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. // #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. typedef struct {
  44. FuriString* name;
  45. FuriString* filename;
  46. } TableMenuItem;
  47. std::vector<TableMenuItem> menu_items;
  48. int display_size; // how many can fit on screen
  49. int selected;
  50. };
  51. class Table;
  52. typedef struct PinballApp {
  53. ~PinballApp();
  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 gameStarted;
  60. bool keys[4]; // which key was pressed?
  61. bool processing; // controls game loop and game objects
  62. // user settings
  63. struct {
  64. bool sound_enabled;
  65. bool vibrate_enabled;
  66. bool led_enabled;
  67. bool debug_mode;
  68. } settings;
  69. int selected_setting;
  70. int max_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;