@@ -86,6 +86,13 @@ generateing the map. ")
8686(defparameter planet-core-radius 3 )
8787(defparameter star-max-amount 1000 )
8888
89+ (defparameter screen-rightmost (- world-rightmost screen-width))
90+ (defparameter screen-bottommost (- world-bottommost screen-height))
91+ (defparameter world-width (- world-rightmost world-leftmost))
92+ (defparameter world-height (- world-bottommost world-topmost))
93+ (defparameter margin-bottom (- screen-height 10 ))
94+ (defparameter margin-right (- screen-width 10 ))
95+
8996(defun generate-bg-stars (n)
9097 " generate N bg stars and return list"
9198 (loop repeat n collect
@@ -95,13 +102,16 @@ generateing the map. ")
95102
96103(defun load-file-set-parameters (filename)
97104 " read one file and load all the parameters"
105+ ; ; without this, the settings won't work
106+ (in-package :org.xzpeter.game.starwar )
98107 (with-open-file (s filename)
99108 (do ((form (read s) (read s nil ' eof)))
100109 ((eq form ' eof) nil )
101110 (if (not (= (length form) 2 ))
102111 (error " configure file format not right!" ))
103112 (setq form (cons ' defparameter form))
104- (eval form))))
113+ (format t " eval: ~a~% " form)
114+ (eval form))))
105115
106116(defun auto-generate-planets (amount)
107117 " auto generate planets and normally set the *planet-list* var.
@@ -152,10 +162,6 @@ INIT-AMOUNT is how many planets one player own at the beginning of game"
152162 (incf count )
153163 (setq vlist (cons v vlist)))))))))
154164
155- (defun set-game-running (n)
156- " set running status of the game"
157- (setf (sdl :frame-rate) (if n frame-rate -1 )))
158-
159165(defun clear-global-vars ()
160166 (setq *planet-list* nil )
161167 (setq *running* nil )
@@ -181,18 +187,16 @@ INIT-AMOUNT is how many planets one player own at the beginning of game"
181187 *bg-stars* (generate-bg-stars bg-star-n)
182188 *planet-list* (planet-sort-by-size
183189 (auto-generate-planets planet-total)))
184- ; ; defaultly, the first planet for player1, then player2
190+
185191 (setf (player (fifth *planet-list* )) *player1* )
186192 (setf (player (sixth *planet-list* )) *player2* )
187193
188194 ; ; load all the configure file
189195 (load-file-set-parameters " starwar.conf" )
190196
191- (defparameter screen-rightmost (- world-rightmost screen-width))
192- (defparameter screen-bottommost (- world-bottommost screen-height))
193- (defparameter world-width (- world-rightmost world-leftmost))
194- (defparameter world-height (- world-bottommost world-topmost))
195- (defparameter margin-bottom (- screen-height 10 ))
196- (defparameter margin-right (- screen-width 10 ))
197-
198- (set-game-running t ))
197+ (setq screen-rightmost (- world-rightmost screen-width))
198+ (setq screen-bottommost (- world-bottommost screen-height))
199+ (setq world-width (- world-rightmost world-leftmost))
200+ (setq world-height (- world-bottommost world-topmost))
201+ (setq margin-bottom (- screen-height 10 ))
202+ (setq margin-right (- screen-width 10 )))
0 commit comments