#include "Entity.h"
+using geometry::Vector;
+
namespace map {
Entity::Entity()
}
+bool Entity::TileLock(int width, int height) const {
+ Vector<int> tilePosition(
+ position.X() - (width / 2),
+ position.Y() - height);
+ return (tilePosition.X() % width == 0) && (tilePosition.Y() % height == 0);
+}
+
+
void Entity::Update(float deltaT) {
position += velocity * deltaT;
}
-void Entity::Render(SDL_Surface *dest, const geometry::Vector<int> &offset) const {
+void Entity::Render(SDL_Surface *dest, const Vector<int> &offset) const {
if (animation.Running()) {
animation.DrawCenterBottom(dest, offset + position);
} else {
graphics::AnimationRunner &Animation() { return animation; }
const graphics::AnimationRunner &Animation() const { return animation; }
+ bool TileLock(int width, int height) const;
+
void Update(float deltaT);
void Render(SDL_Surface *, const geometry::Vector<int> &offset) const;
void MapState::HandleEvents(const Input &input) {
if (!controlled) return;
+ if (!controlled->TileLock(map->Tileset()->Width(), map->Tileset()->Height())) return;
}
void MapState::UpdateWorld(float deltaT) {