読者です 読者をやめる 読者になる 読者になる

`(kakko ,man)

Find a guide into tomorrow by taking lessons from the past

Lisp Game Programming <Step12-2>

step12の2番目はenemyの爆発処理
メインループを16回回ったら、enemyのstateを2(explosion)から0(dead)にする

;; Step12 <Explode enemy>
;; -----------------------------------------------------------------------------------------------
(defvar *enemybom-sound-flag* nil)
(defgeneric Explode-enemy (foe))

(defmethod Explode-enemy (foe)
  "enemy explosion while 16 times loop"
  (dolist (enemy (enemy-list foe))
  (when (= (state enemy) 2)
    (when (eql *enemybom-sound-flag* nil)
      (setf *enemybom-sound-flag* t)
      (Play-sample *enemybom-sound*)) ; enemybom sound
  (incf (explode-cnt enemy) 1)
  (when (= (explode-cnt enemy) 16) ; enemy explode count 16
    (setf (state enemy) 0
            *enemybom-sound-flag* nil)))))