entities.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #include "entities.h"
  2. //extern "C"
  3. /*Player create_player(double x, double y){
  4. return {create_coords((double) x + (double)0.5, (double) y + (double)0.5), create_coords(1, 0), create_coords(0, -0.66), 0, 100, 0};
  5. }*/
  6. Player create_player(double x, double y) {
  7. Player p;
  8. p.pos = create_coords((double)x + (double)0.5, (double)y + (double)0.5);
  9. p.dir = create_coords(1, 0);
  10. p.plane = create_coords(0, -0.66);
  11. p.velocity = 0;
  12. p.health = 100;
  13. p.keys = 0;
  14. return p; //{create_coords((double) x + (double)0.5, (double) y + (double)0.5), create_coords(1, 0), create_coords(0, -0.66), 0, 100, 0};
  15. }
  16. //extern "C"
  17. Entity
  18. create_entity(uint8_t type, uint8_t x, uint8_t y, uint8_t initialState, uint8_t initialHealth) {
  19. UID uid = create_uid(type, x, y);
  20. Coords pos = create_coords((double)x + (double).5, (double)y + (double).5);
  21. Entity new_entity; // = { uid, pos, initialState, initialHealth, 0, 0 };
  22. new_entity.uid = uid;
  23. new_entity.pos = pos;
  24. new_entity.state = initialState;
  25. new_entity.health = initialHealth;
  26. new_entity.distance = 0;
  27. new_entity.timer = 0;
  28. return new_entity;
  29. }
  30. //extern "C"
  31. StaticEntity crate_static_entity(UID uid, uint8_t x, uint8_t y, bool active) {
  32. StaticEntity ent;
  33. ent.uid = uid;
  34. ent.x = x;
  35. ent.y = y;
  36. ent.active = active;
  37. return ent;
  38. }