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
|
* Render the text
|
||||||
*/
|
*/
|
||||||
public void render(){
|
public void render(){
|
||||||
if(text != null && !text.isEmpty()){
|
if(text != null && !text.equals("")){
|
||||||
// store the current model matrix
|
// store the current model matrix
|
||||||
GL11.glPushMatrix();
|
GL11.glPushMatrix();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -108,7 +108,7 @@ public class Particles extends Entity{
|
||||||
private void init() {
|
private void init() {
|
||||||
for (int i=0;i<maxParticles;i++){ // Initials All The Textures
|
for (int i=0;i<maxParticles;i++){ // Initials All The Textures
|
||||||
particle[i].active = true; // Make All The Particles Active
|
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].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].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
|
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 int max;
|
||||||
private float width;
|
private float width;
|
||||||
private float height;
|
private float height;
|
||||||
|
private Vector4f[] valueColor = new Vector4f[100];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a selection box with health bar
|
* Creates a selection box with health bar
|
||||||
|
|
@ -48,6 +49,13 @@ public class ProgressBar{
|
||||||
bar.getTexture().setColor(c);
|
bar.getTexture().setColor(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setValueColor(int procent, Vector4f c){
|
||||||
|
procent--;
|
||||||
|
if(procent >= 0 && procent <= 99){
|
||||||
|
valueColor[procent] = c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public Node getNode(){
|
public Node getNode(){
|
||||||
return progressNode;
|
return progressNode;
|
||||||
}
|
}
|
||||||
|
|
@ -61,14 +69,13 @@ public class ProgressBar{
|
||||||
value.setSize(new Vector2f(((float)v/max)*width,height));//(v/max)*width
|
value.setSize(new Vector2f(((float)v/max)*width,height));//(v/max)*width
|
||||||
value.setLocation(new Vector2f(-width/2+(((float)v/max)*width)/2,0));
|
value.setLocation(new Vector2f(-width/2+(((float)v/max)*width)/2,0));
|
||||||
|
|
||||||
if(((float)v/max) < 0.15f){
|
System.out.println("lol"+((float)v/max));
|
||||||
value.getTexture().setColor(new Vector4f(1.0f, 0f, 0f, 0.6f));
|
for(int i=0; i<valueColor.length ;i++){
|
||||||
}
|
if(valueColor[i] != null && ((float)v/max) < (float)i/100){
|
||||||
else if(((float)v/max) < 0.50f){
|
System.out.println("lol"+((float)v/max));
|
||||||
value.getTexture().setColor(new Vector4f(1.0f, .95f, 0, 0.6f));
|
value.getTexture().setColor(valueColor[i]);
|
||||||
}
|
break;
|
||||||
else{
|
}
|
||||||
value.getTexture().setColor(new Vector4f(0.3f, 1.0f, 0.3f, 0.6f));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@ import ei.game.input.InGameMouseInput;
|
||||||
import ei.game.player.HumanPlayer;
|
import ei.game.player.HumanPlayer;
|
||||||
import ei.game.player.PlayerHandler;
|
import ei.game.player.PlayerHandler;
|
||||||
import ei.game.scene.Map;
|
import ei.game.scene.Map;
|
||||||
import ei.game.scene.buildings.CommandCenter;
|
|
||||||
import ei.game.scene.units.APU;
|
import ei.game.scene.units.APU;
|
||||||
import ei.game.scene.units.Bomber;
|
import ei.game.scene.units.Bomber;
|
||||||
import ei.game.scene.units.Tank;
|
import ei.game.scene.units.Tank;
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,9 @@ package ei.game.hud;
|
||||||
|
|
||||||
import ei.engine.LWJGLGameWindow;
|
import ei.engine.LWJGLGameWindow;
|
||||||
import ei.engine.effects.BitmapText;
|
import ei.engine.effects.BitmapText;
|
||||||
|
import ei.engine.effects.ProgressBar;
|
||||||
import ei.engine.math.Vector2f;
|
import ei.engine.math.Vector2f;
|
||||||
|
import ei.engine.math.Vector4f;
|
||||||
import ei.engine.scene.Node;
|
import ei.engine.scene.Node;
|
||||||
import ei.engine.scene.Sprite;
|
import ei.engine.scene.Sprite;
|
||||||
import ei.game.player.Player;
|
import ei.game.player.Player;
|
||||||
|
|
@ -11,6 +13,7 @@ public class InGameHud {
|
||||||
private Node hudNode;
|
private Node hudNode;
|
||||||
private BitmapText money;
|
private BitmapText money;
|
||||||
private Player player;
|
private Player player;
|
||||||
|
private ProgressBar buildBar;
|
||||||
|
|
||||||
public InGameHud(Player p){
|
public InGameHud(Player p){
|
||||||
player = p;
|
player = p;
|
||||||
|
|
@ -26,6 +29,20 @@ public class InGameHud {
|
||||||
money = new BitmapText("MoneyMeter");
|
money = new BitmapText("MoneyMeter");
|
||||||
money.setLocation(new Vector2f(LWJGLGameWindow.getWidth()-money.getBound().width,5));
|
money.setLocation(new Vector2f(LWJGLGameWindow.getWidth()-money.getBound().width,5));
|
||||||
hudNode.add(money);
|
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(){
|
public void update(){
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,8 @@
|
||||||
package ei.game.scene;
|
package ei.game.scene;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
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.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
|
||||||
import ei.engine.math.Vector2f;
|
import ei.engine.math.Vector2f;
|
||||||
|
|
@ -15,7 +10,6 @@ import ei.engine.math.Vector2i;
|
||||||
import ei.engine.math.Vector3f;
|
import ei.engine.math.Vector3f;
|
||||||
import ei.engine.scene.Node;
|
import ei.engine.scene.Node;
|
||||||
import ei.engine.scene.Sprite;
|
import ei.engine.scene.Sprite;
|
||||||
import ei.engine.texture.TextureLoader;
|
|
||||||
import ei.engine.util.MultiPrintStream;
|
import ei.engine.util.MultiPrintStream;
|
||||||
import ei.game.player.GaiaPlayer;
|
import ei.game.player.GaiaPlayer;
|
||||||
import ei.game.player.Player;
|
import ei.game.player.Player;
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ import ei.engine.math.Vector2f;
|
||||||
import ei.engine.math.Vector4f;
|
import ei.engine.math.Vector4f;
|
||||||
import ei.engine.scene.Box;
|
import ei.engine.scene.Box;
|
||||||
import ei.engine.scene.Node;
|
import ei.engine.scene.Node;
|
||||||
import ei.engine.scene.Sprite;
|
|
||||||
import ei.engine.texture.Texture;
|
import ei.engine.texture.Texture;
|
||||||
|
|
||||||
public class SelectBox {
|
public class SelectBox {
|
||||||
|
|
@ -30,6 +29,9 @@ public class SelectBox {
|
||||||
|
|
||||||
bar = new ProgressBar("Health",x,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));
|
||||||
|
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());
|
selectNode.add(bar.getNode());
|
||||||
mouseOverNode.add(bar.getNode());
|
mouseOverNode.add(bar.getNode());
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,26 +1,19 @@
|
||||||
package ei.game.scene.buildings;
|
package ei.game.scene.buildings;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
|
|
||||||
import ei.engine.math.Vector2f;
|
|
||||||
import ei.engine.math.Vector2i;
|
import ei.engine.math.Vector2i;
|
||||||
import ei.engine.math.Vector3f;
|
|
||||||
import ei.engine.scene.Node;
|
import ei.engine.scene.Node;
|
||||||
import ei.game.algo.AStar;
|
|
||||||
import ei.game.algo.AStarNode;
|
|
||||||
import ei.game.gamestate.InGameState;
|
import ei.game.gamestate.InGameState;
|
||||||
import ei.game.player.Player;
|
import ei.game.player.Player;
|
||||||
import ei.game.scene.GameEntity;
|
import ei.game.scene.GameEntity;
|
||||||
import ei.game.scene.Map;
|
import ei.game.scene.Map;
|
||||||
import ei.game.scene.units.Unit;
|
import ei.game.scene.units.Unit;
|
||||||
import ei.game.scene.weapons.Weapon;
|
|
||||||
import ei.game.scene.weapons.WeaponHandler;
|
|
||||||
|
|
||||||
public abstract class Building extends GameEntity{
|
public abstract class Building extends GameEntity{
|
||||||
private ArrayList<Unit> availableUnits;
|
|
||||||
private Queue<Unit> buildQueue;
|
private Queue<Unit> buildQueue;
|
||||||
|
private int buildTime;
|
||||||
private Node unitNode;
|
private Node unitNode;
|
||||||
private Vector2i oldPos;
|
private Vector2i oldPos;
|
||||||
private int size;
|
private int size;
|
||||||
|
|
@ -29,6 +22,7 @@ public abstract class Building extends GameEntity{
|
||||||
public Building(int l, Vector2i pos, Player p, int size) {
|
public Building(int l, Vector2i pos, Player p, int size) {
|
||||||
super(l, p);
|
super(l, p);
|
||||||
this.size = size;
|
this.size = size;
|
||||||
|
buildQueue = new LinkedList<Unit>();
|
||||||
unitNode = new Node("UnitNode");
|
unitNode = new Node("UnitNode");
|
||||||
unitNode.setLocation(Map.getPixelByPos(pos.getX(), pos.getY(), this.size));
|
unitNode.setLocation(Map.getPixelByPos(pos.getX(), pos.getY(), this.size));
|
||||||
System.out.println("location: "+unitNode.getLocation());
|
System.out.println("location: "+unitNode.getLocation());
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue