4 * Created on: Sep 29, 2012
10 using geometry::Vector;
16 , orientation(ORIENTATION_NORTH)
22 void Entity::SetOrientation(Orientation o) {
25 animation.SetColOffset(orientation);
28 void Entity::SetSpeed(float s) {
33 void Entity::UpdateVelocity() {
35 velocity = Vector<float>();
38 switch (orientation) {
39 case ORIENTATION_NORTH:
40 velocity = Vector<float>(0.0f, -speed);
42 case ORIENTATION_EAST:
43 velocity = Vector<float>(speed, 0.0f);
45 case ORIENTATION_SOUTH:
46 velocity = Vector<float>(0.0f, speed);
48 case ORIENTATION_WEST:
49 velocity = Vector<float>(-speed, 0.0f);
55 bool Entity::TileLock(int width, int height) const {
56 Vector<int> tilePosition(
57 position.X() - (width / 2),
59 return (tilePosition.X() % width == 0) && (tilePosition.Y() % height == 0);
63 void Entity::Update(float deltaT) {
64 position += velocity * deltaT;
68 void Entity::Render(SDL_Surface *dest, const Vector<int> &offset) const {
69 // TODO: configurable sprite offsets
70 if (animation.Running()) {
71 animation.DrawCenter(dest, offset + position);
73 sprite->DrawCenter(dest, offset + position, orientation);