From d949d6604d574a2c50e74b7f3652147280e7a43a Mon Sep 17 00:00:00 2001 From: arngo <27396817+arngo@users.noreply.github.com> Date: Tue, 30 May 2023 00:57:52 -0400 Subject: trying to fix enemy teleporting but idk --- src/main.c | 7 ++++--- src/wall.c | 13 +++++++++++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/main.c b/src/main.c index 4a08439..82f5199 100644 --- a/src/main.c +++ b/src/main.c @@ -44,9 +44,9 @@ main_loop(void) rodeo_audio_music_stop_fadeOut(1000); } - player_shoot(get_player_bullet_world()); - enemies_attempt_weapon_fire(); - attempt_random_enemy_spawn((rodeo_rectangle_t){ 0, 0, window_width, window_height }); + //player_shoot(get_player_bullet_world()); + //enemies_attempt_weapon_fire(); + //attempt_random_enemy_spawn((rodeo_rectangle_t){ 0, 0, window_width, window_height }); move_bullets(); move_enemies(); @@ -125,6 +125,7 @@ main(void) { wall_init_do() { + spawn_enemy(764.0f+73.0f,500.0f); rodeo_mainLoop_run( main_loop ); diff --git a/src/wall.c b/src/wall.c index 56cda7f..d62e331 100644 --- a/src/wall.c +++ b/src/wall.c @@ -104,12 +104,16 @@ moving_wall_resolver( .height = p->height }; rodeo_rectangle_t intersection = rodeo_collision_2d_get_collision_rect(p, w); + // left collision if (intersection.width < intersection.height) { - if (intersection.x == step.x) { + // colliding left/right + // if x equal push right + if (intersection.x >= step.x) { p->x = w->x + w->width; if (p->dx < 0) { p->dx = 0; } + // else push left } else { p->x = w->x - p->width; if (p->dx > 0) { @@ -118,11 +122,14 @@ moving_wall_resolver( } } else if (intersection.height < intersection.width) { - if (intersection.y == step.y) { + // colliding up/down + // if y equal push down + if (intersection.y >= step.y) { p->y = w->y + w->height; if (p->dy < 0) { p->dy = 0; } + // else push up } else { p->y = w->y - p->height; if (p->dy > 0) { @@ -130,6 +137,8 @@ moving_wall_resolver( } } } + // tunneled into a hitbox + // don't allow movement else if (p->width == w->width && p->height == w->height) { p->dx = 0; p->dy = 0; -- cgit v1.2.3