pinball0.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. // #define DRAW_NORMALS
  18. #define TAG "Pinball0"
  19. #define VERSION "v0.3"
  20. // Vertical orientation
  21. #define LCD_WIDTH 64
  22. #define LCD_HEIGHT 128
  23. typedef enum {
  24. EventTypeTick,
  25. EventTypeKey
  26. } EventType;
  27. typedef struct {
  28. EventType type;
  29. InputEvent input;
  30. } PinballEvent;
  31. typedef enum GameMode {
  32. GM_TableSelect,
  33. GM_Playing,
  34. GM_GameOver,
  35. GM_Error,
  36. GM_Settings,
  37. GM_About
  38. } GameMode;
  39. class TableList {
  40. public:
  41. TableList() = default;
  42. ~TableList() {
  43. for(auto& mi : menu_items) {
  44. furi_string_free(mi.name);
  45. furi_string_free(mi.filename);
  46. }
  47. }
  48. typedef struct {
  49. FuriString* name;
  50. FuriString* filename;
  51. } TableMenuItem;
  52. std::vector<TableMenuItem> menu_items;
  53. int display_size; // how many can fit on screen
  54. int selected;
  55. };
  56. class Table;
  57. typedef struct PinballApp {
  58. ~PinballApp();
  59. FuriMutex* mutex;
  60. TableList table_list;
  61. GameMode game_mode;
  62. Table* table; // data for the current table
  63. uint32_t tick;
  64. bool gameStarted;
  65. bool keys[4]; // which key was pressed?
  66. bool processing; // controls game loop and game objects
  67. uint32_t idle_start; // tracks time of last key press
  68. // user settings
  69. struct {
  70. bool sound_enabled;
  71. bool vibrate_enabled;
  72. bool led_enabled;
  73. bool debug_mode;
  74. } settings;
  75. int selected_setting;
  76. int max_settings;
  77. // system objects
  78. Storage* storage;
  79. NotificationApp* notify; // allows us to blink/buzz during game
  80. char text[256]; // general temp buffer
  81. } PinballApp;