Przeglądaj źródła

Add game over notification

Ivan Barsukov 1 rok temu
rodzic
commit
ffa779a6ff

+ 45 - 2
src/game_notifications.c

@@ -10,10 +10,50 @@ const NotificationSequence sequence_earn_point = {
     &message_sound_off, &message_vibro_off, &message_green_0, NULL,
 };
 
+const NotificationSequence sequence_game_over = {
+    &message_red_255,
+    &message_vibro_on,
+
+    &message_note_ds4,
+    &message_delay_10,
+    &message_sound_off,
+    &message_delay_10,
+
+    &message_note_ds4,
+    &message_delay_10,
+    &message_sound_off,
+    &message_delay_10,
+
+    &message_note_ds4,
+    &message_delay_10,
+    &message_sound_off,
+    &message_delay_10,
+
+    &message_note_ds4,
+    &message_delay_10,
+    &message_sound_off,
+    &message_delay_10,
+
+    &message_note_ds4,
+    &message_delay_10,
+    &message_sound_off,
+    &message_delay_10,
+
+    &message_note_ds4,
+    &message_delay_10,
+    &message_sound_off,
+    &message_delay_10,
+
+    &message_vibro_off,
+    &message_red_0,
+
+    NULL,
+};
+
 void
 game_notify(GameContext* game_context, const NotificationSequence* sequence)
 {
-    static const NotificationMessage* notification[20];
+    static const NotificationMessage* notification[30];
 
     size_t input_index = 0;
     size_t result_index = 0;
@@ -39,7 +79,10 @@ game_notify(GameContext* game_context, const NotificationSequence* sequence)
         notification[result_index] = item;
         ++result_index;
     }
-    notification[result_index] = NULL;
+
+    for (size_t index = result_index; index < sizeof(notification); ++index) {
+        notification[index] = NULL;
+    }
 
     notification_message(game_context->notification,
                          (const NotificationSequence*)notification);

+ 1 - 0
src/game_notifications.h

@@ -5,6 +5,7 @@
 #include "game.h"
 
 extern const NotificationSequence sequence_earn_point;
+extern const NotificationSequence sequence_game_over;
 
 void
 game_notify(GameContext* game_context, const NotificationSequence* sequence);

+ 2 - 0
src/levels/level_game/enemy_entity.c

@@ -2,6 +2,7 @@
 
 #include "src/engine/game_manager.h"
 #include "src/game.h"
+#include "src/game_notifications.h"
 
 #include "level_game.h"
 #include "player_entity.h"
@@ -163,6 +164,7 @@ enemy_collision(Entity* self,
 
     // Game over
     GameContext* game_context = game_manager_game_context_get(manager);
+    game_notify(game_context, &sequence_game_over);
     game_manager_next_level_set(manager, game_context->levels.game_over);
 }