Added minVelocity to weapons
This commit is contained in:
parent
9d1bcdc52b
commit
83c0b0f180
1 changed files with 14 additions and 3 deletions
|
|
@ -15,9 +15,11 @@ public class Weapon {
|
||||||
private int range;
|
private int range;
|
||||||
private Vector2i target;
|
private Vector2i target;
|
||||||
private float velocity;
|
private float velocity;
|
||||||
|
private float minVelocity;
|
||||||
private Particles part;
|
private Particles part;
|
||||||
private Vector2f startPos;
|
private Vector2f startPos;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for the class Weapon. Initializes the weapon.
|
* Constructor for the class Weapon. Initializes the weapon.
|
||||||
* @param range
|
* @param range
|
||||||
|
|
@ -28,12 +30,13 @@ public class Weapon {
|
||||||
this.range = range;
|
this.range = range;
|
||||||
this.startPos = startPos;
|
this.startPos = startPos;
|
||||||
this.velocity = velocity;
|
this.velocity = velocity;
|
||||||
|
this.minVelocity = 5;
|
||||||
part = new Particles("weapon");
|
part = new Particles("weapon");
|
||||||
part.setLocation(startPos);
|
part.setLocation(startPos);
|
||||||
part.MaxSpeedX=500;
|
part.MaxSpeedX=500;
|
||||||
part.MaxSpeedY=400;
|
part.MaxSpeedY=400;
|
||||||
part.MaxSpeedZ=600;
|
part.MaxSpeedZ=600;
|
||||||
part.rainbow = true;
|
part.rainbow = false;
|
||||||
part.size=5;
|
part.size=5;
|
||||||
part.reset();
|
part.reset();
|
||||||
|
|
||||||
|
|
@ -57,9 +60,17 @@ public class Weapon {
|
||||||
Vector2f vect = Map.getPixelByPos(target.getX(), target.getY());
|
Vector2f vect = Map.getPixelByPos(target.getX(), target.getY());
|
||||||
float yVelocity = (Math.abs((vect.getY()-startPos.getY()) / velocity))/10;
|
float yVelocity = (Math.abs((vect.getY()-startPos.getY()) / velocity))/10;
|
||||||
float xVelocity = (Math.abs((vect.getX()-startPos.getX()) / 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()) {
|
if(vect.getX() > part.getLocation().getX()) {
|
||||||
part.getLocation().add(xVelocity, 0f, 0f);
|
part.getLocation().add(xVelocity, 0f, 0f);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue