瀏覽代碼

Delay between bullet firing.

antirez 3 年之前
父節點
當前提交
6f7abf0b09
共有 1 個文件被更改,包括 6 次插入1 次删除
  1. 6 1
      app.c

+ 6 - 1
app.c

@@ -535,7 +535,12 @@ void game_tick(void *ctx) {
      * asteroids_update_keypress_state() since depends on exact
      * pressure timing. */
     if (app->fire) {
-        ship_fire_bullet(app);
+        uint32_t bullet_min_period = 200; // In milliseconds
+        uint32_t now = furi_get_tick();
+        if (now - app->last_bullet_tick >= bullet_min_period) {
+            ship_fire_bullet(app);
+            app->last_bullet_tick = now;
+        }
         app->fire = false;
     }