Asdded a build menu to the hud and fixed some color isues with the new ProgressBar class
This commit is contained in:
parent
d1a2aa8b4e
commit
2cf489403d
10 changed files with 593 additions and 1168 deletions
BIN
src/data/hud/buildmenu.png
Normal file
BIN
src/data/hud/buildmenu.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.6 KiB |
|
|
@ -52,7 +52,7 @@ public class BitmapText extends Entity{
|
|||
* Render the text
|
||||
*/
|
||||
public void render(){
|
||||
if(text != null && !text.isEmpty()){
|
||||
if(text != null && !text.equals("")){
|
||||
// store the current model matrix
|
||||
GL11.glPushMatrix();
|
||||
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ public class Particles extends Entity{
|
|||
private void init() {
|
||||
for (int i=0;i<maxParticles;i++){ // Initials All The Textures
|
||||
particle[i].active = true; // Make All The Particles Active
|
||||
particle[i].life = life; // Give All The Particles Full Life
|
||||
particle[i].life = (float) (Math.random()*(life+0.7f)); // Give All The Particles Full Life
|
||||
particle[i].fade = ((float)(Math.random() * 100.0)) / 1000.0f + 0.003f; // Random Fade Speed
|
||||
particle[i].r = colors[i * (colors.length / maxParticles)][0][0]; // Select Red Rainbow Color
|
||||
particle[i].g = colors[i * (colors.length / maxParticles)][0][1]; // Select Red Rainbow Color
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ public class ProgressBar{
|
|||
private int max;
|
||||
private float width;
|
||||
private float height;
|
||||
private Vector4f[] valueColor = new Vector4f[100];
|
||||
|
||||
/**
|
||||
* Creates a selection box with health bar
|
||||
|
|
@ -48,6 +49,13 @@ public class ProgressBar{
|
|||
bar.getTexture().setColor(c);
|
||||
}
|
||||
|
||||
public void setValueColor(int procent, Vector4f c){
|
||||
procent--;
|
||||
if(procent >= 0 && procent <= 99){
|
||||
valueColor[procent] = c;
|
||||
}
|
||||
}
|
||||
|
||||
public Node getNode(){
|
||||
return progressNode;
|
||||
}
|
||||
|
|
@ -61,14 +69,13 @@ public class ProgressBar{
|
|||
value.setSize(new Vector2f(((float)v/max)*width,height));//(v/max)*width
|
||||
value.setLocation(new Vector2f(-width/2+(((float)v/max)*width)/2,0));
|
||||
|
||||
if(((float)v/max) < 0.15f){
|
||||
value.getTexture().setColor(new Vector4f(1.0f, 0f, 0f, 0.6f));
|
||||
}
|
||||
else if(((float)v/max) < 0.50f){
|
||||
value.getTexture().setColor(new Vector4f(1.0f, .95f, 0, 0.6f));
|
||||
}
|
||||
else{
|
||||
value.getTexture().setColor(new Vector4f(0.3f, 1.0f, 0.3f, 0.6f));
|
||||
System.out.println("lol"+((float)v/max));
|
||||
for(int i=0; i<valueColor.length ;i++){
|
||||
if(valueColor[i] != null && ((float)v/max) < (float)i/100){
|
||||
System.out.println("lol"+((float)v/max));
|
||||
value.getTexture().setColor(valueColor[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ import ei.game.input.InGameMouseInput;
|
|||
import ei.game.player.HumanPlayer;
|
||||
import ei.game.player.PlayerHandler;
|
||||
import ei.game.scene.Map;
|
||||
import ei.game.scene.buildings.CommandCenter;
|
||||
import ei.game.scene.units.APU;
|
||||
import ei.game.scene.units.Bomber;
|
||||
import ei.game.scene.units.Tank;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,9 @@ package ei.game.hud;
|
|||
|
||||
import ei.engine.LWJGLGameWindow;
|
||||
import ei.engine.effects.BitmapText;
|
||||
import ei.engine.effects.ProgressBar;
|
||||
import ei.engine.math.Vector2f;
|
||||
import ei.engine.math.Vector4f;
|
||||
import ei.engine.scene.Node;
|
||||
import ei.engine.scene.Sprite;
|
||||
import ei.game.player.Player;
|
||||
|
|
@ -11,6 +13,7 @@ public class InGameHud {
|
|||
private Node hudNode;
|
||||
private BitmapText money;
|
||||
private Player player;
|
||||
private ProgressBar buildBar;
|
||||
|
||||
public InGameHud(Player p){
|
||||
player = p;
|
||||
|
|
@ -26,6 +29,20 @@ public class InGameHud {
|
|||
money = new BitmapText("MoneyMeter");
|
||||
money.setLocation(new Vector2f(LWJGLGameWindow.getWidth()-money.getBound().width,5));
|
||||
hudNode.add(money);
|
||||
|
||||
Sprite buildBack = new Sprite("BuildBackground","data/hud/buildmenu.png");
|
||||
buildBack.setLocation(new Vector2f(
|
||||
LWJGLGameWindow.getWidth()/2,
|
||||
LWJGLGameWindow.getHeight()-buildBack.getSize().getY()/2));
|
||||
hudNode.add(buildBack);
|
||||
|
||||
buildBar = new ProgressBar("BuildProgressBar",350,5,100);
|
||||
buildBar.setBarColor(new Vector4f(0.41f, 0.41f, 0.41f, 1f));
|
||||
buildBar.setValueColor(100, new Vector4f(0.21f, 0.7f, 0.44f, 1f));
|
||||
buildBar.getNode().setLocation(new Vector2f(
|
||||
LWJGLGameWindow.getWidth()/2+50,
|
||||
LWJGLGameWindow.getHeight()-55));
|
||||
hudNode.add(buildBar.getNode());
|
||||
}
|
||||
|
||||
public void update(){
|
||||
|
|
|
|||
|
|
@ -1,13 +1,8 @@
|
|||
package ei.game.scene;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
|
||||
import ei.engine.math.Vector2f;
|
||||
|
|
@ -15,7 +10,6 @@ import ei.engine.math.Vector2i;
|
|||
import ei.engine.math.Vector3f;
|
||||
import ei.engine.scene.Node;
|
||||
import ei.engine.scene.Sprite;
|
||||
import ei.engine.texture.TextureLoader;
|
||||
import ei.engine.util.MultiPrintStream;
|
||||
import ei.game.player.GaiaPlayer;
|
||||
import ei.game.player.Player;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ import ei.engine.math.Vector2f;
|
|||
import ei.engine.math.Vector4f;
|
||||
import ei.engine.scene.Box;
|
||||
import ei.engine.scene.Node;
|
||||
import ei.engine.scene.Sprite;
|
||||
import ei.engine.texture.Texture;
|
||||
|
||||
public class SelectBox {
|
||||
|
|
@ -30,6 +29,9 @@ public class SelectBox {
|
|||
|
||||
bar = new ProgressBar("Health",x,height,max);
|
||||
bar.getNode().setLocation(new Vector2f(0,-x/2+height/2));
|
||||
bar.setValueColor(25, new Vector4f(1.0f, 0f, 0f, 1f));
|
||||
bar.setValueColor(50, new Vector4f(1.0f, .95f, 0, 1f));
|
||||
bar.setValueColor(100, new Vector4f(0.3f, 1.0f, 0.3f, 1f));
|
||||
selectNode.add(bar.getNode());
|
||||
mouseOverNode.add(bar.getNode());
|
||||
|
||||
|
|
|
|||
|
|
@ -1,26 +1,19 @@
|
|||
package ei.game.scene.buildings;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Queue;
|
||||
|
||||
import ei.engine.math.Vector2f;
|
||||
import ei.engine.math.Vector2i;
|
||||
import ei.engine.math.Vector3f;
|
||||
import ei.engine.scene.Node;
|
||||
import ei.game.algo.AStar;
|
||||
import ei.game.algo.AStarNode;
|
||||
import ei.game.gamestate.InGameState;
|
||||
import ei.game.player.Player;
|
||||
import ei.game.scene.GameEntity;
|
||||
import ei.game.scene.Map;
|
||||
import ei.game.scene.units.Unit;
|
||||
import ei.game.scene.weapons.Weapon;
|
||||
import ei.game.scene.weapons.WeaponHandler;
|
||||
|
||||
public abstract class Building extends GameEntity{
|
||||
private ArrayList<Unit> availableUnits;
|
||||
private Queue<Unit> buildQueue;
|
||||
private int buildTime;
|
||||
private Node unitNode;
|
||||
private Vector2i oldPos;
|
||||
private int size;
|
||||
|
|
@ -29,6 +22,7 @@ public abstract class Building extends GameEntity{
|
|||
public Building(int l, Vector2i pos, Player p, int size) {
|
||||
super(l, p);
|
||||
this.size = size;
|
||||
buildQueue = new LinkedList<Unit>();
|
||||
unitNode = new Node("UnitNode");
|
||||
unitNode.setLocation(Map.getPixelByPos(pos.getX(), pos.getY(), this.size));
|
||||
System.out.println("location: "+unitNode.getLocation());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue