isometricGame.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. #pragma once
  2. #include <gl2d/gl2d.h>
  3. #include <imgui.h>
  4. #include <baseContainer.h>
  5. #include <shortcutApi/shortcutApi.h>
  6. #include <pikaSizes.h>
  7. #include <fileChanged.h>
  8. #include <engineLibraresSupport/engineGL2DSupport.h>
  9. #include <containers/isometricGame/isometricGameEditor.h>
  10. struct IsometricGame: public Container
  11. {
  12. static constexpr int MAPS_COUNT = 5;
  13. IsometricGameEditor::Map levels[MAPS_COUNT] = {};
  14. gl2d::Renderer2D renderer;
  15. gl2d::Texture tiles;
  16. gl2d::Texture shadow;
  17. gl2d::TextureAtlasPadding tilesAtlas;
  18. gl2d::Texture playerSprite;
  19. gl2d::TextureAtlas playerAtlas;
  20. gl2d::Texture itemsSprite;
  21. gl2d::TextureAtlas itemsAtlas;
  22. gl2d::Font font;
  23. gl2d::Texture itemFrameSprite;
  24. float life = 1;
  25. int redstoneCount = 0;
  26. int redstoneTorchesCount = 0;
  27. int foodCount = 0;
  28. int itemSelected = -1;
  29. int currentLevel = 0;
  30. glm::ivec3 playerPosition = {13, 1, 3};
  31. struct PlayerAnimations
  32. {
  33. int indexX = 0;
  34. int indexY = 0;
  35. float timer = 0.2;
  36. glm::vec3 delta = {};
  37. glm::ivec2 lastPosition = {};
  38. }playerAnimations;
  39. std::vector<glm::ivec2> path;
  40. float timerPath = 0;
  41. static ContainerStaticInfo containerInfo()
  42. {
  43. ContainerStaticInfo info = {};
  44. info.defaultHeapMemorySize = pika::MB(20);
  45. info.requestImguiFbo = true;
  46. return info;
  47. }
  48. bool create(RequestedContainerInfo &requestedInfo, pika::StaticString<256> commandLineArgument);
  49. struct Block
  50. {
  51. unsigned char type;
  52. unsigned char secondType;
  53. void set(unsigned char count, unsigned char down)
  54. {
  55. type = count;
  56. secondType = down;
  57. }
  58. glm::ivec2 get()
  59. {
  60. return {type, secondType};
  61. }
  62. };
  63. struct RedstoneStatus
  64. {
  65. unsigned char status = {};
  66. };
  67. std::vector<RedstoneStatus> redstone;
  68. bool update(pika::Input input, pika::WindowState windowState,
  69. RequestedContainerInfo &requestedInfo) override;
  70. void destruct(RequestedContainerInfo &requestedInfo) override;
  71. void saveData(RequestedContainerInfo &requestedInfo);
  72. };