Explorar el Código

memory improvements, collision fixes, final typos

jblanked hace 11 meses
padre
commit
176af4523d

+ 2 - 1
README.md

@@ -70,9 +70,10 @@ An enemy attack registers if the enemy is facing you and collides with you. Howe
 
 **v0.4**
 - New game features
+- World expansion
+- Stability patch
 
 **v0.5**
-- World expansion
 - New game features
 - Custom Controller Support
 

BIN
assets/01-home.png


+ 2 - 1
assets/CHANGELOG.md

@@ -1,9 +1,10 @@
-## 0.4 (2025-01-17)
+## 0.4 (2025-01-23)
 - Added an In-Game menu.
 - Added New controls (HOLD OK to access the In-Game menu, PRESS BACK to exit the menu, and HOLD BACK to leave the game).
 - Added option to choose player weapon in the Game Settings.
 - Added transition icon for switching worlds.
 - Doubled the size of each world (from 384x192 to 768x384).
+- Improved memory allocation.
 
 ## 0.3 (2025-01-14)
 - Added new worlds.

+ 2 - 1
assets/README.md

@@ -67,9 +67,10 @@ An enemy attack registers if the enemy is facing you and collides with you. Howe
 
 **v0.4**
 - New game features
+- Stability patch
+- World expansion
 
 **v0.5**
-- World expansion
 - New game features
 - Custom Controller Support
 

+ 8 - 0
easy_flipper/easy_flipper.h

@@ -26,6 +26,14 @@
 #include <jsmn/jsmn_furi.h>
 #include <jsmn/jsmn.h>
 
+// added by Derek Jamison to lower memory usage
+#undef FURI_LOG_E
+#define FURI_LOG_E(tag, msg, ...)
+
+#undef FURI_LOG_I
+#define FURI_LOG_I(tag, msg, ...)
+//
+
 #define EASY_TAG "EasyFlipper"
 
 void easy_flipper_dialog(

+ 8 - 0
flipper_http/flipper_http.h

@@ -14,6 +14,14 @@
 #include <furi_hal_serial.h>
 #include <storage/storage.h>
 
+// added by Derek Jamison to lower memory usage
+#undef FURI_LOG_E
+#define FURI_LOG_E(tag, msg, ...)
+
+#undef FURI_LOG_I
+#define FURI_LOG_I(tag, msg, ...)
+//
+
 // STORAGE_EXT_PATH_PREFIX is defined in the Furi SDK as /ext
 
 #define HTTP_TAG "FlipWorld"              // change this to your app name

+ 6 - 2
game/draw.c

@@ -20,9 +20,13 @@ void draw_user_stats(Canvas *canvas, Vector pos, GameManager *manager)
     char level[32];
 
     snprintf(health, sizeof(health), "HP : %ld", player->health);
-    snprintf(xp, sizeof(xp), "XP : %ld", player->xp);
     snprintf(level, sizeof(level), "LVL: %ld", player->level);
 
+    if (player->xp < 10000)
+        snprintf(xp, sizeof(xp), "XP : %ld", player->xp);
+    else
+        snprintf(xp, sizeof(xp), "XP : %ldK", player->xp / 1000);
+
     canvas_set_font_custom(canvas, FONT_SIZE_SMALL);
     canvas_draw_str(canvas, pos.x, pos.y, health);
     canvas_draw_str(canvas, pos.x, pos.y + 7, xp);
@@ -163,7 +167,7 @@ static void draw_menu(GameManager *manager, Canvas *canvas)
         }
 
         canvas_set_font(canvas, FontPrimary);
-        canvas_draw_str(canvas, 7, 16, "FlipWorld v0.4");
+        canvas_draw_str(canvas, 7, 16, VERSION_TAG);
         canvas_set_font_custom(canvas, FONT_SIZE_SMALL);
         canvas_draw_str_multi(canvas, 7, 25, "Developed by\nJBlanked and Derek \nJamison. Graphics\nfrom Pr3!\n\nwww.github.com/jblanked");
 

+ 3 - 19
game/enemy.c

@@ -364,24 +364,8 @@ static void enemy_collision(Entity *self, Entity *other, GameManager *manager, v
         }
         else // handle other collisions
         {
-            // Bounce player in the direction they came
-            Vector player_pos = entity_pos_get(other);
-            switch (game_context->player_context->direction)
-            {
-            case PLAYER_UP:
-                player_pos.y += enemy_context->size.y;
-                break;
-            case PLAYER_DOWN:
-                player_pos.y -= enemy_context->size.y;
-                break;
-            case PLAYER_LEFT:
-                player_pos.x += enemy_context->size.x;
-                break;
-            case PLAYER_RIGHT:
-                player_pos.x -= enemy_context->size.x;
-                break;
-            };
-            entity_pos_set(other, player_pos);
+            // Set the player's old position to prevent collision
+            entity_pos_set(other, game_context->player_context->old_position);
             // Reset player's movement direction to prevent immediate re-collision
             game_context->player_context->dx = 0;
             game_context->player_context->dy = 0;
@@ -395,7 +379,7 @@ static void enemy_collision(Entity *self, Entity *other, GameManager *manager, v
         {
             // Reset player's position and health
             entity_pos_set(other, game_context->player_context->start_position);
-            game_context->player_context->health = 100;
+            game_context->player_context->health = game_context->player_context->max_health;
         }
     }
 }

+ 2 - 20
game/icon.c

@@ -10,26 +10,8 @@ static void icon_collision(Entity *self, Entity *other, GameManager *manager, vo
         PlayerContext *player = (PlayerContext *)entity_context_get(other);
         if (player)
         {
-            Vector player_pos = entity_pos_get(other);
-
-            // Bounce player in the direction they came
-            switch (player->direction)
-            {
-            case PLAYER_UP:
-                player_pos.y += ictx->size.y;
-                break;
-            case PLAYER_DOWN:
-                player_pos.y -= ictx->size.y;
-                break;
-            case PLAYER_LEFT:
-                player_pos.x += ictx->size.x;
-                break;
-            case PLAYER_RIGHT:
-                player_pos.x -= ictx->size.x;
-                break;
-            };
-
-            entity_pos_set(other, player_pos);
+            // Set the player's old position to prevent collision
+            entity_pos_set(other, player->old_position);
 
             // Reset movement to prevent re-collision
             player->dx = 0;

+ 2 - 2
game/level.c

@@ -154,12 +154,12 @@ static void level_start(Level *level, GameManager *manager, void *context)
        adjust the player's position n such based on icon count
        the more icons to draw, the slower the player moves
        so we'll increase the player's speed as the icon count increases
-       by 0.1 for every 10 icons
+       by 0.1 for every 8 icons
    */
     game_context->icon_offset = 0;
     if (!game_context->imu_present)
     {
-        game_context->icon_offset += ((game_context->icon_count / 10) / 10);
+        game_context->icon_offset += ((game_context->icon_count / 8) / 10);
     }
     player_spawn(level, manager);
 }

+ 3 - 1
game/player.c

@@ -3,6 +3,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <math.h>
+#include <engine/entity_i.h>
 /****** Entities: Player ******/
 static Level *next_level(GameManager *manager)
 {
@@ -161,7 +162,7 @@ void player_spawn(Level *level, GameManager *manager)
 
 static int vgm_increase(float value, float increase)
 {
-    const int val = abs((int)(round(value + increase) / (double)1.5));
+    const int val = abs((int)(round(value + increase) / 2));
     return val < 1 ? 1 : val;
 }
 
@@ -205,6 +206,7 @@ static void player_update(Entity *self, GameManager *manager, void *context)
     PlayerContext *player = (PlayerContext *)context;
     InputState input = game_manager_input_get(manager);
     Vector pos = entity_pos_get(self);
+    player->old_position = pos;
     GameContext *game_context = game_manager_game_context_get(manager);
 
     // Store previous direction

+ 1 - 0
game/player.h

@@ -27,6 +27,7 @@ typedef enum
 
 typedef struct
 {
+    Vector old_position;        // previous position of the player
     PlayerDirection direction;  // direction the player is facing
     PlayerState state;          // current state of the player
     Vector start_position;      // starting position of the player

+ 8 - 0
jsmn/jsmn_h.h

@@ -4,6 +4,14 @@
 #include <string.h>
 #include <stdlib.h>
 #include <stdio.h>
+// added by Derek Jamison to lower memory usage
+#undef FURI_LOG_E
+#define FURI_LOG_E(tag, msg, ...)
+
+#undef FURI_LOG_I
+#define FURI_LOG_I(tag, msg, ...)
+//
+
 typedef enum
 {
     JSMN_UNDEFINED = 0,

+ 7 - 0
text_input/uart_text_input.c

@@ -4,6 +4,13 @@
 #include <gui/elements.h>
 #include "flip_world_icons.h"
 #include <furi.h>
+// added by Derek Jamison to lower memory usage
+#undef FURI_LOG_E
+#define FURI_LOG_E(tag, msg, ...)
+
+#undef FURI_LOG_I
+#define FURI_LOG_I(tag, msg, ...)
+//
 
 struct UART_TextInput
 {