Skip to content
Snippets Groups Projects
Commit e793bee2 authored by Oscar Wiberg's avatar Oscar Wiberg
Browse files

bomb tracear

parent 34c9b4f4
No related branches found
No related tags found
1 merge request!2Newmode
......@@ -32,8 +32,8 @@ public class FlyingEnemy extends Object{
}
public Bomb dropBomb() {
//om man vill kan man skicka med players x pos på dirren, blir lite svårare då ba
public Bomb dropBomb(Player p) {
if (!bombDropped && this.getX() >= bombDropX - 50 && this.getX() <= bombDropX + 50) {
Bomb bomb = new Bomb(Constants.bombImg, bombDropX, 50, Constants.bombHeight, Constants.bombWidth); // Drop the bomb at bombDropX
......@@ -42,7 +42,7 @@ public class FlyingEnemy extends Object{
bombDropped = true; // Mark that the bomb has been dropped
// Optionally, reset bombDropX to a new random location after dropping the bomb
bombDropX = dropNextBombX();
bombDropX = p.getPlayerX();
return bomb;
}
......
......@@ -389,7 +389,7 @@ public class PlayState extends GameState {
flyingEnemy.setX(flyingEnemy.getX() -movingSpeed);
Bomb droppedBomb = flyingEnemy.dropBomb();
Bomb droppedBomb = flyingEnemy.dropBomb(player);
if (droppedBomb != null) {
bomb = droppedBomb;
......
......@@ -118,12 +118,12 @@ public class Player {
}
public void setPlayerX(double playerX) {
......@@ -139,7 +139,12 @@ public class Player {
public void moveLeft(int movingSpeed) {
playerX -= movingSpeed;
if (playerX > 0) {
playerX -= movingSpeed;
}
}
......@@ -147,7 +152,12 @@ public class Player {
public void moveRight(int movingSpeed) {
playerX += movingSpeed;
if (playerX < Constants.screenWidth - Constants.playerWidth) {
playerX += movingSpeed;
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment