Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

added some menu functionality and two new weapons to enemies. #8

Merged
merged 2 commits into from

2 participants

@frekfra

Added mainmenu, (newgame button will not reset game state.)
Added Highscore list, will be read and written to file.
Added Gun clas which acts as a bullet factory.
Enemies have randomized guns (three variants, straight shot, shot in player direction, and triple shot)
change damage to be on entity instead of bullet in order to do ship-to-ship collision damage.
Modified PlayState to use state variable to change render and input mechanics.

frekfra added some commits
@frekfra frekfra Added mainmenu, (newgame button will not reset game state.)
Added Highscore list, will be read and written to file.
Added Gun clas which acts as a bullet factory.
Enemies have randomized guns (three variants, straight shot, shot in player direction, and triple shot)
change damage to be on entity instead of bullet in order to do ship-to-ship collision damage.
Modified PlayState to use state variable to change render and input mechanics.
19be149
@frekfra frekfra Delete #Player.java#
unintended commit
1b89786
@SubSage SubSage merged commit c4c85e2 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 30, 2013
  1. @frekfra

    Added mainmenu, (newgame button will not reset game state.)

    frekfra authored
    Added Highscore list, will be read and written to file.
    Added Gun clas which acts as a bullet factory.
    Enemies have randomized guns (three variants, straight shot, shot in player direction, and triple shot)
    change damage to be on entity instead of bullet in order to do ship-to-ship collision damage.
    Modified PlayState to use state variable to change render and input mechanics.
  2. @frekfra

    Delete #Player.java#

    frekfra authored
    unintended commit
