GameLogic.h 1.6 KB

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