@@ -52,14 +52,10 @@ generateing the map. ")
5252(defparameter world-topmost 0 )
5353(defparameter world-rightmost 1600 )
5454(defparameter world-bottommost 1200 )
55- (defparameter world-width (- world-rightmost world-leftmost))
56- (defparameter world-height (- world-bottommost world-topmost))
5755; ; these params defines the biggest places that user can go via moving the
5856; ; mouse
5957(defparameter screen-leftmost world-leftmost)
6058(defparameter screen-topmost world-topmost)
61- (defparameter screen-rightmost (- world-rightmost screen-width))
62- (defparameter screen-bottommost (- world-bottommost screen-height))
6359
6460(defparameter star-life-max 10 )
6561(defparameter star-life-min 3 )
@@ -75,9 +71,7 @@ generateing the map. ")
7571; ; position on the worldmap.
7672; ; these are the margin place, outside which the moving is activated.
7773(defparameter margin-left 10 )
78- (defparameter margin-right (- screen-width 10 ))
7974(defparameter margin-top 10 )
80- (defparameter margin-bottom (- screen-height 10 ))
8175
8276; ; defines the background
8377(defparameter bg-star-size-max 2 )
@@ -98,6 +92,17 @@ generateing the map. ")
9892 (list (random world-width) (random world-height)
9993 (+ bg-star-size-min (random (- bg-star-size-max
10094 bg-star-size-min -1 ))))))
95+
96+ (defun load-file-set-parameters (filename)
97+ " read one file and load all the parameters"
98+ (with-open-file (s filename)
99+ (do ((form (read s) (read s nil ' eof)))
100+ ((eq form ' eof) nil )
101+ (if (not (= (length form) 2 ))
102+ (error " configure file format not right!" ))
103+ (setq form (cons ' defparameter form))
104+ (eval form))))
105+
101106(defun auto-generate-planets (amount)
102107 " auto generate planets and normally set the *planet-list* var.
103108AMOUNT is how many planet to generate in all,
@@ -179,4 +184,15 @@ INIT-AMOUNT is how many planets one player own at the beginning of game"
179184 ; ; defaultly, the first planet for player1, then player2
180185 (setf (player (fifth *planet-list* )) *player1* )
181186 (setf (player (sixth *planet-list* )) *player2* )
187+
188+ ; ; load all the configure file
189+ (load-file-set-parameters " starwar.conf" )
190+
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+
182198 (set-game-running t ))
0 commit comments