player tweaks
This commit is contained in:
parent
2d79747a82
commit
f73f5d4950
@ -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()
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user