Entity.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #include "Entity.h"
  2. #include "misc.h"
  3. #include "Rect.h"
  4. #include "Text.h"
  5. #define ENTITY WalrusRPG::Entity
  6. #define RECT WalrusRPG::Utils::Rect
  7. ENTITY::Entity(int x, int y, unsigned w, unsigned h, WalrusRPG::Renderer *tset,
  8. unsigned sprite_id)
  9. : coords(x, y, w, h), tset(tset), sprite_id(sprite_id)
  10. {
  11. }
  12. ENTITY::~Entity()
  13. {
  14. // TODO if you allocate dynamically members
  15. }
  16. void ENTITY::render(Camera &camera, unsigned dt) const
  17. {
  18. UNUSED(dt);
  19. if (camera.is_visible(coords))
  20. {
  21. tset->render(sprite_id,
  22. RECT(coords.x - camera.get_x(), coords.y - camera.get_y()));
  23. //(*tset).render_tile(sprite_id, coords.x - camera.get_x(), coords.y -
  24. // camera.get_y(), dt);
  25. }
  26. }
  27. void ENTITY::update(unsigned dt)
  28. {
  29. UNUSED(dt);
  30. // TODO update map's data according to elasped time
  31. /*
  32. // Need to think aagain on how to go to a target point and/or we need to
  33. align the corner OR the center to this point.
  34. position += velocity * dt;
  35. velocity += acceleration * dt;
  36. */
  37. }