-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Player now uses Gun class for weapon.
Player now has three lives. When player loses all health a life will be lost. Added "graphical" heads-up-display with player lives, health, and current weapon name. removed debug log from highscoreList class. refactored gun parameter names.
- Loading branch information
Showing
8 changed files
with
147 additions
and
37 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1 @@ | ||
1000,Thomas | ||
40000,Eddison | ||
10000,George | ||
5000,Micheal | ||
110,Player1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package org.gdc.gdcalaga; | ||
import org.newdawn.slick.Color; | ||
import org.newdawn.slick.Graphics; | ||
import org.newdawn.slick.Image; | ||
import org.newdawn.slick.SlickException; | ||
|
||
public class HeadsUpDisplay { | ||
|
||
private Image lifeIcon = null; | ||
private Image healthIcon = null; | ||
|
||
private int livesX = 100; | ||
private int livesY = 15; | ||
private int livesIconOffset = 20; | ||
|
||
private int healthX = 180; | ||
private int healthY = 15; | ||
private int healthIconOffset = 25; | ||
|
||
private int weaponX = 450; | ||
private int weaponY = 15; | ||
|
||
|
||
private int imageScale = 1; | ||
private Player player; | ||
|
||
public HeadsUpDisplay(Player player) { | ||
this.player = player; | ||
} | ||
|
||
public void render(Graphics g) { | ||
|
||
loadResources(); | ||
if(player != null) { | ||
drawHealthBar(g); | ||
drawLives(g); | ||
drawWeapon(g); | ||
} | ||
} | ||
|
||
private void loadResources() { | ||
if(lifeIcon == null){ | ||
try { | ||
lifeIcon = new Image("Pics/upgrade_invalid.png"); | ||
} | ||
catch (SlickException e) { | ||
e.printStackTrace(); | ||
} | ||
|
||
try { | ||
healthIcon = new Image("Pics/HealthBar.png"); | ||
} | ||
catch (SlickException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
} | ||
|
||
private void drawHealthBar(Graphics g) | ||
{ | ||
for(int i = 0; i < player.getHealth(); ++i) | ||
{ | ||
healthIcon.draw(healthX + (healthIconOffset*i), healthY, imageScale, Color.white); | ||
} | ||
} | ||
|
||
private void drawLives(Graphics g) { | ||
for(int i = 0; i < player.getLives(); ++i) | ||
{ | ||
lifeIcon.draw(livesX + (livesIconOffset*i), livesY, imageScale, Color.white); | ||
} | ||
} | ||
|
||
private void drawWeapon(Graphics g) { | ||
|
||
String weaponName = new String("Weapon: " + player.getWeapon().getName()); | ||
g.drawString(weaponName, weaponX, weaponY); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters