23 lines
650 B
Odin
23 lines
650 B
Odin
package main
|
|
|
|
import "core:fmt"
|
|
import "util"
|
|
import "vendor:sdl3"
|
|
|
|
handle_input :: proc(game: ^Game, event: sdl3.Event) {
|
|
effect := event.type == sdl3.EventType.KEY_DOWN ? true : false
|
|
game.input_state[event.key.scancode] = effect
|
|
}
|
|
|
|
move_player :: proc(game: ^Game) {
|
|
speed := game.player.speed
|
|
|
|
y: f32 = game.input_state[sdl3.Scancode.W] ? -speed : 0
|
|
y += game.input_state[sdl3.Scancode.S] ? speed : 0
|
|
x: f32 = game.input_state[sdl3.Scancode.A] ? -speed : 0
|
|
x += game.input_state[sdl3.Scancode.D] ? speed : 0
|
|
game.player.velocity = util.Velocity{x, y}
|
|
|
|
game.player.position.y += y * game.delta
|
|
game.player.position.x += x * game.delta
|
|
}
|