diff --git a/img/misc/flame/flameLeft.png b/img/misc/flame/flameLeft.png index 661a64c..2e670d3 100644 Binary files a/img/misc/flame/flameLeft.png and b/img/misc/flame/flameLeft.png differ diff --git a/saves/Level1.txt b/saves/Level1.txt index 77da5e2..da9ae01 100644 --- a/saves/Level1.txt +++ b/saves/Level1.txt @@ -12,7 +12,7 @@ sssssssssssssssssd sssssssssssssssssd zxc asd asd zxxxxxc zxxxxxxxllllxxxxxxxxc ad sssssssssssssssssd 1 zxc zxc vvvvvvvvwwwwvvvvvvvvv ad sssssssssssssssssd qe vvvvvvvvvvvvvvvvvvvvv ad -sssssssssssssssssdlllllad 2 hqwwwwwwwwe vvvvvvvvvvvvvvvvvvvvv ad +sssssssssssssssssdlllllad 2 qwwwwwwwwe vvvvvvvvvvvvvvvvvvvvv ad sssssssssssssssssdlllllad bbb s qrsssslssstwe vvvvvvvvvvvvvvvvvvvvv ad -sssssssssssssssssdllllladbb s ooqwwrssssllssssstwe !!! qwe vvvvvvvvvvvvvvvvvvvvv + ad +sssssssssssssssssdllllladbb s ooqwwrssssllssssstwe ! b h !!! qwe vvvvvvvvvvvvvvvvvvvvv + ad ssssssssssssssssstwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwrsssssssssssssssstwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwrstwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww3 \ No newline at end of file diff --git a/src/FireBall.java b/src/FireBall.java index 683557d..f40b0bd 100644 --- a/src/FireBall.java +++ b/src/FireBall.java @@ -3,20 +3,47 @@ import java.io.IOException; public class FireBall extends GenericSprite{ public String spritePath; - public FireBall(int x, int y, int height, int width, int xv, int yv, String dir) { + private int realX; + + public boolean dead; + + public static final int height = 8; + public static final int width = 16; + public FireBall(int x, int y, int xv, int yv, String dir) { super(x, y, height, width); xVelocity = xv; yVelocity = yv; if(dir.equals("left")){ spritePath = "img/misc/flame/flameLeft.png"; } + realX = 0; + dead = false; } + public void update(){ + realX = x-GameFrame.game.camera.x; + } + + public boolean collidePlayer(Player p){ + if(realX+width>p.x&&realX0&&!player.holdingSteel){ bombDir = new BombDirectionShow(this.player.x + this.camera.x + WIDTH/2, this.player.y+HEIGHT/2, (player.mouseX - this.player.x) / 20, (player.mouseY - this.player.y) / 10); @@ -395,8 +404,7 @@ public class GamePanel extends JPanel implements Runnable, KeyListener, Serializ now = System.nanoTime(); delta = delta + (now-lastTime)/ns; lastTime = now; -// if(fireballCounter<0){fireballCounter = 20;} -// fireballCounter--; + //only move objects around and update screen if enough time has passed if(delta >= 1){ if ((!isPaused && !isDialogue) && MenuPanel.gameStart) { @@ -408,7 +416,11 @@ public class GamePanel extends JPanel implements Runnable, KeyListener, Serializ } checkCollision(); updateEnemy(); -//wwwwwwww + if(fireballCounter<0){fireballCounter = 100;} + fireballCounter--; + if(fireballCounter == 0){ + updateShootingBlock(); + } try { updateParticle(); } catch (IOException e) { @@ -455,7 +467,7 @@ public class GamePanel extends JPanel implements Runnable, KeyListener, Serializ public void updateShootingBlock(){ for(Tile i: shootingTiles){ if(i.shootingDir.equals("left")){ - //fireballs.add(new FireBall(i.x,i.y,80,41,-1,0,"left")); + fireballs.add(new FireBall(i.x-20,i.y+Tile.length/2-FireBall.height/2,-fireballSpeed,0,"left")); } } } diff --git a/src/Main.java b/src/Main.java index a87b5bc..84f982f 100644 --- a/src/Main.java +++ b/src/Main.java @@ -8,6 +8,6 @@ class Main { public static void main(String[] args) { new GameFrame(); - + } } \ No newline at end of file diff --git a/src/MenuPanel.java b/src/MenuPanel.java index a7f9abd..4bd729e 100644 --- a/src/MenuPanel.java +++ b/src/MenuPanel.java @@ -10,6 +10,7 @@ Implements Runnable interface to use "threading" - let the game do two things at import java.awt.*; import java.awt.event.*; import java.awt.image.BufferedImage; +import java.io.File; import java.io.IOException; import java.util.ArrayList; import javax.sound.sampled.LineUnavailableException; @@ -183,6 +184,16 @@ public class MenuPanel extends JPanel implements Runnable, KeyListener{ } } + public static void deleteFiles(File dirPath) { + File filesList[] = dirPath.listFiles(); + for(File file : filesList) { + if(file.isFile()) { + file.delete(); + } else { + deleteFiles(file); + } + } + } //if a key is released, we'll send it over to the Player class for processing public void keyReleased(KeyEvent e){ diff --git a/src/Player.java b/src/Player.java index 0cf08dc..7ee2925 100644 --- a/src/Player.java +++ b/src/Player.java @@ -14,7 +14,6 @@ import java.util.Arrays; import java.util.LinkedList; public class Player extends GenericSprite { - public final int SPEED = 5; public static final int PLAYER_WIDTH = 52; public static final int PLAYER_HEIGHT = 94; @@ -50,6 +49,11 @@ public class Player extends GenericSprite { leftMouseDown = false; holdingSteel = false; canPlaceSteel = false; + rightPressed = false; + leftPressed = false; + upPressed= false; + downPressed = false; + isGrounded = false; } @@ -126,12 +130,7 @@ public class Player extends GenericSprite { return canUpdate; } -// public boolean SteelCollide(GenericSprite g, int x, int y){ -// if(x+WIDTH>tile.realX&&x xx = new LinkedList<>(); - LinkedList yy = new LinkedList<>(); - xx.add(pX); - yy.add(pY); - dis[pX][pY] = 0; - vis[pX][pY] = true; - while(!xx.isEmpty()){ - int tempX = xx.poll(); - int tempY = yy.poll(); - for(int[]a: check){ - try{ - int newX = tempX + a[0]; - int newY = tempY + a[1]; - if(dis[tempX][tempY]+1<(Math.min(6,dis[newX][newY]))) { - dis[newX][newY] = dis[tempX][tempY]+1; - if(GameFrame.game.map[newX][newY]==null||GameFrame.game.map[newX][newY].replaceAble) { - xx.add(newX); - yy.add(newY); + try { + 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); + if (pY < 0) { + return false; + } + //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 xx = new LinkedList<>(); + LinkedList yy = new LinkedList<>(); + xx.add(pX); + yy.add(pY); + dis[pX][pY] = 0; + vis[pX][pY] = true; + while (!xx.isEmpty()) { + int tempX = xx.poll(); + int tempY = yy.poll(); + for (int[] a : check) { + try { + int newX = tempX + a[0]; + int newY = tempY + a[1]; + if (dis[tempX][tempY] + 1 < (Math.min(6, dis[newX][newY]))) { + dis[newX][newY] = dis[tempX][tempY] + 1; + if (GameFrame.game.map[newX][newY] == null || GameFrame.game.map[newX][newY].replaceAble) { + xx.add(newX); + yy.add(newY); + } } - } - } catch(Exception e){ + } catch (Exception e) { + } } } - } - if(dis[x][y]<=6){ - return true; - } + if (dis[x][y] <= 6) { + return true; + } - return false; + return false; + }catch(Exception e){ + return false; + } } public void mouseDragged(MouseEvent e) { @@ -386,7 +389,7 @@ public class Player extends GenericSprite { mouseY = e.getY(); if(e.getButton()==MouseEvent.BUTTON1) { leftMouseDown = false; - if (GameFrame.game.bombs.size() < 3 && LevelManager.bombs>0) { + if (GameFrame.game.bombs.size() < 3 && LevelManager.bombs>0 && !holdingSteel) { LevelManager.bombs--; GameFrame.game.bombs.add(new StickyBomb(GameFrame.game.player.x + GameFrame.game.camera.x + WIDTH/2, GameFrame.game.player.y+HEIGHT/2, (mouseX - GameFrame.game.player.x) / 20, (mouseY - GameFrame.game.player.y) / 10, GameFrame.game.bomb, GameFrame.game.explosionArray)); diff --git a/src/Tile.java b/src/Tile.java index bff8c06..60dca6d 100644 --- a/src/Tile.java +++ b/src/Tile.java @@ -24,6 +24,8 @@ public class Tile implements Serializable { public Tile previousBlock; public String shootingDir; + + public Tile(int x, int y){ isFinish = false; collision = true;