diff --git a/game/game b/game/game index 4cd8bc7..00ad5e3 100755 Binary files a/game/game and b/game/game differ diff --git a/game/game.odin b/game/game.odin index f4d1c12..db07bab 100644 --- a/game/game.odin +++ b/game/game.odin @@ -25,13 +25,14 @@ main :: proc() { rl.SetTargetFPS(60) player = { - position = {CELL_SIZE * 10, CELL_SIZE * 10}, + position = {CELL_SIZE * 0, CELL_SIZE * 0}, camera = { zoom = 4, target = {player.position.x + (CELL_SIZE / 2), player.position.y + (CELL_SIZE / 2)}, offset = {f32(rl.GetScreenWidth()) / 2, f32(rl.GetScreenHeight()) / 2}, }, mode = .INTERACT, + speed = 1, } load_tilemap() diff --git a/game/player.odin b/game/player.odin index 284b920..e78f943 100644 --- a/game/player.odin +++ b/game/player.odin @@ -11,6 +11,7 @@ Player :: struct { move_timer: f32, mode: InteractMode, camera: rl.Camera2D, + speed:f32 } InteractMode :: enum { @@ -76,13 +77,23 @@ player_update_chunks :: proc(p: ^Player, w: ^World) { @(private="file") handle_player_input :: proc(p:^Player, w:^World) { + + current_tile := get_world_tile(w, vec2_to_vec2i(get_player_grid_position(p))) // Movement dt := rl.GetFrameTime() - move_delay : f32 = 0.0 + move_delay : f32 = 0.2 / p.speed if p.move_timer > 0 { p.move_timer -= dt } + + + if current_tile.type == .WATER { + p.speed = 0.3 + } + else { + p.speed = 1 + } if p.move_timer <= 0 { current_pos := get_player_grid_position(p) @@ -208,7 +219,7 @@ draw_player :: proc(player:^Player) { will_collide :: proc(direction:InteractDirection, p:^Player, w:^World) -> bool { tile, pos := get_tile_in_direction(direction, p, w) - // if tile.type == .SOLID { return true } + if tile.type == .SOLID { return true } return false }