Game Development Reference
In-Depth Information
Add the following import to AbstractGameObject :
import com.badlogic.gdx.math.Rectangle;
Then, add the following member variables and initialization code to the same class:
public Vector2 velocity;
public Vector2 terminalVelocity;
public Vector2 friction;
public Vector2 acceleration;
public Rectangle bounds;
public AbstractGameObject () {
position = new Vector2();
dimension = new Vector2(1, 1);
origin = new Vector2();
scale = new Vector2(1, 1);
rotation = 0;
velocity = new Vector2();
terminalVelocity = new Vector2(1, 1);
friction = new Vector2();
acceleration = new Vector2();
bounds = new Rectangle();
}
The following list contains a brief description of the purpose of each variable:
velocity : This is the object's current speed in m/s.
terminalVelocity : This is the object's positive and negative maximum
speed in m/s.
friction : This is an opposing force that slows down the object until
its velocity equals zero. This value is given as a coefficient that is
dimensionless. A value of zero means no friction, and thus the object's
velocity will not decrease.
acceleration : This is the object's constant acceleration in m/s².
bounds : The object's bounding box describes the physical body that will be
used for collision detection with other objects. The bounding box can be set
to any size and is completely independent of the actual dimension of the
object in the game world.
 
Search WWH ::




Custom Search