summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorrealtradam <[email protected]>2023-05-28 17:07:37 -0400
committerrealtradam <[email protected]>2023-05-28 17:07:37 -0400
commitb3c02a644b9412f07c95621385488954c5b98dfc (patch)
tree6a33e772a681e772aabb533fa3539a4cb6492d3d
parentf54e3249d5c8fff4f7a64381c6dd7210c81f569a (diff)
parentf9996cb800be544b64dd871d652eeb8c7870edf2 (diff)
downloadrodeo_sample_game-b3c02a644b9412f07c95621385488954c5b98dfc.tar.gz
rodeo_sample_game-b3c02a644b9412f07c95621385488954c5b98dfc.zip
.
-rw-r--r--assets/blowing_bubbles.wavbin0 -> 96710 bytes
-rw-r--r--assets/floor.pngbin0 -> 147486 bytes
-rw-r--r--assets/pop.wavbin0 -> 49412 bytes
-rw-r--r--assets/walls.pngbin0 -> 203132 bytes
-rw-r--r--src/bullet.c4
-rw-r--r--src/main.c8
-rw-r--r--src/player.c7
-rw-r--r--src/player.h3
-rw-r--r--src/wall.c38
-rw-r--r--src/wall.h3
10 files changed, 56 insertions, 7 deletions
diff --git a/assets/blowing_bubbles.wav b/assets/blowing_bubbles.wav
new file mode 100644
index 0000000..635bfa1
--- /dev/null
+++ b/assets/blowing_bubbles.wav
Binary files differ
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/pop.wav b/assets/pop.wav
new file mode 100644
index 0000000..3cef580
--- /dev/null
+++ b/assets/pop.wav
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/bullet.c b/src/bullet.c
index 41264ed..77acaa7 100644
--- a/src/bullet.c
+++ b/src/bullet.c
@@ -6,6 +6,7 @@
#include "rodeo/collision.h"
static rodeo_texture_2d_t bullet_texture;
+static rodeo_audio_sound_t *pop_sound;
//static rodeo_collision_2d_world_t bullet_collision_world;
static rodeo_collision_2d_world_t player_bullet_collision_world = {0};
static rodeo_collision_2d_world_t enemy_bullet_collision_world = {0};
@@ -15,12 +16,14 @@ void
init_bullets(void)
{
bullet_texture = rodeo_texture_2d_create_from_path(cstr_lit("assets/bullet.png"));
+ pop_sound = rodeo_audio_sound_create_from_path(cstr_lit("assets/pop.wav"));
}
void
deinit_bullets(void)
{
rodeo_texture_2d_destroy(&bullet_texture);
+ rodeo_audio_sound_destroy(pop_sound);
}
bullet_t *
@@ -148,6 +151,7 @@ bullet_destroy(
rodeo_collision_2d_world_item_destroy_by_id(bullet->id);
*bullet = *cvec_bullet_t_back(&bullets);
cvec_bullet_t_pop(&bullets);
+ rodeo_audio_sound_play(pop_sound);
}
void bullet_wall_resolver(
diff --git a/src/main.c b/src/main.c
index 89f5086..81e0248 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();
@@ -105,6 +106,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();
@@ -117,10 +120,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/player.c b/src/player.c
index d56b7dc..02c583c 100644
--- a/src/player.c
+++ b/src/player.c
@@ -31,6 +31,7 @@ struct player_t
player = { 0 };
typedef struct player_t player_t;
+static rodeo_audio_sound_t *bubbles_sound;
// 0-19 jumping
// 61 standing
@@ -44,6 +45,7 @@ static float orc_size[] = {13.0f * 2.0f, 19.0f * 2.0f};
void
init_player(void)
{
+ bubbles_sound = rodeo_audio_sound_create_from_path(cstr_lit("assets/blowing_bubbles.wav"));
player.texture = rodeo_texture_2d_create_from_path(cstr_lit("assets/mainblob-128.png"));
player.shadow_texture = rodeo_texture_2d_create_from_path(cstr_lit("assets/blobshadow.png"));
player.aim_texture = rodeo_texture_2d_create_from_path(cstr_lit("assets/aim.png"));
@@ -82,6 +84,7 @@ deinit_player(void)
{
rodeo_texture_2d_destroy(&player.texture);
rodeo_collision_2d_world_destroy(&player_collision_world);
+ rodeo_audio_sound_destroy(bubbles_sound);
}
void
@@ -172,6 +175,10 @@ move_player(void)
{
player.move_state = mv_state_standing;
}
+ if(player.sprite.iter == 1)
+ {
+ rodeo_audio_sound_play(bubbles_sound);
+ }
cvec_collision_2d_world_item_value *player_position = rodeo_collision_2d_world_item_get_by_id(player.collision_id);
player_position->x += player_position->dx * ((60.0f - (float)player.sprite.iter) / 60.0f);
player_position->dx = 0;
diff --git a/src/player.h b/src/player.h
index f0614d1..f102b1d 100644
--- a/src/player.h
+++ b/src/player.h
@@ -47,9 +47,6 @@ void
detect_player_enemy_collisions(void);
void
-detect_player_bullet_collisions(void);
-
-void
detect_player_wall_collisions(void);
cvec_collision_2d_world_item_value *
diff --git a/src/wall.c b/src/wall.c
index 1be1a78..d3c9d3f 100644
--- a/src/wall.c
+++ b/src/wall.c
@@ -2,11 +2,41 @@
#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
@@ -102,3 +132,11 @@ moving_wall_resolver(
}
}
+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 2f75fd2..07990fa 100644
--- a/src/wall.h
+++ b/src/wall.h
@@ -28,3 +28,6 @@ moving_wall_resolver(
rodeo_collision_2d_world_item_t *obj_collision,
rodeo_collision_2d_world_item_t *wall_collision
);
+
+void
+draw_level(void);