Parcourir la source

Add town world

jblanked il y a 1 an
Parent
commit
32af170ad1
2 fichiers modifiés avec 120 ajouts et 1 suppressions
  1. 119 1
      game/world.c
  2. 1 0
      game/world.h

+ 119 - 1
game/world.c

@@ -72,6 +72,13 @@ bool draw_json_world_furi(Level *level, FuriString *json_data)
         if (!icon || !x || !y || !width || !height || !amount || !horizontal)
         {
             furi_string_free(data);
+            furi_string_free(icon);
+            furi_string_free(x);
+            furi_string_free(y);
+            furi_string_free(width);
+            furi_string_free(height);
+            furi_string_free(amount);
+            furi_string_free(horizontal);
             return false;
         }
         // if amount is less than 2, we spawn a single icon
@@ -182,4 +189,115 @@ void draw_tree_world(Level *level)
     spawn_icon_line(level, get_icon("tree"), 5, 2 + 8 * 17, 16, 16, 3, true);           // 3 left
     spawn_icon_line(level, get_icon("tree"), 5 + 5 * 17, 2 + 8 * 17, 16, 16, 1, true);  // 1 middle
     spawn_icon_line(level, get_icon("tree"), 5 + 11 * 17, 2 + 8 * 17, 16, 16, 3, true); // 3 right
-}
+}
+
+void draw_town_world(Level *level)
+{
+    // house-fence group 1
+    spawn_icon(level, get_icon("house"), 148, 36, 48, 32);
+    spawn_icon(level, get_icon("fence"), 148, 72, 16, 8);
+    spawn_icon(level, get_icon("fence"), 164, 72, 16, 8);
+    spawn_icon(level, get_icon("fence_end"), 180, 72, 16, 8);
+
+    // house-fence group 4 (the left of group 1)
+    spawn_icon(level, get_icon("house"), 96, 36, 48, 32);
+    spawn_icon(level, get_icon("fence"), 96, 72, 16, 8);
+    spawn_icon(level, get_icon("fence"), 110, 72, 16, 8);
+    spawn_icon(level, get_icon("fence_end"), 126, 72, 16, 8);
+
+    // house-fence group 5 (the left of group 4)
+    spawn_icon(level, get_icon("house"), 40, 36, 48, 32);
+    spawn_icon(level, get_icon("fence"), 40, 72, 16, 8);
+    spawn_icon(level, get_icon("fence"), 56, 72, 16, 8);
+    spawn_icon(level, get_icon("fence_end"), 72, 72, 16, 8);
+
+    // line of fences on the 8th row (using spawn_icon_line)
+    spawn_icon_line(level, get_icon("fence"), 8, 100, 16, 8, 10, true);
+
+    // plants spaced out underneath the fences
+    spawn_icon_line(level, get_icon("plant"), 40, 110, 16, 16, 6, true);
+    spawn_icon_line(level, get_icon("flower"), 40, 140, 16, 16, 6, true);
+
+    // man and woman
+    spawn_icon(level, get_icon("man"), 156, 110, 7, 16);
+    spawn_icon(level, get_icon("woman"), 164, 110, 9, 16);
+
+    // lake
+    // Top row
+    spawn_icon(level, get_icon("lake_top_left"), 240, 52, 24, 22);
+    spawn_icon(level, get_icon("lake_top"), 264, 52, 31, 22);
+    spawn_icon(level, get_icon("lake_top_right"), 295, 52, 24, 22);
+
+    // Middle row
+    spawn_icon(level, get_icon("lake_left"), 231, 74, 11, 31);
+    spawn_icon(level, get_icon("lake_right"), 317, 74, 11, 31);
+
+    // Bottom row
+    spawn_icon(level, get_icon("lake_bottom_left"), 240, 105, 24, 22);
+    spawn_icon(level, get_icon("lake_bottom"), 264, 124, 31, 12);
+    spawn_icon(level, get_icon("lake_bottom_right"), 295, 105, 24, 22);
+
+    // Spawn two full left/up tree lines
+    for (int i = 0; i < 2; i++)
+    {
+        // Horizontal line of 22 icons
+        spawn_icon_line(level, get_icon("tree"), 5, 2 + i * 17, 16, 16, 22, true);
+        // Vertical line of 11 icons
+        spawn_icon_line(level, get_icon("tree"), 5 + i * 17, 2, 16, 16, 11, false);
+    }
+
+    // Spawn two full down tree lines
+    for (int i = 9; i < 11; i++)
+    {
+        // Horizontal line of 22 icons
+        spawn_icon_line(level, get_icon("tree"), 5, 2 + i * 17, 16, 16, 22, true);
+    }
+
+    // Spawn two full right tree lines
+    for (int i = 20; i < 22; i++)
+    {
+        // Vertical line of 8 icons starting further down (y=50)
+        spawn_icon_line(level, get_icon("tree"), 5 + i * 17, 50, 16, 16, 8, false);
+    }
+}
+/*
+{
+    "name": "town_world",
+    "author": "JBlanked",
+    "json_data": [
+        { "icon": "house",     "x": 148, "y": 36, "width": 48, "height": 32, "amount": 1, "horizontal": true },
+        { "icon": "fence",     "x": 148, "y": 72, "width": 16, "height": 8,  "amount": 1, "horizontal": true },
+        { "icon": "fence",     "x": 164, "y": 72, "width": 16, "height": 8,  "amount": 1, "horizontal": true },
+        { "icon": "fence_end", "x": 180, "y": 72, "width": 16, "height": 8,  "amount": 1, "horizontal": true },
+        { "icon": "house",     "x": 96,  "y": 36, "width": 48, "height": 32, "amount": 1, "horizontal": true },
+        { "icon": "fence",     "x": 96,  "y": 72, "width": 16, "height": 8,  "amount": 1, "horizontal": true },
+        { "icon": "fence",     "x": 110, "y": 72, "width": 16, "height": 8,  "amount": 1, "horizontal": true },
+        { "icon": "fence_end", "x": 126, "y": 72, "width": 16, "height": 8,  "amount": 1, "horizontal": true },
+        { "icon": "house",     "x": 40,  "y": 36, "width": 48, "height": 32, "amount": 1, "horizontal": true },
+        { "icon": "fence",     "x": 40,  "y": 72, "width": 16, "height": 8,  "amount": 1, "horizontal": true },
+        { "icon": "fence",     "x": 56,  "y": 72, "width": 16, "height": 8,  "amount": 1, "horizontal": true },
+        { "icon": "fence_end", "x": 72,  "y": 72, "width": 16, "height": 8,  "amount": 1, "horizontal": true },
+        { "icon": "fence",  "x": 8,  "y": 100, "width": 16, "height": 8,  "amount": 10, "horizontal": true },
+        { "icon": "plant",  "x": 40, "y": 110, "width": 16, "height": 16, "amount": 6, "horizontal": true },
+        { "icon": "flower", "x": 40, "y": 140, "width": 16, "height": 16, "amount": 6, "horizontal": true },
+        { "icon": "man",    "x": 156, "y": 110, "width": 7,  "height": 16, "amount": 1, "horizontal": true },
+        { "icon": "woman",  "x": 164, "y": 110, "width": 9,  "height": 16, "amount": 1, "horizontal": true },
+        { "icon": "lake_top_left",     "x": 240, "y": 52,  "width": 24, "height": 22, "amount": 1, "horizontal": true },
+        { "icon": "lake_top",          "x": 264, "y": 52,  "width": 31, "height": 22, "amount": 1, "horizontal": true },
+        { "icon": "lake_top_right",    "x": 295, "y": 52,  "width": 24, "height": 22, "amount": 1, "horizontal": true },
+        { "icon": "lake_left",         "x": 231, "y": 74,  "width": 11, "height": 31, "amount": 1, "horizontal": true },
+        { "icon": "lake_right",        "x": 317, "y": 74,  "width": 11, "height": 31, "amount": 1, "horizontal": true },
+        { "icon": "lake_bottom_left",  "x": 240, "y": 105, "width": 24, "height": 22, "amount": 1, "horizontal": true },
+        { "icon": "lake_bottom",       "x": 264, "y": 124, "width": 31, "height": 12, "amount": 1, "horizontal": true },
+        { "icon": "lake_bottom_right", "x": 295, "y": 105, "width": 24, "height": 22, "amount": 1, "horizontal": true },
+        { "icon": "tree", "x": 5,   "y": 2,   "width": 16, "height": 16, "amount": 22, "horizontal": true },
+        { "icon": "tree", "x": 5,   "y": 2,   "width": 16, "height": 16, "amount": 11, "horizontal": false },
+        { "icon": "tree", "x": 22,  "y": 2,   "width": 16, "height": 16, "amount": 22, "horizontal": true },
+        { "icon": "tree", "x": 22,  "y": 2,   "width": 16, "height": 16, "amount": 11, "horizontal": false },
+        { "icon": "tree", "x": 5,   "y": 155, "width": 16, "height": 16, "amount": 22, "horizontal": true },
+        { "icon": "tree", "x": 5,   "y": 172, "width": 16, "height": 16, "amount": 22, "horizontal": true },
+        { "icon": "tree", "x": 345, "y": 50,  "width": 16, "height": 16, "amount": 8,  "horizontal": false },
+        { "icon": "tree", "x": 362, "y": 50,  "width": 16, "height": 16, "amount": 8,  "horizontal": false }
+    ]
+}
+*/

+ 1 - 0
game/world.h

@@ -16,5 +16,6 @@
 void draw_bounds(Canvas *canvas);
 void draw_example_world(Level *level);
 void draw_tree_world(Level *level);
+void draw_town_world(Level *level);
 bool draw_json_world(Level *level, const char *json_data);
 bool draw_json_world_furi(Level *level, FuriString *json_data);