Skip to content

Commit 77a9e6e

Browse files
committed
examples: run the update method of breakout on its own frame independent rate
1 parent 0210567 commit 77a9e6e

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

examples/breakout/breakout.v

+9-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import gg
22
import gx
33
import math
44
import rand
5+
import time
56
import sokol.audio
67
import os.asset
78
import sokol.sgl
@@ -295,8 +296,15 @@ fn main() {
295296
height: g.height
296297
window_title: 'V Breakout'
297298
sample_count: 2
299+
init_fn: fn (mut g Game) {
300+
spawn fn (mut g Game) {
301+
for {
302+
g.update()
303+
time.sleep(16666 * time.microsecond)
304+
}
305+
}(mut g)
306+
}
298307
frame_fn: fn (mut g Game) {
299-
g.update()
300308
g.draw()
301309
}
302310
click_fn: fn (x f32, y f32, btn gg.MouseButton, mut g Game) {

0 commit comments

Comments
 (0)