From b73ba2cf0eee457b9dad64cd1bb3fa7063caac97 Mon Sep 17 00:00:00 2001 From: Evan Pratten Date: Sat, 24 Apr 2021 14:10:49 -0400 Subject: [PATCH] the cave renders --- src/logic/ingame/mod.rs | 7 +++++-- src/logic/ingame/playerlogic.rs | 9 ++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/logic/ingame/mod.rs b/src/logic/ingame/mod.rs index e311944..910faa7 100644 --- a/src/logic/ingame/mod.rs +++ b/src/logic/ingame/mod.rs @@ -36,7 +36,7 @@ impl InGameScreen { height: game_core.resources.cave_mid_layer.height as f32, }; let world_bounds = Rectangle { - x: -100.0, + x: -200.0, y: -100.0, width: game_core.resources.cave_mid_layer.width as f32, height: game_core.resources.cave_mid_layer.height as f32, @@ -49,7 +49,10 @@ impl InGameScreen { context_2d.draw_texture_rec( &game_core.resources.cave_mid_layer, source_bounds, - Vector2::zero(), + Vector2 { + x: world_bounds.x, + y: world_bounds.y + }, Color::WHITE, ); } diff --git a/src/logic/ingame/playerlogic.rs b/src/logic/ingame/playerlogic.rs index 1460984..ff7855f 100644 --- a/src/logic/ingame/playerlogic.rs +++ b/src/logic/ingame/playerlogic.rs @@ -142,9 +142,16 @@ pub fn update_player_movement( draw_handle.get_world_to_screen2D(game_core.player.position, game_core.master_camera); // Camera only moves if you get close to the edge of the screen - if player_screen_position.distance_to(window_center).abs() > (window_center.y - 40.0) { + if player_screen_position.distance_to(window_center).abs() > 100.0 { game_core.master_camera.target += player_real_movement; } + + // // Clamp camera target y to 0 + // if game_core.master_camera.target.y < -100.0 { + // game_core.master_camera.target.y = -100.0; + // } + + } pub fn render_player(context_2d: &mut RaylibMode2D, game_core: &mut GameCore) {