40 lines
739 B
Odin
40 lines
739 B
Odin
package game
|
|
|
|
import rl "vendor:raylib"
|
|
import "core:fmt"
|
|
|
|
Player :: struct {
|
|
position : rl.Vector2,
|
|
}
|
|
|
|
handle_player_input :: proc(p : ^Player) {
|
|
|
|
if rl.IsKeyPressed(.RIGHT) {
|
|
p.position.x += CELL_SIZE
|
|
}
|
|
|
|
if rl.IsKeyPressed(.LEFT) {
|
|
p.position.x -= CELL_SIZE
|
|
}
|
|
|
|
if rl.IsKeyPressed(.UP) {
|
|
p.position.y -= CELL_SIZE
|
|
}
|
|
|
|
if rl.IsKeyPressed(.DOWN) {
|
|
p.position.y += CELL_SIZE
|
|
}
|
|
|
|
}
|
|
|
|
get_player_grid_position :: proc(player:^Player) -> rl.Vector2 {
|
|
grid_pos_x := player.position.x / CELL_SIZE
|
|
grid_pos_y := player.position.y / CELL_SIZE
|
|
|
|
return {grid_pos_x, grid_pos_y}
|
|
}
|
|
|
|
draw_player :: proc(player:^Player) {
|
|
draw_tile({27,0}, player.position, rl.DARKBLUE)
|
|
}
|