okidoki
This commit is contained in:
parent
99a30c2e8d
commit
90d685195d
5 changed files with 160 additions and 4 deletions
|
|
@ -1,5 +1,63 @@
|
|||
package ei.game.scene.weapons;
|
||||
|
||||
public abstract class Weapon {
|
||||
import ei.engine.effects.Particles;
|
||||
import ei.engine.math.Vector2f;
|
||||
import ei.engine.math.Vector2i;
|
||||
import ei.engine.scene.Entity;
|
||||
import ei.game.scene.Map;
|
||||
|
||||
public class Weapon {
|
||||
private int range;
|
||||
private Vector2i target;
|
||||
private int velocity;
|
||||
private Particles part;
|
||||
private Vector2f startPos;
|
||||
|
||||
public Weapon(int range, Vector2f startPos) {
|
||||
this.range = range;
|
||||
this.startPos = startPos;
|
||||
part = new Particles("weapon");
|
||||
part.setLocation(startPos);
|
||||
part.MaxSpeedX=500;
|
||||
part.MaxSpeedY=400;
|
||||
part.MaxSpeedZ=600;
|
||||
|
||||
part.size=5;
|
||||
|
||||
}
|
||||
public void launch(Vector2i target) {
|
||||
this.target = target;
|
||||
|
||||
|
||||
}
|
||||
public void update() {
|
||||
System.out.println("target getx :"+target.getX());
|
||||
System.out.println("startpos getx :"+startPos.getX());
|
||||
System.out.println("target getx :"+target.getY());
|
||||
System.out.println("startpos gety :"+startPos.getY());
|
||||
|
||||
System.out.println("part getLoc: "+part.getLocation().getX());
|
||||
|
||||
Vector2f vect = Map.getPixelByPos(target.getX(), target.getY());
|
||||
float percentage = (vect.getX()-startPos.getX()) / (vect.getY()-startPos.getY());
|
||||
System.out.println("Percentage; "+percentage);
|
||||
|
||||
if(target.getX() > part.getLocation().getX()) {
|
||||
part.getLocation().add(4f*percentage, 0f, 0f);
|
||||
}
|
||||
if(target.getX() < part.getLocation().getX()) {
|
||||
part.getLocation().add(-4.0f*percentage, 0f, 0f);
|
||||
}
|
||||
if(target.getY() > part.getLocation().getY()) {
|
||||
part.getLocation().add(0f, 4.0f, 0f);
|
||||
}
|
||||
if(target.getY() < part.getLocation().getY()) {
|
||||
part.getLocation().add(0f, -4.0f, 0f);
|
||||
}
|
||||
|
||||
}
|
||||
public Entity getNode() {
|
||||
return part;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue