Fixed som bugs with unit
This commit is contained in:
parent
da8ec6f899
commit
a7749878f0
3 changed files with 9 additions and 7 deletions
|
|
@ -24,8 +24,8 @@ public class InGameState extends GameState{
|
|||
|
||||
HumanPlayer player = new HumanPlayer();
|
||||
player.addUnit(new Tank());
|
||||
player.addUnit(new Tank(0,1));
|
||||
player.addUnit(new Tank(0,2));
|
||||
player.addUnit(new Tank(1,0));
|
||||
player.addUnit(new Tank(2,0));
|
||||
rootNode.add(player.getNode());
|
||||
PlayerHandler.getInstance().addPlayer(player);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package ei.game.scene.units;
|
||||
|
||||
import ei.engine.math.Vector2f;
|
||||
import ei.engine.math.Vector2i;
|
||||
import ei.engine.math.Vector4f;
|
||||
import ei.engine.scene.Box;
|
||||
import ei.engine.scene.Entity;
|
||||
|
|
@ -14,7 +15,7 @@ public class Tank extends Unit{
|
|||
}
|
||||
|
||||
public Tank(int x, int y){
|
||||
super(10);
|
||||
super(10, new Vector2i(x,y));
|
||||
Sprite sp = new Sprite("Tank", "data/units/tank.png");
|
||||
sp.setSize(new Vector2f(50,37));
|
||||
getNode().add(sp);
|
||||
|
|
|
|||
|
|
@ -35,11 +35,13 @@ public abstract class Unit extends GameEntity{
|
|||
*
|
||||
* @param l The max life of the unit
|
||||
*/
|
||||
public Unit(int l) {
|
||||
public Unit(int l, Vector2i pos) {
|
||||
super(l);
|
||||
unitNode = new Node("unit");
|
||||
setPos(0, 0);
|
||||
unitNode.setLocation(Map.getPixelByPos(pos.getX(), pos.getY()));
|
||||
setPos(pos.getX(), pos.getY());
|
||||
}
|
||||
|
||||
public void setSelected(boolean b) {
|
||||
super.setSelected(b);
|
||||
if(b) {
|
||||
|
|
@ -67,7 +69,6 @@ public abstract class Unit extends GameEntity{
|
|||
public void setPos(int x, int y) {
|
||||
oldPos = new Vector2i(x, y);
|
||||
InGameState.getMap().setPos(this, x, y);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue