mirror of
https://github.com/vlang/v.git
synced 2025-09-13 14:32:26 +03:00
examples: run the update method of breakout on its own frame independent rate
This commit is contained in:
parent
0210567af2
commit
77a9e6e1b8
1 changed files with 9 additions and 1 deletions
|
@ -2,6 +2,7 @@ import gg
|
||||||
import gx
|
import gx
|
||||||
import math
|
import math
|
||||||
import rand
|
import rand
|
||||||
|
import time
|
||||||
import sokol.audio
|
import sokol.audio
|
||||||
import os.asset
|
import os.asset
|
||||||
import sokol.sgl
|
import sokol.sgl
|
||||||
|
@ -295,8 +296,15 @@ fn main() {
|
||||||
height: g.height
|
height: g.height
|
||||||
window_title: 'V Breakout'
|
window_title: 'V Breakout'
|
||||||
sample_count: 2
|
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) {
|
frame_fn: fn (mut g Game) {
|
||||||
g.update()
|
|
||||||
g.draw()
|
g.draw()
|
||||||
}
|
}
|
||||||
click_fn: fn (x f32, y f32, btn gg.MouseButton, mut g Game) {
|
click_fn: fn (x f32, y f32, btn gg.MouseButton, mut g Game) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue