Skip to content
Snippets Groups Projects
Verified Commit 0a347143 authored by Jan Kožusznik's avatar Jan Kožusznik
Browse files

Correct reload and fire.

parent cf4ad40e
No related merge requests found
...@@ -73,37 +73,35 @@ public class BulletAnimated implements DrawableSimulable, Collisionable{ ...@@ -73,37 +73,35 @@ public class BulletAnimated implements DrawableSimulable, Collisionable{
position = new Point2D(position.getX(), size / 2); position = new Point2D(position.getX(), size / 2);
} }
} else { } else {
fire(); reload();
} }
} }
public Rectangle2D getBoundingBox() { public Rectangle2D getBoundingBox() {
return new Rectangle2D(position.getX(), position.getY() - size, size, size); return new Rectangle2D(position.getX(), position.getY() - size, size, size);
} }
public boolean overlaps(Dragon dragon) { public boolean overlaps(Dragon dragon) {
return getBoundingBox().intersects(dragon.getBoundingBox()); return getBoundingBox().intersects(dragon.getBoundingBox());
} }
public void hitBy(Collisionable other) { public void hitBy(Collisionable other) {
reload(); fire();
} }
public void reload() { public void reload() {
position = start; position = start;
speed = initialSpeed; speed = initialSpeed;
hitToGround = false; hitToGround = false;
accelerate = true;
} }
public void setCanonPower(double value) { public void setCanonPower(double value) {
strenghtOfCannon = value; strenghtOfCannon = value;
} }
public void fire() { public void fire() {
reload(); reload();
accelerate = true;
} }
} }
...@@ -19,7 +19,6 @@ public class GameController { ...@@ -19,7 +19,6 @@ public class GameController {
animationTimer = new DrawingThread(canvas, world); animationTimer = new DrawingThread(canvas, world);
animationTimer.start(); animationTimer.start();
world.setCannonAngle(-45d); world.setCannonAngle(-45d);
world.setCannonPower(100.); world.setCannonPower(100.);
world.fireBullet(); world.fireBullet();
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment