Init
This commit is contained in:
39
game/player.odin
Normal file
39
game/player.odin
Normal file
@@ -0,0 +1,39 @@
|
||||
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.WHITE)
|
||||
}
|
||||
Reference in New Issue
Block a user