pinball0.h 1.8 KB

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