This page is out of date. Refresh to see the latest.
View
4 GDCalaga/highscore.dat
@@ -0,0 +1,4 @@
+1000,Thomas
+40000,Eddison
+10000,George
+5000,Micheal
View
6 GDCalaga/src/org/gdc/gdcalaga/Bullet.java
@@ -10,7 +10,6 @@
private static final int SIZE_WIDTH = 9;
private static final int SIZE_HEIGHT = 5;
- private float damage;
private Vector2f velocity;
private Image bullet;
@@ -19,7 +18,7 @@ public Bullet(EntityManager manager, Vector2f position, int dmg, Entity.Alliance
super(manager);
pos.set(position);
size = new Vector2f(SIZE_WIDTH, SIZE_HEIGHT);
- damage = dmg;
+ collisionDamage = dmg;
velocity = new Vector2f(0, 0);
alliance = alnc;
@@ -101,9 +100,6 @@ else if(other instanceof Player)
}
}
- public float getDamage(){
- return damage;
- }
public Entity.Alliance getAlliance() {
View
19 GDCalaga/src/org/gdc/gdcalaga/Enemy.java
@@ -29,6 +29,7 @@
private Vector2f startPos, pathVelocity;
private float fireRate;
private float fireRateDT;
+ private Gun shipGun;
private Random rand;
private EnemyGroup group;
@@ -37,6 +38,9 @@
protected AudioManager audioManager;
+ protected static Player player;
+
+
public Enemy(EntityManager manager, Vector2f position)
{
super(manager);
@@ -58,13 +62,18 @@ public Enemy(EntityManager manager, Vector2f position)
rand = new Random(System.currentTimeMillis());
fireRate = rand.nextInt(MAX_FIRE);
fireRateDT = 0;
-
+
try {
ship = new Image("Pics/Enemy.png");
} catch (SlickException e) {
e.printStackTrace();
}
+ Gun.GunType gunType = Gun.GunType.values()[rand.nextInt(Gun.MAX_GUN_TYPES)];
+ shipGun = new Gun(entities, 250, alliance, gunType);
+
+
+
audioManager = AudioManager.getAudioManager();
}
@@ -146,17 +155,15 @@ public void Collide(Entity other)
{
if(other instanceof Bullet && ((Bullet)other).getAlliance()!=alliance)
{
- Hurt(((Bullet)other).getDamage());
+ Hurt(((Entity)other).getCollisionDamage());
}
}
public void fire()
{
- Vector2f bulletPosition = new Vector2f((pos.x - size.x / 2) + 3, pos.y);
- Bullet newBullet = new Bullet(entities, bulletPosition, 1, alliance);
- newBullet.setSpeed(-250, 0);
- //audioManager.playSFX(AudioAsset.SFX_FIRE2);
+ Vector2f bulletPosition = new Vector2f((pos.x - size.x / 2) + 3, pos.y);
+ shipGun.shoot(bulletPosition, player);
}
View
9 GDCalaga/src/org/gdc/gdcalaga/Entity.java
@@ -24,6 +24,7 @@
protected Shape shape;
+ protected float collisionDamage;
public Entity(EntityManager manager)
{
@@ -33,11 +34,14 @@ public Entity(EntityManager manager)
dying = false;
alliance = Alliance.ENEMY;
pos = new Vector2f(0, 0);
+
+ collisionDamage = 1;
}
public Entity(int xpos, int ypos)
{
pos = new Vector2f(xpos, ypos);
+ collisionDamage = 1;
}
public Entity(int xpos, int ypos, float w, float h)
@@ -46,6 +50,7 @@ public Entity(int xpos, int ypos, float w, float h)
pos = new Vector2f(xpos, ypos);
size = new Vector2f(w, h);
+ collisionDamage = 1;
}
public Entity(Vector2f position, Vector2f size)
@@ -64,6 +69,10 @@ public void Destroy()
dying = true;
}
+ public float getCollisionDamage(){
+ return collisionDamage;
+ }
+
public Entity.Alliance getAlliance()
{
return alliance;
View
6 GDCalaga/src/org/gdc/gdcalaga/GDCalaga.java
@@ -8,6 +8,10 @@
public class GDCalaga {
+ static final int SCREEN_SIZE_X = 1280;
+ static final int SCREEN_SIZE_Y = 720;
+
+
static {
String path = System.getProperties().get("java.library.path").toString();
@@ -41,7 +45,7 @@ else if (os.indexOf("linux") >= 0) {
public static void main(String[] argv) {
try {
AppGameContainer container = new AppGameContainer(new GDCalagaGame());
- container.setDisplayMode(1280, 720, false);
+ container.setDisplayMode(SCREEN_SIZE_X, SCREEN_SIZE_Y, false);
container.start();
} catch (SlickException e) {
e.printStackTrace();
View
81 GDCalaga/src/org/gdc/gdcalaga/Gun.java
@@ -0,0 +1,81 @@
+package org.gdc.gdcalaga;
+
+import org.newdawn.slick.geom.Vector2f;
+
+
+public class Gun {
+
+ public static int MAX_GUN_TYPES = 3; //fixme use enum max value correctly.
+
+
+ enum GunType {
+ StraightShot,
+ AimedShot,
+ TripleShot,
+ }
+
+ protected float velocity;
+ protected GunType gunType;
+ protected EntityManager entityManager;
+ protected Entity.Alliance alliance;
+
+ public Gun(EntityManager entityManager, float velocity, Entity.Alliance alliance, GunType gunType)
+ {
+ this.entityManager = entityManager;
+ this.velocity = velocity;
+ this.alliance = alliance;
+ this.gunType = gunType;
+
+ }
+
+ public void shoot(Vector2f bulletPosition, Player player)
+ {
+ switch(gunType)
+ {
+ case StraightShot:
+ straightShot(bulletPosition);
+ break;
+ case AimedShot:
+ aimedShot(bulletPosition, player);
+ break;
+ case TripleShot:
+ tripleShot(bulletPosition);
+ break;
+ default:
+ break;
+ }
+ }
+
+ private void straightShot(Vector2f bulletPosition) {
+ Bullet newBullet = new Bullet(entityManager, bulletPosition, 1, alliance);
+ newBullet.setSpeed(-250, 0);
+ }
+
+ private void aimedShot(Vector2f bulletPosition, Player player) {
+
+ Bullet newBullet = new Bullet(entityManager, bulletPosition, 1, alliance);
+
+ Vector2f directionOfPlayer = new Vector2f(player.getPosition());
+ directionOfPlayer.x -= bulletPosition.x;
+ directionOfPlayer.y += (-bulletPosition.y) + (Math.random() * 20) - 10;
+ directionOfPlayer.normalise();
+
+ newBullet.setSpeed(directionOfPlayer.x * 250,directionOfPlayer.y * 250);
+ }
+
+ private void tripleShot(Vector2f bulletPosition){
+
+ Bullet diagonalUpBullet = new Bullet(entityManager, bulletPosition, 1, alliance);
+ Vector2f diagonalUp = new Vector2f(-2,1);
+ diagonalUp.normalise();
+ diagonalUpBullet.setSpeed(diagonalUp.x * velocity, diagonalUp.y * velocity);
+
+ straightShot(bulletPosition);
+
+ Vector2f diagonalDown = new Vector2f(-2,-1);
+ diagonalDown.normalise();
+ Bullet diagonalDownBullet = new Bullet(entityManager, bulletPosition, 1, alliance);
+
+ diagonalDownBullet.setSpeed(diagonalDown.x * velocity, diagonalDown.y * velocity);
+ }
+}
View
2  GDCalaga/src/org/gdc/gdcalaga/GunPositions.java
@@ -20,7 +20,7 @@
public GunPositions(float width, float height)
{
- playerWidth = width;
+ playerWidth = width;
playerHeight = height;
positions = new ArrayList<Vector2f>();
View
142 GDCalaga/src/org/gdc/gdcalaga/HighscoreList.java
@@ -0,0 +1,142 @@
+package org.gdc.gdcalaga;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.newdawn.slick.Graphics;
+
+public class HighscoreList {
+ private int centerX;
+ private int centerY;
+ private final int lineSpacing = 15;
+ private final int maxScoreLength = 9;
+
+
+ List<Highscore> scores = new ArrayList<Highscore>();
+
+
+ public HighscoreList(int screenSizeX, int screenSizeY)
+ {
+ this.centerX = screenSizeX / 2;
+ this.centerY = screenSizeY / 2;
+ }
+
+
+ public void render(Graphics g) {
+ drawHighscoreList(g);
+ }
+
+
+ private void drawHighscoreList(Graphics g) {
+ for(int i = 0; i < getHighscoreList().size(); ++i)
+ {
+ String number = String.valueOf(getHighscoreList().get(i).getScore());
+ number = String.format("%1$" + maxScoreLength + "s", number);
+ String score = (i+1) + ": " + number + " - " + getHighscoreList().get(i).getName();
+
+ g.drawString(score,
+ centerX - (maxScoreLength * 10),
+ centerY + (lineSpacing * i));
+ }
+ }
+
+
+ private List<Highscore> getHighscoreList() {
+ //if the scores list is empty read highscores from file.
+ if(scores.size() == 0)
+ {
+ try {
+ String current = new java.io.File( "." ).getCanonicalPath();
+ System.out.println("Current dir:"+current);
+
+ BufferedReader in = new BufferedReader(new FileReader("highscore.dat"));
+
+ String line;
+ while ((line = in.readLine()) != null) {
+
+ String[] split = line.split(",");
+ scores.add(new Highscore(Integer.parseInt(split[0]), split[1]));
+ }
+ in.close();
+
+ } catch (FileNotFoundException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (NumberFormatException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ Collections.sort(scores,Collections.reverseOrder());
+ }
+
+ return scores;
+ }
+
+ public void addHighscore(int score, String name) {
+
+ scores.add(new Highscore(score,name));
+ Collections.sort(scores,Collections.reverseOrder());
+ }
+
+ public void saveHighscore()
+ {
+ try {
+ String current = new java.io.File( "." ).getCanonicalPath();
+ System.out.println("Current dir:"+current);
+
+ BufferedWriter out = new BufferedWriter(new FileWriter("highscore.dat"));
+
+ for(int i = 0; i < scores.size(); ++i)
+ {
+ out.write( scores.get(i).getScore() + "," + scores.get(i).getName() + "\n");
+ }
+
+ out.close();
+
+ } catch (FileNotFoundException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+
+ private class Highscore implements Comparable<Highscore> {
+
+ private int score;
+ private String name;
+
+ public Highscore(int score, String name) {
+ this.score = score;
+ this.name = name;
+ }
+
+ public int getScore() { return score; }
+ public String getName() { return name; }
+
+ @Override
+ public int compareTo(Highscore arg0) {
+ Highscore otherHighScore = (Highscore)arg0;
+ if(score > otherHighScore.getScore())
+ return 1;
+ else if (score < otherHighScore.getScore())
+ return -1;
+
+ return 0;
+ }
+ }
+
+}
View
75 GDCalaga/src/org/gdc/gdcalaga/Menu.java
@@ -0,0 +1,75 @@
+package org.gdc.gdcalaga;
+import org.newdawn.slick.Graphics;
+
+public class Menu {
+
+ public enum Selection
+ {
+ NewGame,
+ ViewHighScore,
+ ExitGame
+ }
+
+ private Selection currentSelection = Selection.NewGame;
+
+ private final int centerX;
+ private final int centerY;
+ private final int lineSpacing = 15;
+
+ //menu is a singleton.
+ public Menu(int screenSizeX, int screenSizeY) {
+ centerX = screenSizeX / 2;
+ centerY = screenSizeY / 2;
+ }
+
+
+ public void MoveSelectionUp() {
+ int selectionInt = currentSelection.ordinal();
+ currentSelection = Selection.values()[Math.max(0, selectionInt - 1)];
+ }
+
+ public void MoveSelectionDown() {
+ int selectionInt = currentSelection.ordinal();
+ currentSelection = Selection.values()[Math.min(Selection.ExitGame.ordinal(), selectionInt + 1)];
+ }
+
+ public Selection selectOption() {
+ return currentSelection;
+ }
+
+ public void render(Graphics g) {
+
+ drawSelector(g);
+ drawMenu(g);
+
+ }
+
+ private void drawSelector(Graphics g) {
+
+ int selectionInt = currentSelection.ordinal();
+ int selectionStringlength = (Selection.values()[selectionInt].name().length() * 5);
+ int selectorLength = 20;
+
+
+
+ g.drawString(">>",
+ centerX - (selectorLength + selectionStringlength),
+ centerY + (lineSpacing * selectionInt) );
+
+ g.drawString("<<",
+ centerX + selectionStringlength - 10,
+ centerY + (lineSpacing * selectionInt) );
+ }
+
+ private void drawMenu(Graphics g) {
+
+ for(int i = 0; i < Selection.values().length; ++i)
+ {
+ g.drawString(Selection.values()[i].name(),
+ centerX - (Selection.values()[i].name().length() * 5),
+ centerY + (lineSpacing * i));
+ }
+ }
+
+
+}
View
283 GDCalaga/src/org/gdc/gdcalaga/PlayState.java
@@ -1,6 +1,7 @@
package org.gdc.gdcalaga;
import java.util.LinkedList;
import java.util.List;
+
import org.gdc.gdcalaga.audio.AudioAsset;
import org.gdc.gdcalaga.audio.AudioManager;
import org.newdawn.slick.GameContainer;
@@ -11,16 +12,35 @@
import org.newdawn.slick.state.StateBasedGame;
import org.newdawn.slick.geom.Vector2f;
+
public class PlayState extends BasicGameState {
- public static final int ID = 0;
- private boolean paused = false;
+ private enum State {
+ Playing,
+ Pause,
+ MainMenu,
+ Highscore,
+ PostGame,
+ }
+
+ public static final int ID = 0;
private Player player;
+ final int menuKeyDelay = 250;
+ int menuKeyDelayCounter = 250;
+
+ private State state = State.MainMenu;
+ boolean gameInProgress = false;
+
+ private String playerName = "Player1"; //storing player entered name;
+
private EntityManager entities = new EntityManager();
private Input input;
private AudioManager audioManager = AudioManager.getAudioManager();
+ private HighscoreList highscoreList = new HighscoreList(GDCalaga.SCREEN_SIZE_X,GDCalaga.SCREEN_SIZE_Y);
+ private Menu mainMenu = new Menu(GDCalaga.SCREEN_SIZE_X,GDCalaga.SCREEN_SIZE_Y);
+
private List<DisplayObject> disObjs = new LinkedList<DisplayObject>();
@@ -31,6 +51,7 @@ public void init(GameContainer container, StateBasedGame game) throws SlickExcep
input = container.getInput();
Vector2f startPosition = new Vector2f(50, 300);
player= new Player(entities, startPosition);
+ Enemy.player = player;
audioManager.loadAudioAssets();
audioManager.playMusic(AudioAsset.MUSIC_LEVEL_1);
@@ -46,8 +67,91 @@ public void render(GameContainer container, StateBasedGame game, Graphics g) thr
for (DisplayObject obj : disObjs) {
obj.draw(g);
}
+
entities.draw(g);
+ switch(state)
+ {
+ case Playing:
+ break;
+ case Pause:
+ break;
+ case MainMenu:
+ mainMenu.render(g);
+ break;
+ case Highscore:
+ highscoreList.render(g);
+ break;
+ case PostGame:
+ renderPostGame(g);
+ break;
+ }
+
+
+ renderDebugText(g);
+ }
+
+
+ @Override
+ public void update(GameContainer container, StateBasedGame game, int delta) throws SlickException {
+
+ switch(state)
+ {
+ case Playing:
+ updateGame(delta);
+ break;
+ case Pause:
+ break;
+ case MainMenu:
+ menuInput(delta);
+ break;
+ case Highscore:
+ break;
+ case PostGame:
+ postGameInput();
+ break;
+ }
+
+
+ if(input.isKeyPressed(Input.KEY_ESCAPE))
+ {
+ changeState(State.MainMenu);
+ }
+
+ /* will put this back in later
+ if(Input.WasKeyPressed(KeyEvent.VK_H))
+ {
+ screenShot();
+ }
+ */
+ }
+
+ private void updateGame(int delta) {
+ Collision.checkCollisions(entities.getEntities());
+
+ Spawn.spawnWave(paths, entities);
+ entities.update(delta);
+
+ if( ( Math.random()*100) < .1 )
+ {
+ ((Background)disObjs.get(0)).addRandomFloater();
+ }
+
+ shipInput(delta);
+
+ for (DisplayObject obj : disObjs) {
+ obj.update(delta);
+ }
+
+ if(player.IsDying())
+ {
+ gameInProgress = false;
+ changeState(State.PostGame);
+ }
+ }
+
+
+ private void renderDebugText(Graphics g) {
/* If we use this same monospace font, each letter takes up 10 pixels
* so we can space the text according to this metric
*/
@@ -69,77 +173,128 @@ public void render(GameContainer container, StateBasedGame game, Graphics g) thr
xPixel += (waveCount.length() * 10) + desiredSpacing;
g.drawString(pointCount, xPixel, 30);
}
-
- @Override
- public void update(GameContainer container, StateBasedGame game, int delta) throws SlickException {
+
+
+ private void renderPostGame(Graphics g) {
+ String gameOverText = new String("GAME OVER");
+ int screenCenterX = GDCalaga.SCREEN_SIZE_X / 2;
+ int screenCenterY = GDCalaga.SCREEN_SIZE_Y / 2;
+ g.drawString(gameOverText, screenCenterX - (gameOverText.length() * 5), screenCenterY);
+
+ String highscoreText = new String("Highscore: " + Player.getTotalPoints());
+ int xPixel = screenCenterX - (highscoreText.length() * 5);
+ int yPixel = screenCenterY + 15;
+ g.drawString(highscoreText, xPixel, yPixel);
+
+ String enterNameText = new String("Enter your name: ");
+ xPixel = screenCenterX - ((enterNameText.length() + 5) * 5);
+ yPixel = screenCenterY + 50;
+ g.drawString(enterNameText + playerName, xPixel, yPixel);
+ }
+
+
+ private void postGameInput() {
- if(!paused){
-
- Collision.checkCollisions(entities.getEntities());
-
- Spawn.spawnWave(paths, entities);
-
- entities.update(delta);
-
- if( ( Math.random()*100) < .1 )
- {
- ((Background)disObjs.get(0)).addRandomFloater();
- }
-
- if(input.isKeyDown(Input.KEY_W)){
- player.moveUp(delta);
- }
- if(input.isKeyDown(Input.KEY_S)){
- player.moveDown(delta);
- }
- if(input.isKeyDown(Input.KEY_A)){
- player.moveLeft(delta);
- }
- if(input.isKeyDown(Input.KEY_D)){
- player.moveRight(delta);
- }
-
- if(input.isKeyDown(Input.KEY_SPACE))
- {
- if (player.fire(delta))
- {
- audioManager.playSFX(AudioAsset.SFX_FIRE1);
- }
- }
-
- if(input.isKeyDown(Input.KEY_Q))
- {
- if (player.activateShield(delta))
- {
- //audioManager.playSFX(AudioAsset.SFX_SHIELD1);
- //should we play a sound, or just show a graphic?
- }
- }
- else
- {
- player.deactivateShield();
- }
-
- for (DisplayObject obj : disObjs) {
- obj.update(delta);
- }
+ if(input.isKeyDown(Input.KEY_ENTER))
+ {
+ highscoreList.addHighscore(Player.getTotalPoints(), playerName);
+ changeState(State.MainMenu);
}
-
- if(input.isKeyPressed(Input.KEY_ESCAPE))
- {
- paused=!paused;
- }
+ }
- /* will put this back in later
- if(Input.WasKeyPressed(KeyEvent.VK_H))
+
+ private void shipInput(int delta) {
+
+ if(input.isKeyDown(Input.KEY_W)){
+ player.moveUp(delta);
+ }
+ if(input.isKeyDown(Input.KEY_S)){
+ player.moveDown(delta);
+ }
+ if(input.isKeyDown(Input.KEY_A)){
+ player.moveLeft(delta);
+ }
+ if(input.isKeyDown(Input.KEY_D)){
+ player.moveRight(delta);
+ }
+ if(input.isKeyDown(Input.KEY_SPACE))
+ {
+ if (player.fire(delta))
+ {
+ audioManager.playSFX(AudioAsset.SFX_FIRE1);
+ }
+ }
+
+ if(input.isKeyDown(Input.KEY_Q))
+ {
+ if (player.activateShield(delta))
+ {
+ //audioManager.playSFX(AudioAsset.SFX_SHIELD1);
+ //should we play a sound, or just show a graphic?
+ }
+ }
+ else
+ {
+ player.deactivateShield();
+ }
+ }
+
+
+ private void menuInput(int delta) {
+
+ menuKeyDelayCounter -= delta;
+ if(menuKeyDelayCounter > 0)
+ return;
+ if(input.isKeyDown(Input.KEY_W))
+ {
+ mainMenu.MoveSelectionUp();
+ menuKeyDelayCounter = menuKeyDelay;
+ }
+ if(input.isKeyDown(Input.KEY_S))
+ {
+ mainMenu.MoveSelectionDown();
+ menuKeyDelayCounter = menuKeyDelay;
+ }
+ if(input.isKeyDown(Input.KEY_ENTER))
+ {
+ Menu.Selection selection = mainMenu.selectOption();
+ switch(selection)
+ {
+ case NewGame:
+ startNewGame();
+ break;
+ case ViewHighScore:
+ changeState(State.Highscore);
+ break;
+ case ExitGame:
+ CloseGame();
+ break;
+ }
+ menuKeyDelayCounter = menuKeyDelay;
+ }
+ if(input.isKeyPressed(Input.KEY_ESCAPE))
{
- screenShot();
+ if(gameInProgress)
+ changeState(State.Playing);
}
- */
}
+ private void startNewGame() {
+ gameInProgress = true;
+ changeState(State.Playing); //fixme reinitialize game.
+ }
+
+ private void changeState(State newState) {
+ state = newState;
+ }
+
+ private void CloseGame() {
+ highscoreList.saveHighscore();
+ System.exit(0);
+ }
+
@Override
public int getID() {
return ID;
View
17 GDCalaga/src/org/gdc/gdcalaga/Player.java
@@ -169,9 +169,10 @@ public void deactivateShield()
public void Collide(Entity other)
{
- if(other instanceof Bullet && ((Bullet)other).getAlliance() != alliance)
+ if(other instanceof Bullet && ((Bullet)other).getAlliance() != alliance
+ || other instanceof Enemy)
{
- Hurt(((Bullet)other).getDamage());
+ Hurt(((Entity)other).getCollisionDamage());
}
}
@@ -181,6 +182,11 @@ public void Hurt(float dmg)
return;
health -= dmg;
+
+ if(health <= 0)
+ {
+ Destroy();
+ }
}
public float getHealth()
@@ -198,6 +204,11 @@ public float getShields()
return alliance;
}
+ public Vector2f getPosition()
+ {
+ return pos;
+ }
+
public static int getTotalPoints()
{
return totalPoints;
@@ -218,7 +229,7 @@ public static void decreaseTotalPoints(int pointValue)
public static void upgrade(Upgrade.UpgradeType upgrade)
{
- //TODO Change the health, hp/armor, fire rate, amount of guns, speed
+ //TODO Change the ealth, hp/armor, fire rate, amount of guns, speed
//according to the upgrade passed in
switch (upgrade)
{
Something went wrong with that request. Please try again.