delta time!
This commit is contained in:
parent
22d1469b0f
commit
266adb051e
2 changed files with 22 additions and 8 deletions
|
@ -3,18 +3,19 @@ package main
|
|||
import "core:fmt"
|
||||
import "vendor:sdl3"
|
||||
|
||||
SPEED: f32 : 200
|
||||
|
||||
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
|
||||
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.position.y += y * game.delta
|
||||
game.player.position.x += x * game.delta
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue