Working on moving block
parent
3caa0b8c37
commit
a569a84a7e
|
@ -7,12 +7,12 @@ sssssssssssssssssd 1 1lllllllll1 1 1
|
||||||
sssssssssssssssssd 1
|
sssssssssssssssssd 1
|
||||||
sssssssssssssssssd
|
sssssssssssssssssd
|
||||||
sssssssssssssssssd ! b qe qe
|
sssssssssssssssssd ! b qe qe
|
||||||
sssssssssssssssssd bbbbb ad ! ad
|
sssssssssssssssssd bbbbb qwe ad ! ad qre
|
||||||
sssssssssssssssssd qwe qwe atwwwrd qwwwwwwellllqwwwwwwwe
|
sssssssssssssssssd a d qwe qwe atwwwrd qwwwwwwellllqwwwwwwwe ad
|
||||||
sssssssssssssssssd asd asd zxxxxxc zxxxxxxxllllxxxxxxxxc
|
sssssssssssssssssd zxc asd asd zxxxxxc zxxxxxxxllllxxxxxxxxc ad
|
||||||
sssssssssssssssssd 1 zxc zxc vvvvvvvvwwwwvvvvvvvvv
|
sssssssssssssssssd 1 zxc zxc vvvvvvvvwwwwvvvvvvvvv ad
|
||||||
sssssssssssssssssd qe vvvvvvvvvvvvvvvvvvvvv
|
sssssssssssssssssd qe vvvvvvvvvvvvvvvvvvvvv ad
|
||||||
sssssssssssssssssdlllllad qwwwwwwwwe vvvvvvvvvvvvvvvvvvvvv
|
sssssssssssssssssdlllllad qwwwwwwwwe vvvvvvvvvvvvvvvvvvvvv ad
|
||||||
sssssssssssssssssdlllllad bbb qrsssslssstwe vvvvvvvvvvvvvvvvvvvvv
|
sssssssssssssssssdlllllad bbb qrsssslssstwe vvvvvvvvvvvvvvvvvvvvv ad
|
||||||
sssssssssssssssssdllllladbb ooqwwrssssllssssstwe !!! qwe vvvvvvvvvvvvvvvvvvvvv +
|
sssssssssssssssssdllllladbb ooqwwrssssllssssstwe !!! qwe vvvvvvvvvvvvvvvvvvvvv + ad
|
||||||
ssssssssssssssssstwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwrsssssssssssssssstwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwrstwwwwwwwwwwwwwwwwwwwwwwwwwwwwww3
|
ssssssssssssssssstwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwrsssssssssssssssstwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwrstwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww3
|
|
@ -251,7 +251,9 @@ public class GamePanel extends JPanel implements Runnable, KeyListener, Serializ
|
||||||
bombs.get(i).move();
|
bombs.get(i).move();
|
||||||
}
|
}
|
||||||
for(int i=0; i<particles.size(); i++){
|
for(int i=0; i<particles.size(); i++){
|
||||||
particles.get(i).move();
|
if(particles.get(i)!=null) {
|
||||||
|
particles.get(i).move();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -332,11 +334,11 @@ public class GamePanel extends JPanel implements Runnable, KeyListener, Serializ
|
||||||
playerFrame = (playerFrame + 1) % 11;
|
playerFrame = (playerFrame + 1) % 11;
|
||||||
playerFrameCounter -= 5;
|
playerFrameCounter -= 5;
|
||||||
// if the player has moved enough to justify a frame change, a new save will also be made
|
// if the player has moved enough to justify a frame change, a new save will also be made
|
||||||
try {
|
// try {
|
||||||
FileManager.writeObjectToFile("local/game_state", this);
|
// FileManager.writeObjectToFile("local/game_state", this);
|
||||||
} catch (IOException e) {
|
// } catch (IOException e) {
|
||||||
e.printStackTrace();
|
// e.printStackTrace();
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
repaint();
|
repaint();
|
||||||
|
|
|
@ -92,12 +92,17 @@ public class NonPlayer extends GenericSprite {
|
||||||
g.drawImage(spriteArray[currentXDirection][currentYDirection][frame], x-GamePanel.camera.x, y, null);
|
g.drawImage(spriteArray[currentXDirection][currentYDirection][frame], x-GamePanel.camera.x, y, null);
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
((Graphics2D)g).setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, (float)fadeCounter));
|
try {
|
||||||
g.drawImage(spriteArray[currentXDirection][currentYDirection][spriteArray[0][0].length-1], x-GamePanel.camera.x, (int)(y+HEIGHT/1.7), null);
|
((Graphics2D) g).setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, (float) fadeCounter));
|
||||||
// reset composite to not affect other sprites being drawn
|
g.drawImage(spriteArray[currentXDirection][currentYDirection][spriteArray[0][0].length - 1], x - GamePanel.camera.x, (int) (y + HEIGHT / 1.7), null);
|
||||||
((Graphics2D)g).setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1));
|
// reset composite to not affect other sprites being drawn
|
||||||
fadeCounter -= 0.01;
|
((Graphics2D) g).setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1));
|
||||||
return 0;
|
fadeCounter -= 0.01;
|
||||||
|
return 0;
|
||||||
|
}catch(Exception e){
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -138,7 +138,10 @@ public class Player extends GenericSprite {
|
||||||
canPlaceSteel = true;
|
canPlaceSteel = true;
|
||||||
boolean adjacent = false;
|
boolean adjacent = false;
|
||||||
int realX = x*Tile.length-GamePanel.camera.x;
|
int realX = x*Tile.length-GamePanel.camera.x;
|
||||||
System.out.println(realX);
|
double xDis = (realX - GamePanel.GAME_WIDTH/2+ Tile.length/2) - (this.x+WIDTH/2);
|
||||||
|
double yDis = (y*Tile.length + Tile.length/2) - (this.y+HEIGHT/2);
|
||||||
|
double hypo = Math.sqrt(xDis*xDis+yDis*yDis);
|
||||||
|
//System.out.println(hypo +" "+xDis + " "+ realX);
|
||||||
int[][]check = {{1,0},{0,1},{-1,0},{0,-1}};
|
int[][]check = {{1,0},{0,1},{-1,0},{0,-1}};
|
||||||
for(int[]a: check){
|
for(int[]a: check){
|
||||||
try{
|
try{
|
||||||
|
@ -152,6 +155,7 @@ public class Player extends GenericSprite {
|
||||||
}
|
}
|
||||||
if(!adjacent){canPlaceSteel = false; return;}
|
if(!adjacent){canPlaceSteel = false; return;}
|
||||||
if(GamePanel.map[x][y]!=null&&!GamePanel.map[x][y].replaceAble){canPlaceSteel = false; return;};
|
if(GamePanel.map[x][y]!=null&&!GamePanel.map[x][y].replaceAble){canPlaceSteel = false; return;};
|
||||||
|
if(hypo>3*Tile.length){canPlaceSteel = false; return;}
|
||||||
}
|
}
|
||||||
public void move() throws IOException {
|
public void move() throws IOException {
|
||||||
// mouseX = MouseInfo.getPointerInfo().getLocation().x;
|
// mouseX = MouseInfo.getPointerInfo().getLocation().x;
|
||||||
|
|
Loading…
Reference in New Issue