WOrking o n steel
parent
e4b18eaa85
commit
e1231d1ada
|
@ -6,13 +6,13 @@ sssssssssssssssssd
|
|||
sssssssssssssssssd 1 1lllllllll1 1 1
|
||||
sssssssssssssssssd 1
|
||||
sssssssssssssssssd
|
||||
sssssssssssssssssd ! b qe qe
|
||||
sssssssssssssssssd bbbbb qwe ad ! ad qre
|
||||
sssssssssssssssssd a d qwe qwe atwwwrd qwwwwwwellllqwwwwwwwe ad
|
||||
qe qe
|
||||
qwe ad ! ad qre
|
||||
a d qwe qwe atwwwrd qwwwwwwellllqwwwwwwwe ad
|
||||
sssssssssssssssssd zxc asd asd zxxxxxc zxxxxxxxllllxxxxxxxxc ad
|
||||
sssssssssssssssssd 1 zxc zxc vvvvvvvvwwwwvvvvvvvvv ad
|
||||
sssssssssssssssssd qe vvvvvvvvvvvvvvvvvvvvv ad
|
||||
sssssssssssssssssdlllllad qwwwwwwwwe vvvvvvvvvvvvvvvvvvvvv ad
|
||||
sssssssssssssssssdlllllad bbb qrsssslssstwe vvvvvvvvvvvvvvvvvvvvv ad
|
||||
sssssssssssssssssdllllladbb ooqwwrssssllssssstwe !!! qwe vvvvvvvvvvvvvvvvvvvvv + ad
|
||||
sssssssssssssssssdlllllad 2 qwwwwwwwwe vvvvvvvvvvvvvvvvvvvvv ad
|
||||
sssssssssssssssssdlllllad bbb s qrsssslssstwe vvvvvvvvvvvvvvvvvvvvv ad
|
||||
sssssssssssssssssdllllladbb s ooqwwrssssllssssstwe !!! qwe vvvvvvvvvvvvvvvvvvvvv + ad
|
||||
ssssssssssssssssstwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwrsssssssssssssssstwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwrstwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww3
|
|
@ -12,7 +12,7 @@ sssssssssssssssssd l
|
|||
sssssssssssssssssd asd asd
|
||||
sssssssssssssssssd bbb 1 zxc zxc
|
||||
sssssssssssssssssdbbbbbbbbb
|
||||
sssssssssssssssssd qwwwwwwwwe
|
||||
sssssssssssssssssd 2 qwwwwwwwwe
|
||||
sssssssssssssssssd qrsssssssstwe
|
||||
sssssssssssssssssd bbb qwwrssssssssssstwe qwe +
|
||||
ssssssssssssssssstwwwwwwwwwwwwllllllllllllllllllllsssssssssssssssstwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwrstwwwwww3
|
|
@ -46,7 +46,7 @@ public class GamePanel extends JPanel implements Runnable, KeyListener, Serializ
|
|||
|
||||
//public static ArrayList<Tile>map = new ArrayList<Tile>();
|
||||
|
||||
public Tile[][]map = new Tile[300][18];
|
||||
public Tile[][]map = new Tile[1000][18];
|
||||
public ArrayList<Middleware> middlewareArray = new ArrayList<Middleware>();
|
||||
|
||||
public ArrayList<Tile>particleTiles = new ArrayList<Tile>();
|
||||
|
@ -202,7 +202,7 @@ public class GamePanel extends JPanel implements Runnable, KeyListener, Serializ
|
|||
}
|
||||
for(int i=0; i<particles.size(); i++){
|
||||
// todo: find cause of particles being null
|
||||
if(i<particles.size()) {
|
||||
if(i<particles.size()&&particles.get(i)!=null) {
|
||||
particles.get(i).draw(g);
|
||||
particles.get(i).lifeSpan--;
|
||||
if (particles.get(i).lifeSpan <= 0) {
|
||||
|
@ -334,11 +334,11 @@ public class GamePanel extends JPanel implements Runnable, KeyListener, Serializ
|
|||
playerFrame = (playerFrame + 1) % 11;
|
||||
playerFrameCounter -= 5;
|
||||
// if the player has moved enough to justify a frame change, a new save will also be made
|
||||
try {
|
||||
FileManager.writeObjectToFile("local/game_state", this);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
// try {
|
||||
// FileManager.writeObjectToFile("local/game_state", this);
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
}
|
||||
}
|
||||
repaint();
|
||||
|
@ -358,12 +358,14 @@ public class GamePanel extends JPanel implements Runnable, KeyListener, Serializ
|
|||
}
|
||||
}
|
||||
public void updateParticle() throws IOException {
|
||||
for(Tile t: particleTiles){
|
||||
if(GlobalState.randInt(1,10)==1) {
|
||||
particles.add(new Particle(t.x + GlobalState.randInt(0, Tile.length), t.y + GlobalState.randInt(0, Tile.length / 2),
|
||||
GlobalState.randInt(-3, 3), GlobalState.randInt(-5, 2), GlobalState.randInt(5, 9), "img/particles/LavaParticle.png"));
|
||||
}
|
||||
if(particles.size()<10) {
|
||||
for (int i = 0; i < particleTiles.size(); i++) {
|
||||
if (GlobalState.randInt(1, 20) == 1) {
|
||||
particles.add(new Particle(particleTiles.get(i).x + GlobalState.randInt(0, Tile.length), particleTiles.get(i).y + GlobalState.randInt(0, Tile.length / 2),
|
||||
GlobalState.randInt(-3, 3), GlobalState.randInt(-5, 2), GlobalState.randInt(5, 9), "img/particles/LavaParticle.png"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//if a key is pressed, we'll send it over to the Player class for processing
|
||||
|
|
|
@ -12,6 +12,7 @@ public class LevelManager implements Serializable {
|
|||
|
||||
public static int bombs;
|
||||
public static void setLevel(int level){
|
||||
GameFrame.game.bombs.clear();
|
||||
GameFrame.game.player.yVelocity = 0;
|
||||
GameFrame.game.player.xVelocity = 0;
|
||||
LevelManager.level = level;
|
||||
|
|
|
@ -97,7 +97,7 @@ public class NonPlayer extends GenericSprite implements Serializable {
|
|||
g.drawImage(spriteArray[currentXDirection][currentYDirection][spriteArray[0][0].length-1].image, x-GameFrame.game.camera.x, (int)(y+HEIGHT/1.7), null);
|
||||
// reset composite to not affect other sprites being drawn
|
||||
((Graphics2D)g).setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1));
|
||||
fadeCounter -= 0.01;
|
||||
fadeCounter = Math.max(0, fadeCounter-0.01);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,8 @@ import java.awt.event.MouseEvent;
|
|||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.ImageObserver;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
|
||||
public class Player extends GenericSprite {
|
||||
public final int SPEED = 5;
|
||||
|
@ -150,7 +152,8 @@ public class Player extends GenericSprite {
|
|||
}
|
||||
if(!adjacent){canPlaceSteel = false; return;}
|
||||
if(hypo>3*Tile.length){canPlaceSteel = false; return;}
|
||||
if(GameFrame.game.map[x][y]!=null&&!GameFrame.game.map[x][y].replaceAble){canPlaceSteel = false; return;};
|
||||
if(GameFrame.game.map[x][y]!=null&&!GameFrame.game.map[x][y].replaceAble){canPlaceSteel = false; return;}
|
||||
;
|
||||
}
|
||||
public void move() throws IOException {
|
||||
// mouseX = MouseInfo.getPointerInfo().getLocation().x;
|
||||
|
@ -250,6 +253,7 @@ public class Player extends GenericSprite {
|
|||
}
|
||||
|
||||
public void mousePressed(MouseEvent e) throws SpriteException, IOException {
|
||||
canReach(1,1);
|
||||
mouseX = e.getX();
|
||||
mouseY = e.getY();
|
||||
if(e.getButton()==MouseEvent.BUTTON1) {
|
||||
|
@ -284,6 +288,25 @@ public class Player extends GenericSprite {
|
|||
}
|
||||
|
||||
|
||||
//TODO
|
||||
public boolean canReach(int x, int y){
|
||||
int pX = (int)(((double)GameFrame.game.camera.x + GamePanel.GAME_WIDTH) / Tile.length);
|
||||
int pY = (int)(((double)this.y+HEIGHT/2)/Tile.length);
|
||||
//System.out.println(pX+" "+pY);
|
||||
|
||||
//BFS
|
||||
int[][]check = {{0,1},{1,0},{-1,0},{0,-1}};
|
||||
int[][]dis = new int[1000][18];
|
||||
for(int[]a: dis){
|
||||
Arrays.fill(a, Integer.MAX_VALUE);
|
||||
}
|
||||
boolean[][]vis = new boolean[1000][18];
|
||||
LinkedList<Integer> xx = new LinkedList<>();
|
||||
LinkedList<Integer> yy = new LinkedList<>();
|
||||
dis[pX][pY] = 0;
|
||||
vis[pX][pY] = true;
|
||||
return false;
|
||||
}
|
||||
public void mouseDragged(MouseEvent e) {
|
||||
|
||||
mouseX = e.getX();
|
||||
|
|
|
@ -67,16 +67,16 @@ public class StickyBomb extends GenericSprite implements Serializable {
|
|||
}
|
||||
|
||||
}
|
||||
int lowX = Math.max(0, ((x+GamePanel.GAME_WIDTH)/Tile.length)-4);
|
||||
int lowX = Math.max(0, ((this.x+GamePanel.GAME_WIDTH/2)/Tile.length)-4);
|
||||
int highX = Math.min(lowX + 8, GameFrame.game.map.length);
|
||||
int lowY = Math.max(0,(this.y/Tile.length)-6);
|
||||
int highY = Math.min(lowY + 12, GameFrame.game.map[0].length);
|
||||
for(int i=0; i<100; i++) {
|
||||
for(int i=lowX; i<highX; i++) {
|
||||
for (int j = lowY; j < highY; j++) {
|
||||
if (GameFrame.game.map[i][j] != null && GameFrame.game.map[i][j].breakable) {
|
||||
double disX = (x + WIDTH / 2) - (GameFrame.game.map[i][j].x + Tile.length / 2);
|
||||
double disY = (y + HEIGHT / 2) - (GameFrame.game.map[i][j].y + Tile.length / 2);
|
||||
if (Math.sqrt(disX * disX + disY * disY) < Tile.length * 5) {
|
||||
if (Math.sqrt(disX * disX + disY * disY) < Tile.length * 3) {
|
||||
GameFrame.game.map[i][j] = null;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue