Fireball
parent
5080aeb539
commit
ae4e8906fb
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
|
@ -1,14 +1,22 @@
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
public class FireBall extends GenericSprite{
|
public class FireBall extends GenericSprite{
|
||||||
public FireBall(int x, int y, int height, int width, int xv, int yv) {
|
public String spritePath;
|
||||||
|
public FireBall(int x, int y, int height, int width, int xv, int yv, String dir) {
|
||||||
super(x, y, height, width);
|
super(x, y, height, width);
|
||||||
xVelocity = xv;
|
xVelocity = xv;
|
||||||
yVelocity = yv;
|
yVelocity = yv;
|
||||||
}
|
if(dir.equals("left")){
|
||||||
|
spritePath = "src/img/misc/flame/flameLeft.png";
|
||||||
public void draw(Graphics g){
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void move(){
|
||||||
|
x += xVelocity;
|
||||||
|
y += yVelocity;
|
||||||
|
}
|
||||||
|
public void draw(Graphics g) throws IOException {
|
||||||
|
g.drawImage(GamePanel.getImage(spritePath),x-GameFrame.game.camera.x,y,null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,6 +61,8 @@ public class GamePanel extends JPanel implements Runnable, KeyListener, Serializ
|
||||||
public ArrayList<Tile>particleTiles = new ArrayList<Tile>();
|
public ArrayList<Tile>particleTiles = new ArrayList<Tile>();
|
||||||
|
|
||||||
public ArrayList<Tile>shootingTiles = new ArrayList<Tile>();
|
public ArrayList<Tile>shootingTiles = new ArrayList<Tile>();
|
||||||
|
|
||||||
|
public ArrayList<FireBall>fireballs = new ArrayList<FireBall>();
|
||||||
public ArrayList<NonPlayer>enemy = new ArrayList<NonPlayer>();
|
public ArrayList<NonPlayer>enemy = new ArrayList<NonPlayer>();
|
||||||
public ArrayList<StickyBomb>bombs = new ArrayList<>();
|
public ArrayList<StickyBomb>bombs = new ArrayList<>();
|
||||||
public BombDirectionShow bombDir = null;
|
public BombDirectionShow bombDir = null;
|
||||||
|
@ -319,6 +321,11 @@ public class GamePanel extends JPanel implements Runnable, KeyListener, Serializ
|
||||||
particles.get(i).move();
|
particles.get(i).move();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for(int i=0; i<fireballs.size(); i++){
|
||||||
|
if(fireballs.get(i)!=null){
|
||||||
|
fireballs.get(i).move();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//handles all collision detection and responds accordingly
|
//handles all collision detection and responds accordingly
|
||||||
|
@ -376,12 +383,13 @@ public class GamePanel extends JPanel implements Runnable, KeyListener, Serializ
|
||||||
double ns = 1000000000/amountOfTicks;
|
double ns = 1000000000/amountOfTicks;
|
||||||
double delta = 0;
|
double delta = 0;
|
||||||
long now;
|
long now;
|
||||||
|
int fireballCounter = 0;
|
||||||
while(true){ //this is the infinite game loop
|
while(true){ //this is the infinite game loop
|
||||||
now = System.nanoTime();
|
now = System.nanoTime();
|
||||||
delta = delta + (now-lastTime)/ns;
|
delta = delta + (now-lastTime)/ns;
|
||||||
lastTime = now;
|
lastTime = now;
|
||||||
|
if(fireballCounter<0){fireballCounter = 20;}
|
||||||
|
fireballCounter--;
|
||||||
//only move objects around and update screen if enough time has passed
|
//only move objects around and update screen if enough time has passed
|
||||||
if(delta >= 1){
|
if(delta >= 1){
|
||||||
if ((!isPaused && !isDialogue) && MenuPanel.gameStart) {
|
if ((!isPaused && !isDialogue) && MenuPanel.gameStart) {
|
||||||
|
@ -393,6 +401,9 @@ public class GamePanel extends JPanel implements Runnable, KeyListener, Serializ
|
||||||
}
|
}
|
||||||
checkCollision();
|
checkCollision();
|
||||||
updateEnemy();
|
updateEnemy();
|
||||||
|
if(fireballCounter == 0) {
|
||||||
|
updateShootingBlock();
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
updateParticle();
|
updateParticle();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
@ -433,6 +444,14 @@ 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))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
public void updateParticle() throws IOException {
|
public void updateParticle() throws IOException {
|
||||||
if(particles.size()<10) {
|
if(particles.size()<10) {
|
||||||
for (int i = 0; i < particleTiles.size(); i++) {
|
for (int i = 0; i < particleTiles.size(); i++) {
|
||||||
|
|
|
@ -109,7 +109,7 @@ public class GenericSprite extends Rectangle implements Serializable {
|
||||||
}
|
}
|
||||||
//called frequently from the GamePanel class
|
//called frequently from the GamePanel class
|
||||||
//draws the current location of the ball to the screen
|
//draws the current location of the ball to the screen
|
||||||
public void draw(Graphics g){
|
public void draw(Graphics g) throws IOException {
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue