Skip to content

Commit 26a9d82

Browse files
author
Mana
committed
lastCommit
1 parent 5e348a8 commit 26a9d82

15 files changed

+108
-57
lines changed
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
[{"gameLevel":{"level":2,"primaryLives":5,"hit":2,"power":2},"username":"mana","password":"mana","isLoggedIn":false,"score":2,"avatarNumber":9},{"username":"arina","password":"arina","isLoggedIn":true,"score":0,"avatarNumber":4},{"username":"fff","password":"fff","isLoggedIn":true,"score":0,"avatarNumber":7},{"username":"aaa","password":"aaa","isLoggedIn":false,"score":0,"avatarNumber":9},{"username":"sdf","password":"sdf","isLoggedIn":true,"score":0,"avatarNumber":6}]

src/main/java/com/example/game/Controllers/BombHitBossAnimation.java

Lines changed: 0 additions & 35 deletions
This file was deleted.

src/main/java/com/example/game/Controllers/NewMiniBoss.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.example.game.Controllers;
22

33
import com.example.game.Models.MiniBoss;
4-
import com.example.game.Views.GameController;
4+
import com.example.game.Transition.MiniBossAnimation;
55
import javafx.application.Platform;
66
import javafx.scene.layout.AnchorPane;
77

src/main/java/com/example/game/Models/Bomb.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
package com.example.game.Models;
22

3-
import com.example.game.Controllers.BombHitBossAnimation;
3+
import com.example.game.Transition.BombHitBossAnimation;
44
import javafx.event.ActionEvent;
55
import javafx.event.EventHandler;
66
import javafx.scene.image.Image;
77
import javafx.scene.image.ImageView;
88
import javafx.scene.layout.AnchorPane;
99
import javafx.scene.paint.ImagePattern;
10+
import javafx.scene.text.Text;
1011

1112
import java.util.ArrayList;
1213

@@ -17,11 +18,15 @@ public class Bomb {
1718
private double Y;
1819
private ImageView imageView;
1920
private static AnchorPane pane;
21+
private Text bossLives;
22+
private Text playerScores;
2023

21-
public Bomb(ImageView plane, AnchorPane pane){
24+
public Bomb(ImageView plane, AnchorPane pane, Text bossLives, Text playerScores){
2225
ImageView bombImage = createImageView(pane, plane);
2326
this.X = bombImage.getLayoutX();
2427
this.Y = bombImage.getLayoutY();
28+
this.bossLives = bossLives;
29+
this.playerScores = playerScores;
2530
imageView = bombImage;
2631
bombs.add(this);
2732
setPane(pane);
@@ -76,7 +81,7 @@ public boolean bombHitBoss() {
7681
}
7782

7883
public void explode() {
79-
BombHitBossAnimation animation = new BombHitBossAnimation(this, pane);
84+
BombHitBossAnimation animation = new BombHitBossAnimation(this, pane, bossLives, playerScores);
8085
animation.setOnFinished(new EventHandler<ActionEvent>() {
8186
@Override
8287
public void handle(ActionEvent actionEvent) {

src/main/java/com/example/game/Models/Boss.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.example.game.Models;
22

3-
import com.example.game.Controllers.BossShootAnimation;
3+
import com.example.game.Transition.BossShootAnimation;
44
import javafx.event.ActionEvent;
55
import javafx.event.EventHandler;
66
import javafx.scene.image.Image;

src/main/java/com/example/game/Models/Bullet.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.example.game.Models;
22

3-
import com.example.game.Controllers.BulletHitBossAnimation;
3+
import com.example.game.Transition.BulletHitBossAnimation;
44
import javafx.event.ActionEvent;
55
import javafx.event.EventHandler;
66
import javafx.scene.image.Image;

src/main/java/com/example/game/Controllers/BombAnimation.java renamed to src/main/java/com/example/game/Transition/BombAnimation.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
1-
package com.example.game.Controllers;
1+
package com.example.game.Transition;
22

33
import com.example.game.Models.Bomb;
44
import com.example.game.Models.Boss;
5-
import com.example.game.Views.GameController;
65
import javafx.animation.Transition;
7-
import javafx.scene.Node;
86
import javafx.scene.layout.AnchorPane;
97
import javafx.util.Duration;
108

11-
import javax.swing.text.PlainDocument;
12-
import javax.swing.text.html.ImageView;
13-
149
public class BombAnimation extends Transition {
1510

1611
private Bomb bomb;
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
package com.example.game.Transition;
2+
3+
import com.example.game.Controllers.UserController;
4+
import com.example.game.Main;
5+
import com.example.game.Models.Bomb;
6+
import com.example.game.Models.Boss;
7+
import com.example.game.Views.GameController;
8+
import javafx.animation.Transition;
9+
import javafx.scene.image.Image;
10+
import javafx.scene.image.ImageView;
11+
import javafx.scene.layout.AnchorPane;
12+
import javafx.scene.paint.ImagePattern;
13+
import javafx.scene.text.Text;
14+
import javafx.util.Duration;
15+
16+
17+
import java.io.IOException;
18+
19+
public class BombHitBossAnimation extends Transition {
20+
private Bomb bomb;
21+
private AnchorPane pane;
22+
private ImageView imageView;
23+
private Text bossLives;
24+
private Text playerScores;
25+
26+
public BombHitBossAnimation(Bomb bomb, AnchorPane pane, Text bossLives, Text playerScores) {
27+
this.bomb = bomb;
28+
this.pane = pane;
29+
this.bossLives = bossLives;
30+
this.playerScores = playerScores;
31+
ImageView imageView = new ImageView();
32+
imageView.setLayoutX(bomb.getLayoutX() + 50);
33+
imageView.setLayoutY(bomb.getLayoutY());
34+
this.imageView = imageView;
35+
36+
pane.getChildren().add(imageView);
37+
setCycleDuration(Duration.millis(500));
38+
}
39+
@Override
40+
protected void interpolate(double v) {
41+
handleScores();
42+
int frame = (int) Math.floor(v * 11);
43+
ImagePattern dust = new ImagePattern(new Image(getClass().getResource("/com/example/game/img/Hit Dust/" + frame + ".png").toExternalForm()));
44+
bomb.getImageView().setImage(dust.getImage());
45+
}
46+
47+
public void handleScores() {
48+
int bossLives;
49+
Boss boss = Boss.getInstance(pane);
50+
if (UserController.getLoggedInUser() != null) {
51+
int score = UserController.getLoggedInUser().getGameLevel().getPower() * 4;
52+
boss.setLives(boss.getLives() - score);
53+
UserController.getLoggedInUser().setScore(score);
54+
if ((bossLives = boss.getLives()) <= 0) {
55+
try {
56+
GameController.stopMusic();
57+
GameController.setGameOff(true);
58+
Main.changeScene("losePage");
59+
} catch (IOException e) {
60+
e.printStackTrace();
61+
}
62+
}
63+
else {
64+
this.bossLives.setText(Integer.toString(bossLives));
65+
this.playerScores.setText(Integer.toString(UserController.getLoggedInUser().getScore()));
66+
}
67+
}
68+
else {
69+
GameController.setGuestPlayerScore(GameController.getGuestPlayerScore() + 4);
70+
boss.setLives(boss.getLives() - 2);
71+
if ((bossLives = boss.getLives()) <= 0) {
72+
try {
73+
GameController.stopMusic();
74+
GameController.setGameOff(true);
75+
Main.changeScene("losePage");
76+
} catch (IOException e) {
77+
e.printStackTrace();
78+
}
79+
}
80+
else {
81+
this.bossLives.setText(Integer.toString(boss.getLives()));
82+
this.playerScores.setText(Integer.toString(GameController.getGuestPlayerScore()));
83+
}
84+
}
85+
}
86+
}

src/main/java/com/example/game/Controllers/BossAnimation.java renamed to src/main/java/com/example/game/Transition/BossAnimation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.example.game.Controllers;
1+
package com.example.game.Transition;
22

33
import com.example.game.Models.Boss;
44
import javafx.animation.Transition;

src/main/java/com/example/game/Controllers/BossShootAnimation.java renamed to src/main/java/com/example/game/Transition/BossShootAnimation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.example.game.Controllers;
1+
package com.example.game.Transition;
22

33
import com.example.game.Models.Boss;
44
import com.example.game.Models.Egg;

0 commit comments

Comments
 (0)