I think Im finished Fireballs
After Width: | Height: | Size: 340 B |
After Width: | Height: | Size: 299 B |
After Width: | Height: | Size: 321 B |
After Width: | Height: | Size: 1.8 KiB |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 938 B After Width: | Height: | Size: 938 B |
|
@ -7,12 +7,12 @@ sssssssssssssssssd 1 1lllllllll1 1 1
|
|||
sssssssssssssssssd 1
|
||||
sssssssssssssssssd
|
||||
qe qe
|
||||
qwe ad ! ad qre
|
||||
a d qwe qwe atwwwrd qwwwwwwellllqwwwwwwwe ad
|
||||
sssssssssssssssssd zxc asd asd zxxxxxc zxxxxxxxllllxxxxxxxxc ad
|
||||
u qwe ad ! ad qre
|
||||
h k a d qwe qwe atwwwrd qwwwwwwellllqwwwwwwwe ad
|
||||
sssssssssssssssssd m zxc asd asd zxxxxxc zxxxxxxxllllxxxxxxxxc ad
|
||||
sssssssssssssssssd 1 zxc zxc vvvvvvvvwwwwvvvvvvvvv ad
|
||||
sssssssssssssssssd qe vvvvvvvvvvvvvvvvvvvvv ad
|
||||
sssssssssssssssssdlllllad 2 qwwwwwwwwe vvvvvvvvvvvvvvvvvvvvv ad
|
||||
sssssssssssssssssdlllllad bbb s qrsssslssstwe vvvvvvvvvvvvvvvvvvvvv ad
|
||||
sssssssssssssssssdllllladbb s ooqwwrssssllssssstwe ! b h !!! qwe vvvvvvvvvvvvvvvvvvvvv + ad
|
||||
sssssssssssssssssdllllladbb s ooqwwrssssllssssstwe ! b h !!! qwek vvvvvvvvvvvvvvvvvvvvv + ad
|
||||
ssssssssssssssssstwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwrsssssssssssssssstwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwrstwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww3
|
|
@ -7,14 +7,19 @@ public class FireBall extends GenericSprite{
|
|||
|
||||
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) {
|
||||
|
||||
public FireBall(int x, int y, int xv, int yv, String dir,int height, int width) {
|
||||
super(x, y, height, width);
|
||||
xVelocity = xv;
|
||||
yVelocity = yv;
|
||||
if(dir.equals("left")){
|
||||
spritePath = "img/misc/flame/flameLeft.png";
|
||||
} else if(dir.equals("right")){
|
||||
spritePath = "img/misc/flame/flameRight.png";
|
||||
} else if(dir.equals("up")){
|
||||
spritePath = "img/misc/flame/flameUp.png";
|
||||
} else if(dir.equals("down")){
|
||||
spritePath = "img/misc/flame/flameDown.png";
|
||||
}
|
||||
realX = 0;
|
||||
dead = false;
|
||||
|
@ -42,6 +47,9 @@ public class FireBall extends GenericSprite{
|
|||
dead = true;
|
||||
GameFrame.game.player.reset();
|
||||
}
|
||||
// if(y<0||y>GameFrame.game.HEIGHT){
|
||||
// dead = true;
|
||||
// }
|
||||
}
|
||||
public void draw(Graphics g) throws IOException {
|
||||
g.drawImage(GamePanel.getImage(spritePath),x-GameFrame.game.camera.x,y,null);
|
||||
|
|
|
@ -180,7 +180,13 @@ public class GamePanel extends JPanel implements Runnable, KeyListener, Serializ
|
|||
if (mouseAlreadyTranslated) {
|
||||
mouseAlreadyTranslated = false;
|
||||
} else if (!isDialogue && !isPaused) {
|
||||
try {
|
||||
player.mouseReleased(e);
|
||||
} catch (IOException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
} catch (SpriteException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -189,7 +195,13 @@ public class GamePanel extends JPanel implements Runnable, KeyListener, Serializ
|
|||
});
|
||||
addMouseMotionListener(new MouseAdapter() {
|
||||
public void mouseDragged(MouseEvent e) {
|
||||
try {
|
||||
player.mouseDragged(e);
|
||||
} catch (IOException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
} catch (SpriteException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
public void mouseMoved(MouseEvent e) {
|
||||
player.mouseMoved(e);
|
||||
|
@ -467,7 +479,13 @@ 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-20,i.y+Tile.length/2-FireBall.height/2,-fireballSpeed,0,"left"));
|
||||
fireballs.add(new FireBall(i.x-20,i.y+Tile.length/2-4,-fireballSpeed,0,"left",8,16));
|
||||
} else if(i.shootingDir.equals("up")){
|
||||
fireballs.add(new FireBall(i.x+Tile.length/2,i.y-20,0,-fireballSpeed,"up",16,8));
|
||||
} else if(i.shootingDir.equals("right")){
|
||||
fireballs.add(new FireBall(i.x+Tile.length+20,i.y+Tile.length/2-4,fireballSpeed,0,"right",8,16));
|
||||
} else if(i.shootingDir.equals("down")){
|
||||
fireballs.add(new FireBall(i.x+Tile.length/2,i.y+Tile.length+10,0,fireballSpeed,"down",16,8));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ public class GenericSprite extends Rectangle implements Serializable {
|
|||
|
||||
}
|
||||
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
public void mouseReleased(MouseEvent e) throws IOException, SpriteException {
|
||||
|
||||
}
|
||||
public void move() throws IOException {
|
||||
|
|
|
@ -16,6 +16,7 @@ public class LevelManager implements Serializable {
|
|||
public static int bombs;
|
||||
public static void setLevel(int level){
|
||||
GameFrame.game.bombs.clear();
|
||||
GameFrame.game.fireballs.clear();
|
||||
GameFrame.game.player.yVelocity = 0;
|
||||
GameFrame.game.player.xVelocity = 0;
|
||||
LevelManager.level = level;
|
||||
|
|
|
@ -31,6 +31,7 @@ public class MapReader implements Serializable {
|
|||
GameFrame.game.enemy.clear();
|
||||
GameFrame.game.particleTiles.clear();
|
||||
GameFrame.game.shootingTiles.clear();
|
||||
GameFrame.game.fireballs.clear();
|
||||
for(int i=0; i<GameFrame.game.map.length; i++){
|
||||
Arrays.fill(GameFrame.game.map[i], null);
|
||||
}
|
||||
|
@ -102,9 +103,21 @@ public class MapReader implements Serializable {
|
|||
newTile("img/tiles/boxes/steel.png");
|
||||
GameFrame.game.map[x][y].movable = true;
|
||||
} else if(file.charAt(i)=='h'){
|
||||
newTile("img/tiles/boxes/boxCoin.png");
|
||||
newTile("img/tiles/boxes/boxShootLeft.png");
|
||||
GameFrame.game.map[x][y].shootingDir = "left";
|
||||
GameFrame.game.shootingTiles.add(GameFrame.game.map[x][y]);
|
||||
} else if(file.charAt(i)=='u'){
|
||||
newTile("img/tiles/boxes/boxShootUp.png");
|
||||
GameFrame.game.map[x][y].shootingDir = "up";
|
||||
GameFrame.game.shootingTiles.add(GameFrame.game.map[x][y]);
|
||||
} else if(file.charAt(i)=='k'){
|
||||
newTile("img/tiles/boxes/boxShootRight.png");
|
||||
GameFrame.game.map[x][y].shootingDir = "right";
|
||||
GameFrame.game.shootingTiles.add(GameFrame.game.map[x][y]);
|
||||
} else if(file.charAt(i)=='m'){
|
||||
newTile("img/tiles/boxes/boxShootDown.png");
|
||||
GameFrame.game.map[x][y].shootingDir = "down";
|
||||
GameFrame.game.shootingTiles.add(GameFrame.game.map[x][y]);
|
||||
}
|
||||
x+=1;
|
||||
}
|
||||
|
|
|
@ -35,6 +35,8 @@ public class Player extends GenericSprite {
|
|||
|
||||
boolean canPlaceSteel;
|
||||
|
||||
private int pickupDelay = 5;
|
||||
|
||||
// sA[0] is -x, -y
|
||||
// sA[1] is x, -y
|
||||
// sA[2] is -x, y
|
||||
|
@ -184,6 +186,7 @@ public class Player extends GenericSprite {
|
|||
public void move() throws IOException {
|
||||
// mouseX = MouseInfo.getPointerInfo().getLocation().x;
|
||||
// mouseY = MouseInfo.getPointerInfo().getLocation().y;
|
||||
pickupDelay = Math.max(0,pickupDelay - 1);
|
||||
int Tilex = (mouseX + GameFrame.game.camera.x + GamePanel.GAME_WIDTH / 2) / Tile.length;
|
||||
int Tiley = (mouseY / Tile.length);
|
||||
if(holdingSteel){
|
||||
|
@ -296,13 +299,14 @@ public class Player extends GenericSprite {
|
|||
int x = (mouseX + GameFrame.game.camera.x + GamePanel.GAME_WIDTH / 2) / Tile.length;
|
||||
int y = (mouseY / Tile.length);
|
||||
rightMouseDown = true;
|
||||
|
||||
if (pickupDelay == 0) {
|
||||
pickupDelay = 5;
|
||||
if (!holdingSteel) {
|
||||
if (GameFrame.game.map[x][y] != null && GameFrame.game.map[x][y].movable) {
|
||||
double xDis = (this.x + WIDTH / 2) - (GameFrame.game.map[x][y].realX + Tile.length / 2);
|
||||
double yDis = (this.y + HEIGHT / 2) - (GameFrame.game.map[x][y].y + Tile.length / 2);
|
||||
double hypo = Math.sqrt(xDis * xDis + yDis * yDis);
|
||||
if (hypo <steelReachRange) {
|
||||
if (hypo < steelReachRange) {
|
||||
holdingSteel = true;
|
||||
if (GameFrame.game.map[x][y].previousBlock != null) {
|
||||
GameFrame.game.map[x][y] = GameFrame.game.map[x][y].previousBlock;
|
||||
|
@ -311,7 +315,7 @@ public class Player extends GenericSprite {
|
|||
}
|
||||
}
|
||||
}
|
||||
} else if ((GameFrame.game.map[x][y] == null || GameFrame.game.map[x][y].replaceAble) && canPlaceSteel) {
|
||||
} else if (holdingSteel && ((GameFrame.game.map[x][y] == null || GameFrame.game.map[x][y].replaceAble) && canPlaceSteel)) {
|
||||
Tile temp = GameFrame.game.map[x][y];
|
||||
GameFrame.game.map[x][y] = new SingleTile(x * Tile.length - (GamePanel.GAME_WIDTH / 2), y * Tile.length, new BufferedImageWrapper(("img/tiles/boxes/steel.png")));
|
||||
GameFrame.game.map[x][y].movable = true;
|
||||
|
@ -321,6 +325,7 @@ public class Player extends GenericSprite {
|
|||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//TODO
|
||||
|
@ -373,7 +378,7 @@ public class Player extends GenericSprite {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
public void mouseDragged(MouseEvent e) {
|
||||
public void mouseDragged(MouseEvent e) throws IOException, SpriteException {
|
||||
|
||||
mouseX = e.getX();
|
||||
mouseY = e.getY();
|
||||
|
@ -384,7 +389,7 @@ public class Player extends GenericSprite {
|
|||
mouseX = e.getX();
|
||||
mouseY = e.getY();
|
||||
}
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
public void mouseReleased(MouseEvent e) throws IOException, SpriteException {
|
||||
mouseX = e.getX();
|
||||
mouseY = e.getY();
|
||||
if(e.getButton()==MouseEvent.BUTTON1) {
|
||||
|
@ -397,6 +402,7 @@ public class Player extends GenericSprite {
|
|||
}
|
||||
if(e.getButton()==MouseEvent.BUTTON3){
|
||||
rightMouseDown = false;
|
||||
|
||||
}
|
||||
}
|
||||
public void addParticle(int x) throws IOException {
|
||||
|
|