1
0
Fork 0

auts: minor

This commit is contained in:
coaljoe 2020-08-20 06:51:24 +03:00
parent e4f0d0c988
commit f120408745
2 changed files with 43 additions and 4 deletions

View File

@ -67,14 +67,43 @@ fn (mut a App) init(w, h int, title string) {
println("app init done")
}
fn (mut a App) step() {
fn (mut a App) step() bool {
println("app step()")
a.dt = f32(20.0)
mut should_close := false
//for {
//evt := SDL_Event{}
evt := vsdl2.Event{}
for 0 < vsdl2.poll_event(&evt) {
match int(evt.@type) {
C.SDL_QUIT { should_close = true }
C.SDL_KEYDOWN {
key := evt.key.keysym.sym
if key == C.SDLK_ESCAPE || key == C.SDLK_q {
should_close = true
break
}
}
else {}
}
}
//}
if should_close {
//pp(2)
return false
}
//a.render()
a.update(a.dt)
return true
}
fn (mut a App) flip() {
@ -83,6 +112,14 @@ fn (mut a App) flip() {
C.SDL_RenderPresent(a.renderer)
}
fn (mut a App) quit() {
println("app quit()")
//C.SDL_DestroyRenderer(a.renderer)
C.SDL_DestroyWindow(a.window)
C.SDL_Quit()
}
fn (mut a App) update(dt f32) {
}

View File

@ -26,8 +26,8 @@ fn main() {
tex := d.load_image_tex("res/images/heightmap.png")
for {
app.step()
for app.step() {
//app.step()
d.clear()
@ -38,7 +38,9 @@ fn main() {
//time.sleep_ms(20)
time.sleep_ms(200)
//pp(2)
}
}
app.quit()
println("done")
}