File tree 1 file changed +13
-3
lines changed
1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change 31
31
state GameState = .play
32
32
tile_format TileFormat = .normal
33
33
moves int
34
+ updates u64
34
35
35
36
is_ai_mode bool
36
37
ai_fpm u64 = 8
@@ -956,14 +957,23 @@ fn on_event(e &gg.Event, mut app App) {
956
957
}
957
958
958
959
fn frame (mut app App) {
960
+ mut do_update := false
961
+ if app.gg.timer.elapsed ().milliseconds () > 15 {
962
+ app.gg.timer.restart ()
963
+ do_update = true
964
+ app.updates++
965
+ }
959
966
app.gg.begin ()
960
- app.update_tickers ()
967
+ if do_update {
968
+ app.update_tickers ()
969
+ }
961
970
app.draw ()
962
971
app.gg.end ()
963
- if app.is_ai_mode && app.state in [.play, .freeplay] && app.gg.frame % app.ai_fpm == 0 {
972
+ if do_update && app.is_ai_mode && app.state in [.play, .freeplay]
973
+ && app.updates % app.ai_fpm == 0 {
964
974
app.ai_move ()
965
975
}
966
- if app.gg.frame % 120 == 0 {
976
+ if app.updates % 120 == 0 {
967
977
// do GC once per 2 seconds
968
978
// eprintln('> gc_memory_use: ${gc_memory_use()}')
969
979
if gc_is_enabled () {
You can’t perform that action at this time.
0 commit comments