We already had developed a fantastic PhysicEngine
class, supporting some Newton's laws, and we rely on the Entity
attributes (x,y)
, (dx,dy)
and (ax, ay)
for respectively position, velocity and acceleration, but also Material
attributes and the mass of this entity
We also used the World
object as PhysicEngine
world's limited context with the play area, the gravity
and a clear
identified Material
to define physic attributes of the play area where the Entity
will move on.
It is now time to use some Math to compute things with a Vector2D class.
A Vector2D
is math entity used to define a force on a 2D world. It basically contains 2 attributes: x
and y
.
This new class must be used to define our Entity position, velocity and acceleration :
public class Entity<T>{
public Vector2D position;
public Vector2D velocity;
public Vector2D acceleration;
}