Skip to content

Commit 8c3b3d8

Browse files
committed
Simplify overall file tree, packages and systems
There is a unnecessary complexity on this game has been structured.
1 parent 67963ac commit 8c3b3d8

19 files changed

+91
-61
lines changed

README

Lines changed: 0 additions & 3 deletions
This file was deleted.

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
![game](https://i.imgur.com/QZSerTN.png)
2+
3+
# starwar (from xzpeter)
4+
5+
This is a game written in CL.
6+
7+
You may check the homepage at http://xzpeter.github.com/starwar for more information.
8+
9+
10+
# Fork reason
11+
12+
This is a exploratory fork into the deepness of the CLOS, Common Lisp Object System.
13+
An additional music was integrated made by the band Miami Vice, track
14+
[Synth Colour](https://miamivice.bandcamp.com/track/synth-colour) from Palm Haze album
15+
16+
17+
All the rights are reserved to xzpeter, the original game author and the background
18+
music to the Miami Vice band.

lib/org.xzpeter.game.lib.asd

Lines changed: 0 additions & 15 deletions
This file was deleted.

packages.lisp

Lines changed: 0 additions & 6 deletions
This file was deleted.

classes.lisp renamed to src/classes.lisp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
;; define all the classes in the game
2-
(in-package :org.xzpeter.game.starwar)
2+
(in-package :starwar)
33

44
(defclass star (hittable-circle)
55
((planet :initarg :planet :initform (error "cannot without planet!")
@@ -10,7 +10,7 @@
1010
(vect :initarg :vect :initform #(0.5 0) :accessor vect)
1111
(life :initarg :life :initform star-life-min)
1212
(target :initform nil :accessor target :documentation
13-
"target star to fight with")
13+
"target star to fight with")
1414
(status :initform :idle :accessor status :documentation
1515
"what does the star think now? possble status are:
1616
:idle -- not doing anything now

globals.lisp renamed to src/globals.lisp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
;; variables definitions
2-
(in-package :org.xzpeter.game.starwar)
2+
(in-package :starwar)
33

44
(defparameter *debug-string* "")
55

66
(defvar color-grey (sdl:color :r 80 :g 80 :b 80))
77

88
(defparameter screen-width 800)
9-
(defparameter screen-height 600)
9+
(defparameter screen-height 600)
1010
(defparameter bg-color sdl:*black*)
1111
(defparameter game-frame-color sdl:*white*)
1212

@@ -68,16 +68,16 @@ generateing the map. ")
6868
"how far can a star moves away from its owner")
6969

7070
;; when the mouse moves to the edge of the screen, we should move the screen
71-
;; position on the worldmap.
72-
;; these are the margin place, outside which the moving is activated.
71+
;; position on the worldmap.
72+
;; these are the margin place, outside which the moving is activated.
7373
(defparameter margin-left 10)
7474
(defparameter margin-top 10)
7575

7676
;; defines the background
7777
(defparameter bg-star-size-max 2)
7878
(defparameter bg-star-size-min 1)
7979
(defparameter bg-star-n 50)
80-
80+
8181
(defparameter *star-color-selected* sdl:*yellow*)
8282

8383
(defparameter star-safe-distance 40)
@@ -103,15 +103,15 @@ generateing the map. ")
103103
(defun load-file-set-parameters (filename)
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
106-
;; starwar package. or the parameters will not be set!
106+
;; starwar package. or the parameters will not be set!
107107
(with-open-file (s 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!"))
112112
(setq form (cons 'defparameter form))
113113
(format t "eval: ~a~%" form)
114-
(eval form))))
114+
(eval form))))
115115

116116
(defun auto-generate-planets (amount)
117117
"auto generate planets and normally set the *planet-list* var.
@@ -190,10 +190,10 @@ INIT-AMOUNT is how many planets one player own at the beginning of game"
190190
*bg-stars* (generate-bg-stars bg-star-n)
191191
*planet-list* (planet-sort-by-size
192192
(auto-generate-planets planet-total)))
193-
193+
194194
(setf (player (fifth *planet-list*)) *player1*)
195195
(setf (player (sixth *planet-list*)) *player2*)
196-
196+
197197
;; load all the configure file
198198
(load-file-set-parameters "starwar.conf")
199199

hittable-circle.lisp renamed to src/hittable-circle.lisp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
;; defines the hittable-circle object
2-
(in-package :org.xzpeter.game.starwar)
2+
(in-package :starwar)
33

44
(defclass hittable-circle ()
55
((pos :initarg :pos :initform (error "must have init position")
66
:accessor pos :documentation "center of the circle")
7-
(r :initarg :r :initform 0
7+
(r :initarg :r :initform 0
88
:accessor r :documentation "radius of the circle"))
99
(:documentation "A circle that is hittable"))
1010

lib/misc.lisp renamed to src/lib/misc.lisp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
;; I will put misc functions related to CL game here
2-
(in-package :org.xzpeter.game.lib)
2+
(in-package :starwar-lib)
33

44
;; use run-game to run any game with threading
55
(defvar *game-thread* nil)

lib/packages.lisp renamed to src/lib/packages.lisp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
(in-package :cl-user)
2-
(defpackage :org.xzpeter.game.lib
2+
(defpackage :starwar-lib
33
(:use :cl :lispbuilder-sdl)
4-
(:export :run-game ; in misc.lisp
4+
(:export
5+
:run-game ; in misc.lisp
56
:color-random
67
:color-darken
78
:color-invert
@@ -13,8 +14,8 @@
1314
:vector-norm
1415
:vector-length
1516
:vec2rad
16-
:rad2vec
17-
:vector+
17+
:rad2vec
18+
:vector+
1819
:vector-
1920
:vector*
2021
:vector-floor

lib/vector.lisp renamed to src/lib/vector.lisp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
;; some vector related functions
2-
(in-package :org.xzpeter.game.lib)
2+
(in-package :starwar-lib)
33

44
;; fix any rad to: -pi/2 ~ 3pi/2
55
(defun rad-fix (rad)
@@ -8,18 +8,23 @@
88
(> r (* pi 1.5)))
99
(* pi 2)
1010
0))))
11+
1112
(defmacro vx (v)
1213
`(aref ,v 0))
14+
1315
(defmacro vy (v)
1416
`(aref ,v 1))
17+
1518
(defun vector-norm (vect)
1619
(let* ((x (vx vect))
1720
(y (vy vect))
1821
(a (sqrt (+ (* x x) (* y y)))))
1922
(vector (/ x a) (/ y a))))
23+
2024
(defun vector-length (vect)
2125
(let ((x (vx vect)) (y (vy vect)))
2226
(sqrt (+ (* x x) (* y y)))))
27+
2328
;; from -pi/2 ~ 3pi/2
2429
(defun vec2rad (vect)
2530
(let ((x (vx vect)) (y (vy vect)))
@@ -30,6 +35,7 @@
3035
(if (plusp y) (/ pi 2) (/ pi -2))
3136
(let ((rad (atan (/ y x))))
3237
(+ rad (if (minusp x) pi 0))))))
38+
3339
;; rad should be from -pi/2~3pi/2
3440
;; the vector returned are NOT normalized!!!
3541
(defun rad2vec (rad)
@@ -41,6 +47,7 @@
4147
(t (if (> rad (* pi 0.5))
4248
(vector -1 (- (tan rad)))
4349
(vector 1 (tan rad))))))
50+
4451
(defun vector+ (a b)
4552
(if (not (and (vectorp a) (vectorp b)))
4653
(error "A and B must be vector!"))
@@ -49,6 +56,7 @@
4956
(y0 (vy a))
5057
(y1 (vy b)))
5158
(vector (+ x0 x1) (+ y0 y1))))
59+
5260
(defun vector- (a b)
5361
(if (not (and (vectorp a) (vectorp b)))
5462
(error "A and B must be vector!"))
@@ -57,6 +65,7 @@
5765
(y0 (vy a))
5866
(y1 (vy b)))
5967
(vector (- x0 x1) (- y0 y1))))
68+
6069
(defun vector* (a n)
6170
(cond ((and (vectorp a) (numberp n))
6271
(let ((x (vx a))
@@ -69,6 +78,7 @@
6978
(y1 (vy n)))
7079
(vector (* x0 x1) (* y0 y1))))
7180
(t (error "not supported *!"))))
81+
7282
(defun vector-floor (vect)
7383
(vector (floor (vx vect)) (floor (vy vect))))
7484

0 commit comments

Comments
 (0)