LOL
This commit is contained in:
parent
347a269c4d
commit
8ff57fda63
3 changed files with 12 additions and 11 deletions
|
|
@ -11,8 +11,8 @@ public class SelectBox {
|
||||||
private Node selectNode;
|
private Node selectNode;
|
||||||
private Sprite value;
|
private Sprite value;
|
||||||
private int max;
|
private int max;
|
||||||
private float whidth;
|
private float width;
|
||||||
private static final float hight = 3;
|
private static final float height = 3;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a selection box with health bar
|
* Creates a selection box with health bar
|
||||||
|
|
@ -23,7 +23,7 @@ public class SelectBox {
|
||||||
*/
|
*/
|
||||||
public SelectBox(float x, float y, int max){
|
public SelectBox(float x, float y, int max){
|
||||||
this.max = max;
|
this.max = max;
|
||||||
this.whidth = x;
|
this.width = x;
|
||||||
selectNode = new Node("SelectionNode");
|
selectNode = new Node("SelectionNode");
|
||||||
|
|
||||||
Texture tex = new Texture();
|
Texture tex = new Texture();
|
||||||
|
|
@ -33,13 +33,13 @@ public class SelectBox {
|
||||||
tex2.setColor(new Vector4f(0.3f, 1.0f, 0.3f, 0.6f));
|
tex2.setColor(new Vector4f(0.3f, 1.0f, 0.3f, 0.6f));
|
||||||
|
|
||||||
value = new Sprite("Healthvalue",tex2);
|
value = new Sprite("Healthvalue",tex2);
|
||||||
value.setSize(new Vector2f(x,hight));
|
value.setSize(new Vector2f(x,height));
|
||||||
value.setLocation(new Vector2f(0,-x/2+hight/2));
|
value.setLocation(new Vector2f(0,-x/2+height/2));
|
||||||
selectNode.add(value);
|
selectNode.add(value);
|
||||||
|
|
||||||
Box bar = new Box("bar",tex);
|
Box bar = new Box("bar",tex);
|
||||||
bar.setSize(new Vector2f(x,hight));
|
bar.setSize(new Vector2f(x,height));
|
||||||
bar.setLocation(new Vector2f(0,-x/2+hight/2));
|
bar.setLocation(new Vector2f(0,-x/2+height/2));
|
||||||
selectNode.add(bar);
|
selectNode.add(bar);
|
||||||
|
|
||||||
Box select = new Box("select",tex);
|
Box select = new Box("select",tex);
|
||||||
|
|
@ -64,6 +64,6 @@ public class SelectBox {
|
||||||
* @param v The value of the health bar
|
* @param v The value of the health bar
|
||||||
*/
|
*/
|
||||||
public void setValue(int v){
|
public void setValue(int v){
|
||||||
value.setSize(new Vector2f((v/max)*whidth,hight));
|
value.setSize(new Vector2f((v/max)*width,height));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,12 +12,13 @@ public class Tank extends Unit{
|
||||||
}
|
}
|
||||||
|
|
||||||
public Tank(int x, int y){
|
public Tank(int x, int y){
|
||||||
super(10, new Vector2i(x,y));
|
super(100, new Vector2i(x,y));
|
||||||
Sprite sp = new Sprite("Tank", "data/units/tank.png");
|
Sprite sp = new Sprite("Tank", "data/units/tank.png");
|
||||||
sp.setSize(new Vector2f(50,37));
|
sp.setSize(new Vector2f(50,37));
|
||||||
getNode().add(sp);
|
getNode().add(sp);
|
||||||
|
|
||||||
selectionBox = new SelectBox(40,40,getMaxLife());
|
selectionBox = new SelectBox(40,40,getMaxLife());
|
||||||
|
setLife(50);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected SelectBox getSelection() {
|
protected SelectBox getSelection() {
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,7 @@ public abstract class Unit extends GameEntity{
|
||||||
public void move(int x, int y) {
|
public void move(int x, int y) {
|
||||||
path = (LinkedList<AStarNode>) new AStar().startSearch(oldPos,new Vector2i(x,y));
|
path = (LinkedList<AStarNode>) new AStar().startSearch(oldPos,new Vector2i(x,y));
|
||||||
|
|
||||||
if(path != null && !path.isEmpty()){
|
if(path != null && !path.isEmpty() && moveTo == null){
|
||||||
AStarNode temp = path.poll();
|
AStarNode temp = path.poll();
|
||||||
moveTo = Map.getPixelByPos(temp.getX(), temp.getY());
|
moveTo = Map.getPixelByPos(temp.getX(), temp.getY());
|
||||||
setPos(temp.getX(), temp.getY());
|
setPos(temp.getX(), temp.getY());
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue