Просмотр исходного кода

Update draw and start tree world

jblanked 1 год назад
Родитель
Сommit
13a8f92812
4 измененных файлов с 74 добавлено и 6 удалено
  1. 68 4
      draw/world.c
  2. 2 1
      draw/world.h
  3. 2 0
      flip_world.h
  4. 2 1
      game.c

+ 68 - 4
draw/world.c

@@ -1,6 +1,13 @@
 #include <draw/world.h>
 #include <draw/world.h>
 
 
-void draw_world_example(Canvas *canvas)
+static void draw_bounds(Canvas *canvas)
+{
+    // Draw the outer bounds adjusted by camera offset
+    // we draw this last to ensure users can see the bounds
+    canvas_draw_frame(canvas, -camera_x, -camera_y, WORLD_WIDTH, WORLD_HEIGHT);
+}
+
+void draw_example_world(Canvas *canvas)
 {
 {
     // Draw other elements adjusted by camera offset
     // Draw other elements adjusted by camera offset
     // Static Dot at (72, 40)
     // Static Dot at (72, 40)
@@ -33,7 +40,64 @@ void draw_world_example(Canvas *canvas)
     // tree world
     // tree world
     draw_icon_half_world(canvas, true, &I_icon_tree);
     draw_icon_half_world(canvas, true, &I_icon_tree);
 
 
-    // Draw the outer bounds adjusted by camera offset
-    // we draw this last to ensure users can see the bounds
-    canvas_draw_frame(canvas, -camera_x, -camera_y, WORLD_WIDTH, WORLD_HEIGHT);
+    // Draw the bounds
+    draw_bounds(canvas);
+}
+
+void draw_tree_world(Canvas *canvas)
+{
+    // two full left/up tree lines
+    for (int i = 0; i < 2; i++)
+    {
+        draw_icon_line(canvas, (Vector){5, 2 + i * 17}, 22, true, &I_icon_tree);  // horizontal
+        draw_icon_line(canvas, (Vector){5 + i * 17, 2}, 11, false, &I_icon_tree); // vertical
+    }
+
+    // two full down tree lines
+    for (int i = 9; i < 11; i++)
+    {
+        draw_icon_line(canvas, (Vector){5, 2 + i * 17}, 22, true, &I_icon_tree); // horizontal
+    }
+    // two full right tree lines
+    for (int i = 20; i < 22; i++)
+    {
+        draw_icon_line(canvas, (Vector){5 + i * 17, 50}, 8, false, &I_icon_tree); // vertical
+    }
+
+    // draw labyinth line-by-line
+
+    // third line (14 left, 3 middle, 0 right) - exit line
+    draw_icon_line(canvas, (Vector){5, 2 + 2 * 17}, 14, true, &I_icon_tree);          // 14 left
+    draw_icon_line(canvas, (Vector){5 + 16 * 17, 2 + 2 * 17}, 3, true, &I_icon_tree); // 3 middle
+
+    // fourth line (3 left, 6 middle, 4 right)
+    draw_icon_line(canvas, (Vector){5, 2 + 3 * 17}, 3, true, &I_icon_tree);           // 3 left
+    draw_icon_line(canvas, (Vector){5 + 7 * 17, 2 + 3 * 17}, 6, true, &I_icon_tree);  // 6 middle
+    draw_icon_line(canvas, (Vector){5 + 15 * 17, 2 + 3 * 17}, 4, true, &I_icon_tree); // 4 right
+
+    // fifth line (6 left, 7 middle, 0 right)
+    draw_icon_line(canvas, (Vector){5, 2 + 4 * 17}, 6, true, &I_icon_tree);          // 6 left
+    draw_icon_line(canvas, (Vector){5 + 7 * 17, 2 + 4 * 17}, 7, true, &I_icon_tree); // 7 middle
+
+    // sixth line (5 left, 6 middle, 7 right)
+    draw_icon_line(canvas, (Vector){5, 2 + 5 * 17}, 5, true, &I_icon_tree);           // 5 left
+    draw_icon_line(canvas, (Vector){5 + 7 * 17, 2 + 5 * 17}, 3, true, &I_icon_tree);  // 3 middle
+    draw_icon_line(canvas, (Vector){5 + 15 * 17, 2 + 5 * 17}, 7, true, &I_icon_tree); // 4 right
+
+    // seventh line (0 left, 7 middle, 4 right)
+    draw_icon_line(canvas, (Vector){5 + 6 * 17, 2 + 6 * 17}, 7, true, &I_icon_tree);  // 7 middle
+    draw_icon_line(canvas, (Vector){5 + 14 * 17, 2 + 6 * 17}, 4, true, &I_icon_tree); // 4 right
+
+    // eighth line (4 left, 3 middle, 4 right)
+    draw_icon_line(canvas, (Vector){5, 2 + 7 * 17}, 4, true, &I_icon_tree);           // 4 left
+    draw_icon_line(canvas, (Vector){5 + 7 * 17, 2 + 7 * 17}, 3, true, &I_icon_tree);  // 3 middle
+    draw_icon_line(canvas, (Vector){5 + 15 * 17, 2 + 7 * 17}, 4, true, &I_icon_tree); // 4 right
+
+    // ninth line (3 left, 2 middle, 3 right)
+    draw_icon_line(canvas, (Vector){5, 2 + 8 * 17}, 3, true, &I_icon_tree);           // 3 left
+    draw_icon_line(canvas, (Vector){5 + 5 * 17, 2 + 8 * 17}, 1, true, &I_icon_tree);  // 2 middle
+    draw_icon_line(canvas, (Vector){5 + 11 * 17, 2 + 8 * 17}, 3, true, &I_icon_tree); // 3 right
+
+    // Draw the bounds
+    draw_bounds(canvas);
 }
 }

+ 2 - 1
draw/world.h

@@ -1,4 +1,5 @@
 #pragma once
 #pragma once
 #include <draw/draw.h>
 #include <draw/draw.h>
 
 
-void draw_world_example(Canvas *canvas);
+void draw_example_world(Canvas *canvas);
+void draw_tree_world(Canvas *canvas);

+ 2 - 0
flip_world.h

@@ -63,3 +63,5 @@ typedef struct
     char *text_input_temp_buffer;    // Temporary buffer for the text input
     char *text_input_temp_buffer;    // Temporary buffer for the text input
     uint32_t text_input_buffer_size; // Size of the text input buffer
     uint32_t text_input_buffer_size; // Size of the text input buffer
 } FlipWorldApp;
 } FlipWorldApp;
+
+// TODO - Add Download world function and download world pack button

+ 2 - 1
game.c

@@ -54,7 +54,8 @@ static void background_render(Canvas *canvas, Vector pos)
     camera_x = CLAMP(camera_x, WORLD_WIDTH - SCREEN_WIDTH, 0);
     camera_x = CLAMP(camera_x, WORLD_WIDTH - SCREEN_WIDTH, 0);
     camera_y = CLAMP(camera_y, WORLD_HEIGHT - SCREEN_HEIGHT, 0);
     camera_y = CLAMP(camera_y, WORLD_HEIGHT - SCREEN_HEIGHT, 0);
 
 
-    draw_world_example(canvas);
+    // Draw the world
+    draw_tree_world(canvas);
 }
 }
 
 
 /****** Entities: Player ******/
 /****** Entities: Player ******/