summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorarngo <[email protected]>2023-05-30 00:57:52 -0400
committerarngo <[email protected]>2023-05-30 00:57:52 -0400
commitd949d6604d574a2c50e74b7f3652147280e7a43a (patch)
tree2c723e94b57185b21787261daef9e9786d742066
parent013b28a4d78c055cc7073e02856577d5026dd8c8 (diff)
downloadrodeo_sample_game-d949d6604d574a2c50e74b7f3652147280e7a43a.tar.gz
rodeo_sample_game-d949d6604d574a2c50e74b7f3652147280e7a43a.zip
trying to fix enemy teleporting but idk
-rw-r--r--src/main.c7
-rw-r--r--src/wall.c13
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;