summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorarngo <[email protected]>2023-05-28 16:47:46 -0400
committerarngo <[email protected]>2023-05-28 16:47:46 -0400
commit2367040ec37ef501446b530c0c5d51863b381627 (patch)
tree9f5fe4132f42a6eaa7754c98797eda4021738017
parent5917762411f9f2c1eb052fbebb712937bc49c6cc (diff)
downloadrodeo_sample_game-2367040ec37ef501446b530c0c5d51863b381627.tar.gz
rodeo_sample_game-2367040ec37ef501446b530c0c5d51863b381627.zip
level walls and assets
-rw-r--r--assets/floor.pngbin0 -> 147486 bytes
-rw-r--r--assets/walls.pngbin0 -> 203132 bytes
-rw-r--r--src/main.c8
-rw-r--r--src/wall.c40
-rw-r--r--src/wall.h3
5 files changed, 47 insertions, 4 deletions
diff --git a/assets/floor.png b/assets/floor.png
new file mode 100644
index 0000000..e400264
--- /dev/null
+++ b/assets/floor.png
Binary files differ
diff --git a/assets/walls.png b/assets/walls.png
new file mode 100644
index 0000000..f263bd1
--- /dev/null
+++ b/assets/walls.png
Binary files differ
diff --git a/src/main.c b/src/main.c
index 09902fc..2024eb9 100644
--- a/src/main.c
+++ b/src/main.c
@@ -51,6 +51,7 @@ main_loop(void)
move_bullets();
move_enemies();
group_follow_target(get_player_position());
+ draw_level();
draw_bullets();
draw_player();
draw_enemies();
@@ -101,6 +102,8 @@ main(void)
rodeo_logLevel_error,
"Testing error log level... It seems to work!"
);
+
+
mrodeo_window_do(window_height, window_width, cstr_lit("Rodeo Window"))
{
renderer = rodeo_renderer_name_get();
@@ -113,10 +116,7 @@ main(void)
init_player();
init_enemies();
init_wall();
- new_wall(0, -10, window_width, 10);
- new_wall(0, window_height, window_width, 10);
- new_wall(-10, 0, 10, window_height);
- new_wall(window_width, 0, 10, window_height);
+
rodeo_mainLoop_run(
main_loop
diff --git a/src/wall.c b/src/wall.c
index 5a2d6df..38010bf 100644
--- a/src/wall.c
+++ b/src/wall.c
@@ -1,11 +1,42 @@
#include "wall.h"
+#include "rodeo.h"
static rodeo_collision_2d_world_t collision_wall_world;
+rodeo_texture_2d_t wall_texture;
+rodeo_texture_2d_t floor_texture;
void
init_wall(void)
{
+ wall_texture = rodeo_texture_2d_create_from_path(cstr_lit("assets/walls.png"));
+ floor_texture = rodeo_texture_2d_create_from_path(cstr_lit("assets/floor.png"));
+ uint16_t window_width = 1600;
+ uint16_t window_height = 900;
collision_wall_world = rodeo_collision_2d_world_create();
+ float walls[][4] = {
+ {0, -10, window_width, 10},
+ {0, window_height, window_width, 10},
+ {-10, 0, 10, window_height},
+ {window_width, 0, 10, window_height},
+ {169,105,72,263},
+ {241,105,191,73},
+ {1169,105,262,72},
+ {1359,177,72,190},
+ {1169,723,262,72},
+ {1359,533,72,190},
+ {169,533,72,262},
+ {241,723,191,72},
+ {764,200,72,500},
+ {550,414,501,72}
+ };
+ int numwalls = sizeof(walls)/sizeof(walls[0]);
+ new_wall(0, -10, window_width, 10);
+ new_wall(0, window_height, window_width, 10);
+ new_wall(-10, 0, 10, window_height);
+ new_wall(window_width, 0, 10, window_height);
+ for (int i = 0; i < numwalls; ++i) {
+ new_wall(walls[i][0], walls[i][1], walls[i][2], walls[i][3]);
+ }
}
void
@@ -53,3 +84,12 @@ coords_inside_wall(
}
return false;
}
+
+void
+draw_level(void)
+{
+ rodeo_rectangle_t rect = (rodeo_rectangle_t){0,0,1600,900};
+ rodeo_texture_2d_draw(&rect, &rect, NULL, &wall_texture);
+ rodeo_texture_2d_draw(&rect, &rect, NULL, &floor_texture);
+
+}
diff --git a/src/wall.h b/src/wall.h
index 6e3dc48..684c595 100644
--- a/src/wall.h
+++ b/src/wall.h
@@ -22,3 +22,6 @@ coords_inside_wall(
float x,
float y
);
+
+void
+draw_level(void);