movement and input handlin (delta time based distance still needed though)

This commit is contained in:
Morrígan 2025-06-26 22:19:33 +02:00
parent 8babb48fd2
commit 22d1469b0f
Signed by: morrigan
GPG key ID: CACB010F463A77D0
3 changed files with 33 additions and 13 deletions

20
movement.odin Normal file
View file

@ -0,0 +1,20 @@
package main
import "core:fmt"
import "vendor:sdl3"
HandleInput :: proc(game: ^Game, event: sdl3.Event) {
effect := event.type == sdl3.EventType.KEY_DOWN ? true : false
game.input_state[event.key.scancode] = effect
}
MovePlayer :: proc(game: ^Game) {
x: f32 = game.input_state[sdl3.Scancode.W] ? 1 : 0
x = game.input_state[sdl3.Scancode.S] ? -1 : 0
y: f32 = game.input_state[sdl3.Scancode.A] ? 1 : 0
y = game.input_state[sdl3.Scancode.D] ? -1 : 0
fmt.println(x, y)
game.player.position.y += y
game.player.position.x += x
}