2007-03-29 23:21:00 +00:00
|
|
|
package ei.game.scene.weapons;
|
|
|
|
|
|
2007-04-18 10:04:08 +00:00
|
|
|
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;
|
|
|
|
|
}
|
2007-03-29 23:21:00 +00:00
|
|
|
|
|
|
|
|
}
|