`(kakko ,man)

Find a guide into tomorrow by taking lessons from the past

Lisp Game Programming <Step15>

まだネタが残っていたので少々追加

Step15はパッケージ化

パッケージ化が必要かどうかはさておき、これまで作成したSTEP14までのプログラムstep14.lispをcommon-shooter.lispに変更し、common-shooter.asd、package.lispを作成する

まずはpackage.lisp

;;;; package.lisp

 (defpackage :game
 (:use :common-lisp :lispbuilder-sdl)
 (:export :Common-shooter))

 

そしてcommon-shooter.asd ⇒

;;;; common-shooter.asd

(asdf:defsystem :common-shooter
 :version "0.2"
 :description "A remake of The shooter made with HSP"
 :author "tomekame0126"
 :license "GPL v2"
 :depends-on (:lispbuilder-sdl
        :lispbuilder-sdl-ttf
        :lispbuilder-sdl-mixer)
 :serial t
 :components ((:file "package")

          (:file "common-shooter")))

 

 プログラム(common-shooter.lisp)に以下を追加

;;;; The Common-Shooter

;;; step1 <Game Frame>
;;; step2 <Audio>
;;; step3 <Sprite Sheets> <Character Object> <Draw Images> <Initialize>
;;; step4 <Scroll> <Scroll Counter>
;;; step5 <Font> <Score Panel>
;;; step6 <Key State>
;;; step7 <Game Field>
;;; step8 <Shot>
;;; step9 <Move Enemy> <Set Enemy> <Remove Dead Eenemy>
;;; step10 <Move Enemy Shot> <Set Enemy Shot> <Remove Dead Enemy Shot>
;;; step11 <Judge Enemy Shot Hit> <Game Over Message> <Explode Ship> <Revive Ship>
;;; step12 <Judge Shot Hit> <Explode enemy>
;;; step13 <Stage Class> <Stage Start Message>
;;; step14 <Game Start Message>
;;; step15 <Define package>

;; step15 <Define package>
;; -----------------------------------------------------------------------------------------------
 (in-package :game)

 ;; step2 <Audio>
;; -----------------------------------------------------------------------------------------------

 (defparameter *path-shot-sound* "C:\\work\\sound\\tm2_shoot003.wav")

       ・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・

 

 使いかたは以下

CL-USER > (asdf:operate 'asdf:load-op 'common-shooter)

       ・・・・・コンパイル・・・・・

CL-USER> (game:common-shooter)

       ・・・・・ゲーム起動・・・・・

 

注意点としては、sbclrcファイルに以下を記述しておく必要がある

(require :asdf)

(dolist (dir (directory "C:\\Program Files (x86)\\Steel Bank Common Lisp\\1.1.12\\site\\*\\"))
(pushnew dir asdf:*central-registry* :test #'equal))

(dolist (dir (directory "C:\\work\\"))          ;;  <‐ーー追加
 (pushnew dir asdf:*central-registry* :test #'equal))

これは、Windows7の環境下でC:の直下にworkホルダを作ってそこで作業しているためで、人により設定が異なるから、確認が必要だと思う。