Explorar el Código

add game mode

jblanked hace 10 meses
padre
commit
440255c17c
Se han modificado 5 ficheros con 18 adiciones y 0 borrados
  1. 3 0
      callback/callback.c
  2. 1 0
      flip_world.c
  3. 1 0
      flip_world.h
  4. 2 0
      game/game.c
  5. 11 0
      game/player.h

+ 3 - 0
callback/callback.c

@@ -1193,12 +1193,15 @@ void callback_submenu_choices(void *context, uint32_t index)
         view_dispatcher_switch_to_view(app->view_dispatcher, FlipWorldViewGameSubmenu);
         break;
     case FlipWorldSubmenuIndexStory:
+        game_mode_index = 2; // GAME_MODE_STORY
         easy_flipper_dialog("Unavailable", "\nStory mode is not ready yet.\nPress BACK to return.");
         break;
     case FlipWorldSubmenuIndexPvP:
+        game_mode_index = 1; // GAME_MODE_PVP
         easy_flipper_dialog("Unavailable", "\nPvP mode is not ready yet.\nPress BACK to return.");
         break;
     case FlipWorldSubmenuIndexPvE:
+        game_mode_index = 0; // GAME_MODE_PVE
         free_all_views(app, true, true);
         if (!is_enough_heap(60000))
         {

+ 1 - 0
flip_world.c

@@ -10,6 +10,7 @@ int player_sprite_index = 1;
 char *vgm_levels[] = {"-2", "-1", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10"};
 int vgm_x_index = 2;
 int vgm_y_index = 2;
+int game_mode_index = 0;
 float atof_(const char *nptr) { return (float)strtod(nptr, NULL); }
 float atof_furi(const FuriString *nptr) { return atof_(furi_string_get_cstr(nptr)); }
 bool is_str(const char *src, const char *dst) { return strcmp(src, dst) == 0; }

+ 1 - 0
flip_world.h

@@ -97,6 +97,7 @@ extern int player_sprite_index;
 extern char *vgm_levels[];
 extern int vgm_x_index;
 extern int vgm_y_index;
+extern int game_mode_index;
 float atof_(const char *nptr);
 float atof_furi(const FuriString *nptr);
 bool is_str(const char *src, const char *dst);

+ 2 - 0
game/game.c

@@ -21,6 +21,8 @@ static void game_start(GameManager *game_manager, void *ctx)
     game_context->enemy_count = 0;
     game_context->npc_count = 0;
 
+    game_context->game_mode = game_mode_index;
+
     // set all levels to NULL
     for (int i = 0; i < MAX_LEVELS; i++)
         game_context->levels[i] = NULL;

+ 11 - 0
game/player.h

@@ -62,6 +62,14 @@ typedef enum
     GAME_MENU_NPC,  // NPC dialog
 } GameMenuScreen;
 
+// game modes
+typedef enum
+{
+    GAME_MODE_PVE = 0,   // player(s) vs everyone
+    GAME_MODE_PVP = 1,   // player vs player
+    GAME_MODE_STORY = 2, // story mode
+} GameMode;
+
 typedef struct
 {
     PlayerContext *player_context;
@@ -69,6 +77,7 @@ typedef struct
     Entity *enemies[MAX_ENEMIES];
     Entity *npcs[MAX_NPCS];
     Entity *player;
+    //
     float fps;
     int level_count;
     int enemy_count;
@@ -87,6 +96,8 @@ typedef struct
     GameMenuScreen menu_screen;
     uint8_t menu_selection;
     //
+    GameMode game_mode;
+    //
     int icon_count;
     int icon_offset;
     //