GameLogic.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #pragma once
  2. #include "utils/Card.h"
  3. #include "utils/List.h"
  4. #include "utils/Input.h"
  5. #include "utils/Vector.h"
  6. enum GameState {
  7. Logo, Intro, Play, Solve, Finish
  8. };
  9. class GameLogic {
  10. List<Card> hand = List<Card>();
  11. RenderBuffer *buffer;
  12. List<Card> stock = List<Card>();
  13. List<Card> waste = List<Card>();
  14. List<Card> foundation[4] = {List<Card>(), List<Card>(), List<Card>(), List<Card>()};
  15. List<Card> tableau[7] = {List<Card>(), List<Card>(), List<Card>(), List<Card>(), List<Card>(), List<Card>(),
  16. List<Card>()};
  17. int8_t selection[2] = {0, 0};
  18. int8_t selectedCard = 0;
  19. Card *tempCard;
  20. Vector tempPos = {0, 0};
  21. float tempTime = 0;
  22. int8_t target[2] = {0, -1};
  23. bool readyToRender = false;
  24. Vector velocity;
  25. public:
  26. GameState state = Logo;
  27. bool dirty = true;
  28. double startTime;
  29. double end;
  30. GameLogic(RenderBuffer *buffer, InputEventHandler *inputHandler);
  31. ~GameLogic();
  32. void Update(float delta);
  33. void Input(int key, InputType type);
  34. void Reset();
  35. void GenerateDeck();
  36. bool CanSolve();
  37. void DoIntro(float delta);
  38. void DrawPlayScene();
  39. void HandleSolve(float delta);
  40. void QuickSolve();
  41. void FallingCard(float delta);
  42. bool isReady() const { return readyToRender; }
  43. void DrawColumn(uint8_t x, uint8_t y, uint8_t selected, int8_t column);
  44. void HandleNavigation(int key);
  45. void PickAndPlace();
  46. int8_t FirstNonFlipped(const List<Card> &deck);
  47. };