File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed
Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change 3131 state GameState = .play
3232 tile_format TileFormat = .normal
3333 moves int
34+ updates u64
3435
3536 is_ai_mode bool
3637 ai_fpm u64 = 8
@@ -956,14 +957,23 @@ fn on_event(e &gg.Event, mut app App) {
956957}
957958
958959fn 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+ }
959966 app.gg.begin ()
960- app.update_tickers ()
967+ if do_update {
968+ app.update_tickers ()
969+ }
961970 app.draw ()
962971 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 {
964974 app.ai_move ()
965975 }
966- if app.gg.frame % 120 == 0 {
976+ if app.updates % 120 == 0 {
967977 // do GC once per 2 seconds
968978 // eprintln('> gc_memory_use: ${gc_memory_use()}')
969979 if gc_is_enabled () {
You can’t perform that action at this time.
0 commit comments