Added a hud for the money

This commit is contained in:
Ziver Koc 2007-04-23 19:33:27 +00:00
parent 287e6b3e50
commit d1a2aa8b4e
13 changed files with 34 additions and 12 deletions

BIN
src/data/hud/money.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -36,12 +36,10 @@ public class ProgressBar{
value = new Sprite(name+"_Value",tex2); value = new Sprite(name+"_Value",tex2);
value.setSize(new Vector2f(width,height)); value.setSize(new Vector2f(width,height));
value.setLocation(new Vector2f(0,-50));
progressNode.add(value); progressNode.add(value);
bar = new Box(name+"_Bar",tex); bar = new Box(name+"_Bar",tex);
bar.setSize(new Vector2f(width,height)); bar.setSize(new Vector2f(width,height));
bar.setLocation(new Vector2f());
progressNode.add(bar); progressNode.add(bar);
} }

View file

@ -41,7 +41,7 @@ public class InGameState extends GameState{
player.addUnit(new Bomber(7, 0, player)); player.addUnit(new Bomber(7, 0, player));
player.addUnit(new APU(4, 0, player)); player.addUnit(new APU(4, 0, player));
player.addUnit(new APU(5, 0, player)); player.addUnit(new APU(5, 0, player));
player.addUnit(new CommandCenter(10, 10, player)); //player.addUnit(new CommandCenter(10, 10, player));
PlayerHandler.getInstance().addPlayer(player); PlayerHandler.getInstance().addPlayer(player);

View file

@ -4,6 +4,7 @@ import ei.engine.LWJGLGameWindow;
import ei.engine.effects.BitmapText; import ei.engine.effects.BitmapText;
import ei.engine.math.Vector2f; import ei.engine.math.Vector2f;
import ei.engine.scene.Node; import ei.engine.scene.Node;
import ei.engine.scene.Sprite;
import ei.game.player.Player; import ei.game.player.Player;
public class InGameHud { public class InGameHud {
@ -16,14 +17,20 @@ public class InGameHud {
hudNode = new Node("Hud"); hudNode = new Node("Hud");
Sprite moneyBack = new Sprite("MoneyBackground","data/hud/money.png");
moneyBack.setLocation(new Vector2f(
LWJGLGameWindow.getWidth()-moneyBack.getSize().getX()/2,
moneyBack.getSize().getY()/2));
hudNode.add(moneyBack);
money = new BitmapText("MoneyMeter"); money = new BitmapText("MoneyMeter");
money.setLocation(new Vector2f(LWJGLGameWindow.getWidth()-money.getBound().width,0)); money.setLocation(new Vector2f(LWJGLGameWindow.getWidth()-money.getBound().width,5));
hudNode.add(money); hudNode.add(money);
} }
public void update(){ public void update(){
money.setText(""+player.getKredits()); money.setText(""+player.getKredits());
money.setLocation(new Vector2f(LWJGLGameWindow.getWidth()-money.getBound().width,0)); money.setLocation(new Vector2f(LWJGLGameWindow.getWidth()-money.getBound().width,5));
player.addKredits(100); player.addKredits(100);

View file

@ -9,6 +9,7 @@ public class HumanPlayer extends Player{
public HumanPlayer(){ public HumanPlayer(){
super(); super();
cc = new CommandCenter(10,10,this); cc = new CommandCenter(10,10,this);
addUnit(cc);
} }
public Building getCC() { public Building getCC() {

View file

@ -9,12 +9,10 @@ import ei.engine.scene.Sprite;
import ei.engine.texture.Texture; import ei.engine.texture.Texture;
public class SelectBox { public class SelectBox {
private static final float height = 3;
private Node selectNode; private Node selectNode;
private Node mouseOverNode; private Node mouseOverNode;
private ProgressBar bar; private ProgressBar bar;
private int max;
private float width;
private static final float height = 3;
/** /**
* Creates a selection box with health bar * Creates a selection box with health bar
@ -24,15 +22,13 @@ public class SelectBox {
* @param max The max health of the object * @param max The max health of the object
*/ */
public SelectBox(float x, float y, int max){ public SelectBox(float x, float y, int max){
this.max = max;
this.width = x;
selectNode = new Node("SelectionNode"); selectNode = new Node("SelectionNode");
mouseOverNode = new Node("MouseOverNode"); mouseOverNode = new Node("MouseOverNode");
Texture tex = new Texture(); Texture tex = new Texture();
tex.setColor(new Vector4f(0.5f, 1.0f, 0.5f,1)); tex.setColor(new Vector4f(0.5f, 1.0f, 0.5f,1));
bar = new ProgressBar("Health",width,height,max); bar = new ProgressBar("Health",x,height,max);
bar.getNode().setLocation(new Vector2f(0,-x/2+height/2)); bar.getNode().setLocation(new Vector2f(0,-x/2+height/2));
selectNode.add(bar.getNode()); selectNode.add(bar.getNode());
mouseOverNode.add(bar.getNode()); mouseOverNode.add(bar.getNode());

View file

@ -27,12 +27,19 @@ public class APU extends Unit{
this.sprite = new Sprite("APU", "data/units/apu/apu0000.png"); this.sprite = new Sprite("APU", "data/units/apu/apu0000.png");
sprite.setSize(new Vector2f(40,40)); sprite.setSize(new Vector2f(40,40));
getNode().add(sprite); getNode().add(sprite);
gunSound = new Sound("gunSound", "data/sounds/machinegun.wav"); gunSound = new Sound("gunSound", "data/sounds/machinegun.wav");
moveSound[0] = new Sound("moveSound", "data/sounds/APUmove1.wav"); moveSound[0] = new Sound("moveSound", "data/sounds/APUmove1.wav");
moveSound[1] = new Sound("moveSound", "data/sounds/APUmove2.wav"); moveSound[1] = new Sound("moveSound", "data/sounds/APUmove2.wav");
selectSound = new Sound("selectSound", "data/sounds/APUselect.wav"); selectSound = new Sound("selectSound", "data/sounds/APUselect.wav");
attackSound = new Sound("attackSound", "data/sounds/APUattack.wav"); attackSound = new Sound("attackSound", "data/sounds/APUattack.wav");
gunSound.setLocation(getNode().getLocation());
moveSound[0].setLocation(getNode().getLocation());
moveSound[1].setLocation(getNode().getLocation());
selectSound.setLocation(getNode().getLocation());
attackSound.setLocation(getNode().getLocation());
selectionBox = new SelectBox(40,40,getMaxLife()); selectionBox = new SelectBox(40,40,getMaxLife());
} }

View file

@ -27,12 +27,19 @@ public class Bomber extends Unit{
this.sprite = new Sprite("Bomber", "data/units/bomber/bomber0000.png"); this.sprite = new Sprite("Bomber", "data/units/bomber/bomber0000.png");
sprite.setSize(new Vector2f(50,60)); sprite.setSize(new Vector2f(50,60));
getNode().add(sprite); getNode().add(sprite);
gunSound = new Sound("gunSound", "data/sounds/bomberweapon.wav"); gunSound = new Sound("gunSound", "data/sounds/bomberweapon.wav");
moveSound[0] = new Sound("moveSound", "data/sounds/BOMBERmove1.wav"); moveSound[0] = new Sound("moveSound", "data/sounds/BOMBERmove1.wav");
moveSound[1] = new Sound("moveSound", "data/sounds/BOMBERmove2.wav"); moveSound[1] = new Sound("moveSound", "data/sounds/BOMBERmove2.wav");
selectSound = new Sound("selectSound", "data/sounds/BOMBERselect.wav"); selectSound = new Sound("selectSound", "data/sounds/BOMBERselect.wav");
attackSound = new Sound("attackSound", "data/sounds/BOMBERattack.wav"); attackSound = new Sound("attackSound", "data/sounds/BOMBERattack.wav");
gunSound.setLocation(getNode().getLocation());
moveSound[0].setLocation(getNode().getLocation());
moveSound[1].setLocation(getNode().getLocation());
selectSound.setLocation(getNode().getLocation());
attackSound.setLocation(getNode().getLocation());
selectionBox = new SelectBox(40,40,getMaxLife()); selectionBox = new SelectBox(40,40,getMaxLife());
} }

View file

@ -34,6 +34,12 @@ public class Tank extends Unit{
selectSound = new Sound("selectSound", "data/sounds/TANKselect.wav"); selectSound = new Sound("selectSound", "data/sounds/TANKselect.wav");
attackSound = new Sound("attackSound", "data/sounds/TANKattack.wav"); attackSound = new Sound("attackSound", "data/sounds/TANKattack.wav");
gunSound.setLocation(getNode().getLocation());
moveSound[0].setLocation(getNode().getLocation());
moveSound[1].setLocation(getNode().getLocation());
selectSound.setLocation(getNode().getLocation());
attackSound.setLocation(getNode().getLocation());
selectionBox = new SelectBox(40,40,getMaxLife()); selectionBox = new SelectBox(40,40,getMaxLife());
} }