Lisp Game Programming <Step16>
Step16はスタンドアローンの実行ファイルの作成
プログラム(common-shooter.lisp)に以下を追加
;;; 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> <------- step16 correct
;; -----------------------------------------------------------------------------------------------
(defpackage :game
(:use :common-lisp :lispbuilder-sdl)
(:nicknames :shooting)
(:export :Common-shooter))
(in-package :game)
・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・
main.lispとして以下のプログラムを作成
main.lisp ⇒
;; Common-Shooter
;;--------------------------
(defun main ()
;; Load SDL
;;--------------------------
(cffi:define-foreign-library sdl
(t (:default "SDL")))
(cffi:use-foreign-library sdl)
;; Run the game
;;--------------------------
(sdl:with-init ()
(game:common-shooter))
;; Quit
;;--------------------------
#+sbcl (sb-ext:exit)
#-sbcl (quit))
EmacsをM-x shellでコマンドラインモードにし、sbclを起動して以下を実行する
(load "c:\\work\\common-shooter.lisp")
(load (compile-file "c:\\work\\main.lisp"))
(sb-ext:save-lisp-and-die "c:\\work\\common-shooter.exe" :toplevel 'main :executable t)
↑
注意)上記はslimeからも実行できるが、直ぐ上のsb-ext:のコードはslimeから実行する
とエラーが発生する 「Cannot save core with multiple threads running」
うまくいくと、バカでかいEXEファイル(47,957KB)ができあがる
実行すると、DOS窓が開きゲーム用ウィンドウが現れてスタートするが、どうもDOS窓(って言うの?)がイケてない
ちなみに、出来上がったEXEファイルのSubsystemをいじってみた
以下を参照
https://gist.github.com/death/6740474
(load "c:\\work\\subsystem-hack")
(subsystem.hack:patch-subsystem "common-shooter.exe" :win-gui)
を実行(当然、必要なnibblesのパッケージを読み込むよう設定)してみたけど、XPだとDOS窓を非表示にできたものの7はできなかったため、OSの違いによるものと思う
うーん、残念