game.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * Copyright 2025 Ivan Barsukov
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #include "game.h"
  18. #include <core/record.h>
  19. #include <furi.h>
  20. #include <notification/notification.h>
  21. #include "engine/engine.h"
  22. #include "game_settings.h"
  23. #include "levels/level_about/level_about.h"
  24. #include "levels/level_game/level_game.h"
  25. #include "levels/level_game_over/level_game_over.h"
  26. #include "levels/level_menu/level_menu.h"
  27. #include "levels/level_settings/level_settings.h"
  28. static void
  29. game_start(GameManager* game_manager, void* _game_context)
  30. {
  31. GameContext* game_context = _game_context;
  32. game_read_settings(game_context);
  33. game_context->notification = furi_record_open(RECORD_NOTIFICATION);
  34. game_context->levels.menu =
  35. game_manager_add_level(game_manager, &level_menu);
  36. game_context->levels.about =
  37. game_manager_add_level(game_manager, &level_about);
  38. game_context->levels.game =
  39. game_manager_add_level(game_manager, &level_game);
  40. game_context->levels.game_over =
  41. game_manager_add_level(game_manager, &level_game_over);
  42. game_context->levels.settings =
  43. game_manager_add_level(game_manager, &level_settings);
  44. FURI_LOG_I(GAME_NAME, "Game has started");
  45. }
  46. static void
  47. game_stop(void* _game_context)
  48. {
  49. UNUSED(_game_context);
  50. furi_record_close(RECORD_NOTIFICATION);
  51. FURI_LOG_I(GAME_NAME, "Game over");
  52. }
  53. const Game game = {
  54. .target_fps = 30,
  55. .show_fps = false,
  56. .always_backlight = true,
  57. .start = game_start,
  58. .stop = game_stop,
  59. .context_size = sizeof(GameContext), // size of game context
  60. };