Implement type-safe input handling

This commit is contained in:
Riyyi
2026-09-12 15:08:50 +02:00
parent 90602ff1ff
commit f1028acb10
8 changed files with 301 additions and 28 deletions
+7 -1
View File
@@ -1,5 +1,6 @@
package game
import "sindri:input"
import "core:time"
import "core:fmt"
@@ -8,6 +9,7 @@ import "sindri:core"
// -----------------------------------------
Game_Memory :: struct {
should_close: bool
}
g: ^Game_Memory
@@ -64,6 +66,10 @@ init :: proc() {
@(export)
update :: proc(dt: f32) {
fmt.println("dt:", dt)
if input.key_state(.Key_Escape) == .Press {
g.should_close = true
}
}
@(export)
@@ -79,7 +85,7 @@ should_close :: proc() -> bool {
seconds := time.duration_seconds(elapsed)
if seconds > 4 do return true
return false
return g.should_close
}
@(export)