Skip to content

Commit 0870961

Browse files
authored
Merge branch 'main' into add-coin-functionalities
2 parents 42aa48e + 852ad94 commit 0870961

File tree

6 files changed

+65
-65
lines changed

6 files changed

+65
-65
lines changed

src/main/java/com/dinosaur/dinosaurexploder/components/BombComponent.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public void onAdded() {
6262
bombText = new Text(languageManager.getTranslation("bombs_left") + ": " + bombCount);
6363

6464
// Style the text
65-
bombText.setFill(Color.BLUE);
65+
bombText.setFill(Color.ORANGE);
6666
bombText.setFont(Font.font(GameConstants.ARCADE_CLASSIC_FONTNAME, 20));
6767
bombText.setLayoutX(0);
6868
bombText.setLayoutY(0);

src/main/java/com/dinosaur/dinosaurexploder/components/CollectedCoinsComponent.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public void onAdded() {
3131

3232
// Create UI elements
3333
coinText = new Text();
34-
coinText.setFill(Color.GOLDENROD);
34+
coinText.setFill(Color.PURPLE);
3535
coinText.setFont(Font.font(GameConstants.ARCADE_CLASSIC_FONTNAME, 20));
3636
coinText.setLayoutX(0);
3737
coinText.setLayoutY(0);

src/main/java/com/dinosaur/dinosaurexploder/components/LifeComponent.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,10 @@ private void updateLifeDisplay() {
8080
}
8181

8282
// Display the lifeText component
83+
lifeText.setText(languageManager.getTranslation("lives") + ": " + life);
8384
setEntity(lifeText);
8485
}
8586

86-
8787
// Created two methods for shorter and cleaner code
8888
public void setEntity(Node j) {
8989
entity.getViewComponent().addChild(j);

src/main/java/com/dinosaur/dinosaurexploder/components/ScoreComponent.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ private void createScoreUI() {
6262

6363
private Text createText() {
6464
Text text = new Text();
65-
text.setFill(Color.GREEN);
65+
text.setFill(Color.YELLOW);
6666
text.setFont(Font.font(GameConstants.ARCADE_CLASSIC_FONTNAME, GameConstants.TEXT_SIZE_GAME_DETAILS));
6767
return text;
6868
}

src/main/java/com/dinosaur/dinosaurexploder/controller/DinosaurController.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
/**
2626
* Summary :
27-
* The Factory handles the Dinosaur , player controls and collision detection of all entities in the game
27+
* The Factory handles the Dinosaur , player controls and collision detection of all entities in the game
2828
*/
2929
public class DinosaurController {
3030
LanguageManager languageManager = LanguageManager.getInstance();
@@ -44,7 +44,7 @@ public class DinosaurController {
4444
* Summary :
4545
* Detecting the player damage to decrease the lives and checking if the game is over
4646
*/
47-
public void damagePlayer() {
47+
public void damagePlayer() {
4848
if(player.getComponent(PlayerComponent.class).isInvincible()){
4949
return;
5050
}
@@ -103,11 +103,11 @@ public void initGame() {
103103
private void initGameEntities(){
104104
spawn("background", 0, 0);
105105
player = spawn("player", getAppCenter().getX() - 45, getAppHeight() - 200);
106-
levelDisplay = spawn("Level", getAppCenter().getX() - 270, getAppCenter().getY() - 350);
107-
score = spawn("Score", getAppCenter().getX() - 270, getAppCenter().getY() - 320);
108-
life = spawn("Life", getAppCenter().getX() - 260, getAppCenter().getY() - 250);
109-
bomb = spawn("Bomb", getAppCenter().getX() - 260, getAppCenter().getY() - 180);
110-
Entity coin = spawn("Coins", getAppCenter().getX() - 260, getAppCenter().getY() - 120);
106+
levelDisplay = spawn("Level", getAppCenter().getX() - 270, getAppCenter().getY() + 350);
107+
score = spawn("Score", getAppCenter().getX() - 270, getAppCenter().getY() - 350);
108+
life = spawn("Life", getAppCenter().getX() - 260, getAppCenter().getY() + 290);
109+
bomb = spawn("Bomb", getAppCenter().getX() - 260, getAppCenter().getY() - 280);
110+
Entity coin = spawn("Coins", getAppCenter().getX() - 260, getAppCenter().getY() - 235);
111111
collectedCoinsComponent = coin.getComponent(CollectedCoinsComponent.class);
112112
bomb.addComponent(new BombComponent());
113113
}
@@ -123,7 +123,7 @@ private void spawnEnemies(){
123123
}
124124

125125
enemySpawnTimer = run(() -> {
126-
if(levelManager.getCurrentLevel()%5==0){
126+
if(levelManager.getCurrentLevel()% 5==0) {
127127
pauseEnemySpawning();
128128
bossSpawner.spawnNewBoss();
129129
}else {
@@ -185,7 +185,7 @@ private void showLevelMessage(){
185185
if (bomb.hasComponent(BombComponent.class)) {
186186
bomb.getComponent(BombComponent.class).checkLevelForBombRegeneration(levelManager.getCurrentLevel());
187187
}
188-
188+
189189
// Resume gameplay after a delay
190190
runOnce(() -> {
191191
getGameScene().removeUINode(levelText);
@@ -335,7 +335,7 @@ public void initPhysics() {
335335
collectedCoinsComponent.incrementCoin();
336336

337337
score.getComponent(ScoreComponent.class).incrementScore(2);
338-
338+
339339
// Check for bomb regeneration when coin is collected
340340
if (bomb.hasComponent(BombComponent.class)) {
341341
bomb.getComponent(BombComponent.class).trackCoinForBombRegeneration();

src/main/java/com/dinosaur/dinosaurexploder/model/GameEntityFactory.java

Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -143,28 +143,28 @@ public Entity newGreenDino(SpawnData data) {
143143
* spawn random coin on the window
144144
*/
145145

146-
@Spawns("coin")
147-
public Entity newCoin(SpawnData data) {
148-
System.out.println("Loading coin texture: " + GameConstants.COIN_IMAGE_FILE);
149-
return entityBuilderBase(data, EntityType.COIN)
150-
.with(new OffscreenCleanComponent())
151-
.view(texture(GameConstants.COIN_IMAGE_FILE, 40, 40))
152-
.bbox(new HitBox(BoundingShape.box(40, 40)))
153-
.collidable()
154-
.with(new CoinComponent())
155-
.build();
156-
}
146+
@Spawns("coin")
147+
public Entity newCoin(SpawnData data) {
148+
System.out.println("Loading coin texture: " + GameConstants.COIN_IMAGE_FILE);
149+
return entityBuilderBase(data, EntityType.COIN)
150+
.with(new OffscreenCleanComponent())
151+
.view(texture(GameConstants.COIN_IMAGE_FILE, 40, 40))
152+
.bbox(new HitBox(BoundingShape.box(40, 40)))
153+
.collidable()
154+
.with(new CoinComponent())
155+
.build();
156+
}
157157

158-
@Spawns("redDino")
159-
public Entity newRedDino(SpawnData data) {
160-
return entityBuilderBase(data, EntityType.RED_DINO)
161-
.with(new OffscreenCleanComponent())
162-
.view(texture(GameConstants.RED_DINO_IMAGE_FILE, 100, 80))
163-
.bbox(new HitBox(BoundingShape.box(65, 55)))
164-
.collidable()
165-
.with(new RedDinoComponent())
166-
.build();
167-
}
158+
@Spawns("redDino")
159+
public Entity newRedDino(SpawnData data) {
160+
return entityBuilderBase(data, EntityType.RED_DINO)
161+
.with(new OffscreenCleanComponent())
162+
.view(texture(GameConstants.RED_DINO_IMAGE_FILE, 100, 80))
163+
.bbox(new HitBox(BoundingShape.box(65, 55)))
164+
.collidable()
165+
.with(new RedDinoComponent())
166+
.build();
167+
}
168168

169169
@Spawns("healthBar")
170170
public Entity newHealthbar(SpawnData data) {
@@ -176,36 +176,36 @@ public Entity newHealthbar(SpawnData data) {
176176
.build();
177177
}
178178

179-
/**
180-
* Summary :
181-
* Spawn of a heart in the window will be handled in below Entity
182-
*/
183-
@Spawns("heart")
184-
public Entity newHeart(SpawnData data) {
185-
System.out.println("Loading heart texture: " + GameConstants.HEART_IMAGE_FILE);
186-
return entityBuilderBase(data, EntityType.HEART)
187-
.with(new OffscreenCleanComponent())
188-
.view(texture(GameConstants.HEART_IMAGE_FILE))
189-
.bbox(new HitBox(BoundingShape.box(22, 22)))
190-
.collidable()
191-
.with(new Heart())
192-
.build();
193-
}
179+
/**
180+
* Summary :
181+
* Spawn of a heart in the window will be handled in below Entity
182+
*/
183+
@Spawns("heart")
184+
public Entity newHeart(SpawnData data) {
185+
System.out.println("Loading heart texture: " + GameConstants.HEART_IMAGE_FILE);
186+
return entityBuilderBase(data, EntityType.HEART)
187+
.with(new OffscreenCleanComponent())
188+
.view(texture(GameConstants.HEART_IMAGE_FILE))
189+
.bbox(new HitBox(BoundingShape.box(22, 22)))
190+
.collidable()
191+
.with(new Heart())
192+
.build();
193+
}
194194

195-
/**
196-
* Summary :
197-
* Setting up the Score will be handled in below Entity
198-
*/
199-
@Spawns("Score")
200-
public Entity newScore(SpawnData data) {
201-
Text scoreText = new Text("");
202-
scoreText.setFill(Color.GREEN);
203-
scoreText.setFont(Font.font(GameConstants.ARCADE_CLASSIC_FONTNAME, 20));
204-
return entityBuilderBase(data, EntityType.SCORE)
205-
.view(scoreText)
206-
.with(new ScoreComponent())
207-
.with(new OffscreenCleanComponent()).build();
208-
}
195+
/**
196+
* Summary :
197+
* Setting up the Score will be handled in below Entity
198+
*/
199+
@Spawns("Score")
200+
public Entity newScore(SpawnData data) {
201+
Text scoreText = new Text("");
202+
scoreText.setFill(Color.GREEN);
203+
scoreText.setFont(Font.font(GameConstants.ARCADE_CLASSIC_FONTNAME, 20));
204+
return entityBuilderBase(data, EntityType.SCORE)
205+
.view(scoreText)
206+
.with(new ScoreComponent())
207+
.with(new OffscreenCleanComponent()).build();
208+
}
209209

210210
/**
211211
* Summary :
@@ -270,7 +270,7 @@ public Entity newExplosion(SpawnData data) {
270270
@Spawns("Level")
271271
public Entity newLevel(SpawnData data) {
272272
Text levelText = new Text("Level: 1");
273-
levelText.setFill(Color.YELLOW);
273+
levelText.setFill(Color.LIGHTBLUE);
274274
levelText.setTranslateX(10);
275275
levelText.setFont(
276276
Font.font(GameConstants.ARCADE_CLASSIC_FONTNAME, GameConstants.TEXT_SIZE_GAME_DETAILS));

0 commit comments

Comments
 (0)