pinball0.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #pragma once
  2. #include <gui/gui.h>
  3. #include <input/input.h>
  4. #include <stdlib.h>
  5. #include <stdbool.h>
  6. #include <string.h>
  7. #include <cmath>
  8. // #include <furi_hal_resources.h>
  9. // #include <furi_hal_gpio.h>
  10. #include <furi.h>
  11. #include <dolphin/dolphin.h>
  12. #include <storage/storage.h>
  13. #include <notification/notification.h>
  14. #include <notification/notification_messages.h>
  15. #include "vec2.h"
  16. #include "objects.h"
  17. #include "settings.h"
  18. // #define DRAW_NORMALS
  19. #define TAG "Pinball0"
  20. #define VERSION "v0.5.2"
  21. // Vertical orientation
  22. #define LCD_WIDTH 64
  23. #define LCD_HEIGHT 128
  24. typedef enum GameMode {
  25. GM_TableSelect,
  26. GM_Playing,
  27. GM_GameOver,
  28. GM_Error,
  29. GM_Settings,
  30. GM_Tilted
  31. } GameMode;
  32. class TableList {
  33. public:
  34. TableList() = default;
  35. ~TableList() {
  36. for(auto& mi : menu_items) {
  37. furi_string_free(mi.name);
  38. furi_string_free(mi.filename);
  39. }
  40. }
  41. typedef struct {
  42. FuriString* name;
  43. FuriString* filename;
  44. } TableMenuItem;
  45. std::vector<TableMenuItem> menu_items;
  46. int display_size; // how many can fit on screen
  47. int selected;
  48. };
  49. class Table;
  50. typedef struct PinballApp {
  51. PinballApp();
  52. ~PinballApp();
  53. bool initialized;
  54. FuriMutex* mutex;
  55. TableList table_list;
  56. GameMode game_mode;
  57. Table* table; // data for the current table
  58. uint32_t tick;
  59. bool keys[4]; // which key was pressed?
  60. bool processing; // controls game loop and game objects
  61. uint32_t idle_start; // tracks time of last key press
  62. // user settings
  63. PinballSettings settings;
  64. // system objects
  65. Storage* storage;
  66. NotificationApp* notify; // allows us to blink/buzz during game
  67. char text[256]; // general temp buffer
  68. } PinballApp;