diff options
| author | arngo <[email protected]> | 2023-05-30 02:00:19 -0400 |
|---|---|---|
| committer | arngo <[email protected]> | 2023-05-30 02:00:19 -0400 |
| commit | 16700c6660d2a3d06792a4f3177c1b28d5d3a573 (patch) | |
| tree | ece65ad1465f85b28ace07f40295a1ada1743091 | |
| parent | d949d6604d574a2c50e74b7f3652147280e7a43a (diff) | |
| download | TOJam2023-16700c6660d2a3d06792a4f3177c1b28d5d3a573.tar.gz TOJam2023-16700c6660d2a3d06792a4f3177c1b28d5d3a573.zip | |
teleporting fixed but player can go through walls a bit
| -rw-r--r-- | src/enemies.c | 8 | ||||
| -rw-r--r-- | src/main.c | 7 | ||||
| -rw-r--r-- | src/player.c | 11 | ||||
| -rw-r--r-- | src/wall.c | 12 |
4 files changed, 22 insertions, 16 deletions
diff --git a/src/enemies.c b/src/enemies.c index 179c6a5..74bd0c5 100644 --- a/src/enemies.c +++ b/src/enemies.c @@ -171,9 +171,9 @@ move_enemies(void) { continue; } - enemy->x += enemy->dx; + enemy->x += enemy->dx * rodeo_frame_time_get() / (1000.0f/60.0f); enemy->dx = 0; - enemy->y += enemy->dy; + enemy->y += enemy->dy * rodeo_frame_time_get() / (1000.0f/60.0f); enemy->dy = 0; } c_foreach(i, cvec_enemy_t, ghosts) { @@ -182,9 +182,9 @@ move_enemies(void) { continue; } - enemy->x += enemy->dx; + enemy->x += enemy->dx * rodeo_frame_time_get() / (1000.0f/60.0f); enemy->dx = 0; - enemy->y += enemy->dy; + enemy->y += enemy->dy * rodeo_frame_time_get() / (1000.0f/60.0f); enemy->dy = 0; } } @@ -58,7 +58,7 @@ main_loop(void) draw_hp_bar(); detect_bullet_enemy_collisions(); detect_bullet_wall_collisions(); - detect_player_enemy_collisions(); + //detect_player_enemy_collisions(); detect_player_wall_collisions(); detect_enemy_wall_collisions(); @@ -125,7 +125,10 @@ main(void) { wall_init_do() { - spawn_enemy(764.0f+73.0f,500.0f); + spawn_enemy(400.0f,700.0f); + spawn_enemy(900.0f,700.0f); + spawn_enemy(400.0f,100.0f); + spawn_enemy(900.0f,100.0f); rodeo_mainLoop_run( main_loop ); diff --git a/src/player.c b/src/player.c index 3f0b100..ae85b65 100644 --- a/src/player.c +++ b/src/player.c @@ -55,8 +55,8 @@ init_player(void) player.collision_id = rodeo_collision_2d_world_item_create( &player_collision_world, (rodeo_collision_2d_world_item_t){ - .x = 1600/3, - .y = 900/3, + .x = 1600/2, + .y = 900/2, .width = orc_size[0], .height = orc_size[1] } @@ -162,6 +162,7 @@ parse_player_input(void) void move_player(void) { + /* if(player.move_state != mv_state_standing) { player.sprite.iter += 1; @@ -179,10 +180,12 @@ move_player(void) { rodeo_audio_sound_play(bubbles_sound); } + */ + player.move_state = mv_state_mid_air; 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->x += player_position->dx * rodeo_frame_time_get() / (1000.0f/60.0f) * ((60.0f - (float)player.sprite.iter) / 60.0f); player_position->dx = 0; - player_position->y += player_position->dy * ((60.0f - (float)player.sprite.iter) / 60.0f); + player_position->y += player_position->dy * rodeo_frame_time_get() / (1000.0f/60.0f) * ((60.0f - (float)player.sprite.iter) / 60.0f); player_position->dy = 0; update_aim_position(); } @@ -97,18 +97,18 @@ moving_wall_resolver( { rodeo_collision_2d_world_item_t *p = obj_collision; rodeo_collision_2d_world_item_t *w = wall_collision; - rodeo_rectangle_t step = (rodeo_rectangle_t){ - .x = p->x + p->dx * rodeo_frame_time_get(), - .y = p->y + p->dy * rodeo_frame_time_get(), + rodeo_collision_2d_world_item_t step = (rodeo_collision_2d_world_item_t){ + .x = p->x + p->dx * rodeo_frame_time_get() / (1000.0f/60.0f), + .y = p->y + p->dy * rodeo_frame_time_get() / (1000.0f/60.0f), .width = p->width, .height = p->height }; - rodeo_rectangle_t intersection = rodeo_collision_2d_get_collision_rect(p, w); + rodeo_rectangle_t intersection = rodeo_collision_2d_get_collision_rect(&step, w); // left collision if (intersection.width < intersection.height) { // colliding left/right // if x equal push right - if (intersection.x >= step.x) { + if (intersection.x == step.x) { p->x = w->x + w->width; if (p->dx < 0) { p->dx = 0; @@ -124,7 +124,7 @@ moving_wall_resolver( else if (intersection.height < intersection.width) { // colliding up/down // if y equal push down - if (intersection.y >= step.y) { + if (intersection.y == step.y) { p->y = w->y + w->height; if (p->dy < 0) { p->dy = 0; |
