WOrking o n steel

master
bob 2022-06-15 11:25:38 -04:00
parent e4b18eaa85
commit e1231d1ada
7 changed files with 50 additions and 24 deletions

View File

@ -6,13 +6,13 @@ sssssssssssssssssd
sssssssssssssssssd 1 1lllllllll1 1 1 sssssssssssssssssd 1 1lllllllll1 1 1
sssssssssssssssssd 1 sssssssssssssssssd 1
sssssssssssssssssd sssssssssssssssssd
sssssssssssssssssd ! b qe qe qe qe
sssssssssssssssssd bbbbb qwe ad ! ad qre qwe ad ! ad qre
sssssssssssssssssd a d qwe qwe atwwwrd qwwwwwwellllqwwwwwwwe ad a d qwe qwe atwwwrd qwwwwwwellllqwwwwwwwe ad
sssssssssssssssssd zxc asd asd zxxxxxc zxxxxxxxllllxxxxxxxxc ad sssssssssssssssssd zxc asd asd zxxxxxc zxxxxxxxllllxxxxxxxxc ad
sssssssssssssssssd 1 zxc zxc vvvvvvvvwwwwvvvvvvvvv ad sssssssssssssssssd 1 zxc zxc vvvvvvvvwwwwvvvvvvvvv ad
sssssssssssssssssd qe vvvvvvvvvvvvvvvvvvvvv ad sssssssssssssssssd qe vvvvvvvvvvvvvvvvvvvvv ad
sssssssssssssssssdlllllad qwwwwwwwwe vvvvvvvvvvvvvvvvvvvvv ad sssssssssssssssssdlllllad 2 qwwwwwwwwe vvvvvvvvvvvvvvvvvvvvv ad
sssssssssssssssssdlllllad bbb qrsssslssstwe vvvvvvvvvvvvvvvvvvvvv ad sssssssssssssssssdlllllad bbb s qrsssslssstwe vvvvvvvvvvvvvvvvvvvvv ad
sssssssssssssssssdllllladbb ooqwwrssssllssssstwe !!! qwe vvvvvvvvvvvvvvvvvvvvv + ad sssssssssssssssssdllllladbb s ooqwwrssssllssssstwe !!! qwe vvvvvvvvvvvvvvvvvvvvv + ad
ssssssssssssssssstwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwrsssssssssssssssstwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwrstwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww3 ssssssssssssssssstwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwrsssssssssssssssstwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwrstwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww3

View File

@ -12,7 +12,7 @@ sssssssssssssssssd l
sssssssssssssssssd asd asd sssssssssssssssssd asd asd
sssssssssssssssssd bbb 1 zxc zxc sssssssssssssssssd bbb 1 zxc zxc
sssssssssssssssssdbbbbbbbbb sssssssssssssssssdbbbbbbbbb
sssssssssssssssssd qwwwwwwwwe sssssssssssssssssd 2 qwwwwwwwwe
sssssssssssssssssd qrsssssssstwe sssssssssssssssssd qrsssssssstwe
sssssssssssssssssd bbb qwwrssssssssssstwe qwe + sssssssssssssssssd bbb qwwrssssssssssstwe qwe +
ssssssssssssssssstwwwwwwwwwwwwllllllllllllllllllllsssssssssssssssstwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwrstwwwwww3 ssssssssssssssssstwwwwwwwwwwwwllllllllllllllllllllsssssssssssssssstwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwrstwwwwww3

View File

@ -46,7 +46,7 @@ public class GamePanel extends JPanel implements Runnable, KeyListener, Serializ
//public static ArrayList<Tile>map = new ArrayList<Tile>(); //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<Middleware> middlewareArray = new ArrayList<Middleware>();
public ArrayList<Tile>particleTiles = new ArrayList<Tile>(); 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++){ for(int i=0; i<particles.size(); i++){
// todo: find cause of particles being null // 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).draw(g);
particles.get(i).lifeSpan--; particles.get(i).lifeSpan--;
if (particles.get(i).lifeSpan <= 0) { if (particles.get(i).lifeSpan <= 0) {
@ -334,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();
@ -358,12 +358,14 @@ public class GamePanel extends JPanel implements Runnable, KeyListener, Serializ
} }
} }
public void updateParticle() throws IOException { public void updateParticle() throws IOException {
for(Tile t: particleTiles){ if(particles.size()<10) {
if(GlobalState.randInt(1,10)==1) { for (int i = 0; i < particleTiles.size(); i++) {
particles.add(new Particle(t.x + GlobalState.randInt(0, Tile.length), t.y + GlobalState.randInt(0, Tile.length / 2), if (GlobalState.randInt(1, 20) == 1) {
GlobalState.randInt(-3, 3), GlobalState.randInt(-5, 2), GlobalState.randInt(5, 9), "img/particles/LavaParticle.png")); 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 //if a key is pressed, we'll send it over to the Player class for processing

View File

@ -12,6 +12,7 @@ public class LevelManager implements Serializable {
public static int bombs; public static int bombs;
public static void setLevel(int level){ public static void setLevel(int level){
GameFrame.game.bombs.clear();
GameFrame.game.player.yVelocity = 0; GameFrame.game.player.yVelocity = 0;
GameFrame.game.player.xVelocity = 0; GameFrame.game.player.xVelocity = 0;
LevelManager.level = level; LevelManager.level = level;

View File

@ -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); 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 // reset composite to not affect other sprites being drawn
((Graphics2D)g).setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1)); ((Graphics2D)g).setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1));
fadeCounter -= 0.01; fadeCounter = Math.max(0, fadeCounter-0.01);
return 0; return 0;
} }
} }

View File

@ -10,6 +10,8 @@ import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.awt.image.ImageObserver; import java.awt.image.ImageObserver;
import java.io.IOException; import java.io.IOException;
import java.util.Arrays;
import java.util.LinkedList;
public class Player extends GenericSprite { public class Player extends GenericSprite {
public final int SPEED = 5; public final int SPEED = 5;
@ -150,7 +152,8 @@ public class Player extends GenericSprite {
} }
if(!adjacent){canPlaceSteel = false; return;} if(!adjacent){canPlaceSteel = false; return;}
if(hypo>3*Tile.length){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 { public void move() throws IOException {
// mouseX = MouseInfo.getPointerInfo().getLocation().x; // mouseX = MouseInfo.getPointerInfo().getLocation().x;
@ -250,6 +253,7 @@ public class Player extends GenericSprite {
} }
public void mousePressed(MouseEvent e) throws SpriteException, IOException { public void mousePressed(MouseEvent e) throws SpriteException, IOException {
canReach(1,1);
mouseX = e.getX(); mouseX = e.getX();
mouseY = e.getY(); mouseY = e.getY();
if(e.getButton()==MouseEvent.BUTTON1) { 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) { public void mouseDragged(MouseEvent e) {
mouseX = e.getX(); mouseX = e.getX();

View File

@ -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 highX = Math.min(lowX + 8, GameFrame.game.map.length);
int lowY = Math.max(0,(this.y/Tile.length)-6); int lowY = Math.max(0,(this.y/Tile.length)-6);
int highY = Math.min(lowY + 12, GameFrame.game.map[0].length); 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++) { for (int j = lowY; j < highY; j++) {
if (GameFrame.game.map[i][j] != null && GameFrame.game.map[i][j].breakable) { 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 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); 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; GameFrame.game.map[i][j] = null;
} }
} }