Skip to content

Commit 072486a

Browse files
committed
Improved shooting projectiles
1 parent 7689673 commit 072486a

File tree

2 files changed

+6
-16
lines changed

2 files changed

+6
-16
lines changed

src/com/redomar/game/entities/Mob.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -234,22 +234,18 @@ protected void moveMob(double xa, double ya, Mob mob) {
234234
}
235235
}
236236

237-
protected double shoot(double x, double y, double dir, double buttonId){
237+
protected void shoot(double x, double y, double dir, double buttonId){
238238
// dir = dir * (180 /Math.PI);
239239
// Printing print = new Printing();
240240
// print.print("Angle: "+ dir, PrintTypes.GAME);
241241
if(buttonId == 1){
242242
Projectile p = new Small(level, (int) x,(int) y, dir);
243243
projectiles.add(p);
244244
level.addProjectileEntities(p);
245-
return 1;
246-
} else if(buttonId == 2){
245+
} else if(buttonId == 3){
247246
Projectile p = new Medium(level, (int) x,(int) y, dir);
248247
projectiles.add(p);
249248
level.addProjectileEntities(p);
250-
return 2;
251-
} else {
252-
return 0;
253249
}
254250
}
255251

src/com/redomar/game/entities/Player.java

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,22 +66,16 @@ public void tick() {
6666

6767
if (Game.getMouse().getButton() == 1 || Game.getMouse().getButton() == 3){
6868
if(fireRate <= 0){
69-
int buttonId;
7069
if(Game.getMouse().getButton()== 1){
71-
buttonId = 1;
72-
}else {
73-
buttonId = 2;
70+
fireRate = Small.FIRE_RATE;
71+
}else if(Game.getMouse().getButton() == 3){
72+
fireRate = Medium.FIRE_RATE;
7473
}
7574
if(!swim.isActive(swimType)){
7675
double dx = Game.getMouse().getX() - 480/2;
7776
double dy = Game.getMouse().getY() - 320/2;
7877
double dir = Math.atan2(dy, dx);
79-
double shootData = shoot(x, y, dir, buttonId);
80-
if(shootData == 1){
81-
fireRate = Small.FIRE_RATE;
82-
}else if(shootData == 2){
83-
fireRate = Medium.FIRE_RATE;
84-
}
78+
shoot(x, y, dir, Game.getMouse().getButton());
8579
}
8680
}
8781
}

0 commit comments

Comments
 (0)