level_menu.c 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. #include "level_menu.h"
  2. #include <stddef.h>
  3. #include "../../engine/vector.h"
  4. #include "../../game.h"
  5. #include "blinking_sprite.h"
  6. #include "delayed_sprite.h"
  7. #include "menu_entity.h"
  8. #include "moving_sprite.h"
  9. typedef struct
  10. {
  11. Entity* quadrastic_logo;
  12. Entity* press_ok;
  13. Entity* left_button;
  14. Entity* right_button;
  15. } LevelMenuContext;
  16. static void
  17. level_menu_alloc(Level* level, GameManager* manager, void* context)
  18. {
  19. LevelMenuContext* menu_context = context;
  20. static const float initial_amimation_duration = 45.0f;
  21. // Quadrastic logo
  22. menu_context->quadrastic_logo =
  23. level_add_entity(level, &moving_sprite_description);
  24. moving_sprite_init(menu_context->quadrastic_logo,
  25. manager,
  26. (Vector){ .x = 9, .y = 64 },
  27. (Vector){ .x = 9, .y = 2 },
  28. initial_amimation_duration,
  29. "quadrastic.fxbm");
  30. // Press ok logo
  31. menu_context->press_ok =
  32. level_add_entity(level, &blinking_sprite_description);
  33. blinking_sprite_init(menu_context->press_ok,
  34. manager,
  35. (Vector){ .x = 31, .y = 33 },
  36. initial_amimation_duration,
  37. 15.0f,
  38. 7.0f,
  39. "press_ok.fxbm");
  40. // Settings button
  41. menu_context->left_button =
  42. level_add_entity(level, &delayed_sprite_description);
  43. delayed_sprite_init(menu_context->left_button,
  44. manager,
  45. (Vector){ .x = 0, .y = 57 },
  46. initial_amimation_duration,
  47. "left_button.fxbm");
  48. // About button
  49. menu_context->right_button =
  50. level_add_entity(level, &delayed_sprite_description);
  51. delayed_sprite_init(menu_context->right_button,
  52. manager,
  53. (Vector){ .x = 115, .y = 57 },
  54. initial_amimation_duration,
  55. "right_button.fxbm");
  56. // Menu
  57. level_add_entity(level, &menu_description);
  58. }
  59. static void
  60. level_menu_start(Level* level, GameManager* manager, void* context)
  61. {
  62. UNUSED(level);
  63. UNUSED(manager);
  64. UNUSED(context);
  65. FURI_LOG_D(GAME_NAME, "Menu level started");
  66. }
  67. const LevelBehaviour level_menu = {
  68. .alloc = level_menu_alloc,
  69. .free = NULL,
  70. .start = level_menu_start,
  71. .stop = NULL,
  72. .context_size = sizeof(LevelMenuContext),
  73. };