mirror of
https://github.com/vlang/v.git
synced 2025-09-13 14:32:26 +03:00
gg,examples: use a timer to limit the rate of updates in breakout, instead of a separate thread, restore ability to run in a browser through emscripten
This commit is contained in:
parent
77a9e6e1b8
commit
2860152e82
2 changed files with 8 additions and 10 deletions
|
@ -2,7 +2,6 @@ import gg
|
|||
import gx
|
||||
import math
|
||||
import rand
|
||||
import time
|
||||
import sokol.audio
|
||||
import os.asset
|
||||
import sokol.sgl
|
||||
|
@ -295,16 +294,12 @@ fn main() {
|
|||
width: g.width
|
||||
height: g.height
|
||||
window_title: 'V Breakout'
|
||||
sample_count: 2
|
||||
init_fn: fn (mut g Game) {
|
||||
spawn fn (mut g Game) {
|
||||
for {
|
||||
g.update()
|
||||
time.sleep(16666 * time.microsecond)
|
||||
}
|
||||
}(mut g)
|
||||
}
|
||||
frame_fn: fn (mut g Game) {
|
||||
dt := g.ctx.timer.elapsed().milliseconds()
|
||||
if dt > 15 {
|
||||
g.update()
|
||||
g.ctx.timer.restart()
|
||||
}
|
||||
g.draw()
|
||||
}
|
||||
click_fn: fn (x f32, y f32, btn gg.MouseButton, mut g Game) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue