`(kakko ,man)

Find a guide into tomorrow by taking lessons from the past

Lisp Game Programming <Step10-1>

 enemy-shot-listに格納されているenemy-shotの移動のためのプログラム

stateが1(alive)の時に移動するが、画面の外にでたらstateを0に設定

;; Step10 <Move Enemy Shot>
;; -----------------------------------------------------------------------------------------------
(defgeneric Move-enemy-shot (foe))

(defmethod Move-enemy-shot (foe)
  "enemy shot move"
  (dolist (enemy-shot (enemy-shot-list foe))
  (when (= (state enemy-shot) 1) ; if enemy-shot state is alive, it can move 
    (incf (x enemy-shot) (dx enemy-shot))
    (incf (y enemy-shot) (dy enemy-shot))
    (when (or (< (x enemy-shot) -16)
                     (> (x enemy-shot) *graphic-width*)
                     (< (y enemy-shot) -16)
                     (> (y enemy-shot) *graphic-height*))
      (setf (state enemy-shot) 0)))))