Skip to content

Commit 3c63bcb

Browse files
committed
Make StarWar game more portable at sbcl-wise / Linux system
Now to play it's only necessary a double click in the launcher. However the user still need have in the your system the follwing softwares: + SBCL + Quicklisp And the following dynamic libraries: + <CFFI:FOREIGN-LIBRARY SDL-MIXER "libSDL_mixer.so"> + <CFFI:FOREIGN-LIBRARY SDL-GFX "libSDL_gfx.so"> + <CFFI:FOREIGN-LIBRARY SDL-TTF "libSDL_ttf-2.0.so.0"> + <CFFI:FOREIGN-LIBRARY SDL-IMAGE "libSDL_image-1.2.so.0"> + <CFFI:FOREIGN-LIBRARY SDL "libSDL-1.2.so.0">
1 parent b81ad36 commit 3c63bcb

File tree

11 files changed

+59
-11
lines changed

11 files changed

+59
-11
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
system-index.txt

StarWar.desktop

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[Desktop Entry]
2+
Version=1.0
3+
Type=Application
4+
Name=StarWar
5+
Comment=A survival and dominance starwar game
6+
Exec=./starwar.lisp
7+
Icon=gcstar
8+
Terminal=false
9+
StartupNotify=false

src/globals.lisp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,12 @@ generateing the map. ")
104104
"read one file and load all the parameters"
105105
;; here, we MUST make sure that we are in the RIGHT package (that is the
106106
;; starwar package. or the parameters will not be set!
107-
(with-open-file (s filename)
107+
(with-open-file (s (portable-pathname filename))
108108
(do ((form (read s) (read s nil 'eof)))
109109
((eq form 'eof) nil)
110110
(if (not (= (length form) 2))
111111
(error "configure file format not right!"))
112-
(setq form (cons 'defparameter form))
112+
(setq form (cons 'defvar form))
113113
(format t "eval: ~a~%" form)
114114
(eval form))))
115115

src/make-binary.lisp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,15 @@
33

44
(in-package :starwar)
55

6+
(defparameter *compression* 9)
7+
8+
(defun dump-binaries ()
9+
(cffi)
10+
)
11+
612
(defun make-binary ()
713
(sb-ext:save-lisp-and-die #+unix "starwar-linux"
814
#+win32 "starwar-win32.exe"
915
:toplevel #'starwar:main
10-
:executable t))
16+
:executable t
17+
:compression compression))

src/packages.lisp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
(defpackage :starwar
33
(:use :cl :starwar-lib)
44
(:documentation "this is the star war game!")
5-
(:export :main :run :make-binary))
5+
(:export :main :run :make-binary :fullscreen))

src/path.lisp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
(in-package :starwar)
2+
3+
(defun portable-pathname (pathname &optional (system 'starwar))
4+
"PORTABLE-PATHNAME consider two possible dirnames: local and system-wide."
5+
(if (probe-file pathname)
6+
pathname
7+
(asdf:system-relative-pathname system pathname)))

src/starwar.lisp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
(setq speed star-speed-max))
7878
(setq star-speed speed))
7979
(setq *news* (format nil "Increase speed to ~ax" star-speed)))
80+
8081
(defun decrease-star-speed ()
8182
(let ((speed (- star-speed 0.5)))
8283
(if (< speed star-speed-min)
@@ -269,7 +270,7 @@ the outter rect. the rect is filled by VALUE/FULL-VALUE"
269270
(set-game-running t)
270271
;; music background
271272
(sdl-mixer:open-audio)
272-
(let ((music (sdl-mixer:load-music "background.mp3")))
273+
(let ((music (sdl-mixer:load-music (portable-pathname "background.mp3"))))
273274
(sdl-mixer:play-music music :loop t)
274275
(sdl:with-events ()
275276
(:quit-event () (sdl-mixer:Halt-Music)

starwar-lib.asd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
(defsystem starwar-lib
77
:name "starwar-lib"
88
:author "Peter Xu"
9-
:version "0.0.1"
9+
:version "0.1.0"
1010
:licence "MIT"
1111
:description "Some basic functions related to game"
1212
:pathname "src/lib/"

starwar.asd

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,20 @@
66
(defsystem starwar
77
:name "starwar"
88
:author "xzpeter"
9-
:version "0.0.1"
9+
:version "0.1.0"
1010
:license "MIT"
1111
:description "A very simple starwar game."
1212
:depends-on (:lispbuilder-sdl
1313
:lispbuilder-sdl-ttf
1414
:lispbuilder-sdl-gfx
1515
:lispbuilder-sdl-mixer
16+
:cffi
1617
:starwar-lib)
1718
:pathname "src"
1819
:components ((:file "packages")
20+
(:file "path")
1921
(:file "make-binary")
20-
(:file "globals" :depends-on ("packages"))
22+
(:file "globals" :depends-on ("packages" "path"))
2123
(:file "hittable-circle" :depends-on ("packages"))
2224
(:file "classes" :depends-on ("packages"
2325
"hittable-circle"))
@@ -34,6 +36,7 @@
3436
"classes"
3537
"globals"))
3638
(:file "starwar" :depends-on ("packages"
39+
"path"
3740
"globals"
3841
"hittable-circle"
3942
"star"

starwar.conf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
;; configuration file for starwar game
22

3-
(fullscreen nil)
4-
(screen-width 1200)
5-
(screen-height 800)
3+
(fullscreen t)
4+
(screen-width 640)
5+
(screen-height 400)
66

77
(star-speed-max 3.0)
88
(star-speed-min 0.5)

0 commit comments

Comments
 (0)