Class SmoothMover

java.lang.Object
  extended by greenfoot.Actor
      extended by SmoothMover

public abstract class SmoothMover
extends greenfoot.Actor

A variation of an actor that maintains precise location (using doubles for the co-ordinates instead of ints). It also maintains a current movement in form of a movement vector.

Version:
2.0
Author:
Poul Henriksen, Michael Kolling

Constructor Summary
SmoothMover()
           
SmoothMover(Vector movement)
          Create new thing initialised with given speed.
 
Method Summary
 void accelerate(double factor)
          Accelerate the speed of this mover by the given factor.
 void addForce(Vector force)
          Increase the speed with the given vector.
 double getExactX()
           
 double getExactY()
           
 Vector getMovement()
          Return the current speed.
 double getSpeed()
          Return the speed of this actor.
 void move()
          Move in the current movement direction.
 void setLocation(double x, double y)
           
 void setLocation(int x, int y)
          Assign a new location for this object.
 void stop()
          Increase the speed with the given vector.
 
Methods inherited from class greenfoot.Actor
act, addedToWorld, getHeight, getImage, getIntersectingObjects, getNeighbours, getObjectsAtOffset, getObjectsInRange, getOneIntersectingObject, getOneObjectAtOffset, getRotation, getWidth, getWorld, getX, getY, intersects, setImage, setImage, setRotation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SmoothMover

public SmoothMover()

SmoothMover

public SmoothMover(Vector movement)
Create new thing initialised with given speed.

Method Detail

accelerate

public void accelerate(double factor)
Accelerate the speed of this mover by the given factor. (Factors < 1 will decelerate.)


addForce

public void addForce(Vector force)
Increase the speed with the given vector.


getExactX

public double getExactX()

getExactY

public double getExactY()

getMovement

public Vector getMovement()
Return the current speed.


getSpeed

public double getSpeed()
Return the speed of this actor.


move

public void move()
Move in the current movement direction.


setLocation

public void setLocation(double x,
                        double y)

setLocation

public void setLocation(int x,
                        int y)
Description copied from class: greenfoot.Actor
Assign a new location for this object. The location is specified as a cell index in the world. If this method is overridden it is important to call this method with super.setLocation(x,y) from the overriding method.

Overrides:
setLocation in class greenfoot.Actor
Parameters:
x - Location index on the x-axis
y - Location index on the y-axis

stop

public void stop()
Increase the speed with the given vector.