From 83c0b0f18067d6a82d603920d20cac0e0d93877a Mon Sep 17 00:00:00 2001 From: Jesper Lundin Date: Wed, 18 Apr 2007 12:40:52 +0000 Subject: [PATCH] Added minVelocity to weapons --- src/ei/game/scene/weapons/Weapon.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/ei/game/scene/weapons/Weapon.java b/src/ei/game/scene/weapons/Weapon.java index 1ee5ee3..9f85885 100644 --- a/src/ei/game/scene/weapons/Weapon.java +++ b/src/ei/game/scene/weapons/Weapon.java @@ -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); }