]> git.localhorst.tv Git - l2e.git/blob - src/map/Entity.cpp
check tile lock in Entity
[l2e.git] / src / map / Entity.cpp
1 /*
2  * Entity.cpp
3  *
4  *  Created on: Sep 29, 2012
5  *      Author: holy
6  */
7
8 #include "Entity.h"
9
10 using geometry::Vector;
11
12 namespace map {
13
14 Entity::Entity()
15 : sprite(0) {
16
17 }
18
19
20 bool Entity::TileLock(int width, int height) const {
21         Vector<int> tilePosition(
22                         position.X() - (width / 2),
23                         position.Y() - height);
24         return (tilePosition.X() % width == 0) && (tilePosition.Y() % height == 0);
25 }
26
27
28 void Entity::Update(float deltaT) {
29         position += velocity * deltaT;
30 }
31
32
33 void Entity::Render(SDL_Surface *dest, const Vector<int> &offset) const {
34         if (animation.Running()) {
35                 animation.DrawCenterBottom(dest, offset + position);
36         } else {
37                 sprite->DrawCenterBottom(dest, offset + position);
38         }
39 }
40
41 }