123456789101112131415161718192021 |
- #include "Entity.h"
- Entity::Entity(const Vector2& size, float mass)
- : size(size), inverseMass(1.0f / mass), onGround(false) {
- }
- void Entity::addForce(const Vector2& force) {
- acceleration += force * inverseMass;
- }
- void Entity::preTick() {
- lastPosition = position;
- // start off with gravity for the next frame
- acceleration = Vector2(0.0f, -0.5f);
- }
- void Entity::tick() {
- // euler integration, timestep is constant
- velocity += acceleration;
- position += velocity;
- }
|