Added minVelocity to weapons

This commit is contained in:
Jesper Lundin 2007-04-18 12:40:52 +00:00
parent 9d1bcdc52b
commit 83c0b0f180

View file

@ -15,9 +15,11 @@ public class Weapon {
private int range;
private Vector2i target;
private float velocity;
private float minVelocity;
private Particles part;
private Vector2f startPos;
/**
* Constructor for the class Weapon. Initializes the weapon.
* @param range
@ -28,12 +30,13 @@ public class Weapon {
this.range = range;
this.startPos = startPos;
this.velocity = velocity;
this.minVelocity = 5;
part = new Particles("weapon");
part.setLocation(startPos);
part.MaxSpeedX=500;
part.MaxSpeedY=400;
part.MaxSpeedZ=600;
part.rainbow = true;
part.rainbow = false;
part.size=5;
part.reset();
@ -57,9 +60,17 @@ public class Weapon {
Vector2f vect = Map.getPixelByPos(target.getX(), target.getY());
float yVelocity = (Math.abs((vect.getY()-startPos.getY()) / velocity))/10;
float xVelocity = (Math.abs((vect.getX()-startPos.getX()) / velocity))/10;
System.out.println("xVel: "+xVelocity);
System.out.println("xVel: "+Math.abs(part.getLocation().getX()-vect.getX()));
//System.out.println("xVel: "+Math.abs(part.getLocation().getX()-vect.getX()));
if(xVelocity < minVelocity && xVelocity < yVelocity) {
yVelocity = (yVelocity/xVelocity)*minVelocity;
xVelocity = minVelocity;
}
if(yVelocity < minVelocity && yVelocity < xVelocity) {
xVelocity = (xVelocity/yVelocity)*minVelocity;
yVelocity = minVelocity;
}
if(vect.getX() > part.getLocation().getX()) {
part.getLocation().add(xVelocity, 0f, 0f);
}