7777 (setq speed star-speed-max))
7878 (setq star-speed speed ))
7979 (setq *news* (format nil " Increase speed to ~a x" star-speed)))
80+
8081(defun decrease-star-speed ()
8182 (let ((speed (- star-speed 0.5 )))
8283 (if (< speed star-speed-min)
8384 (setq speed star-speed-min))
8485 (setq star-speed speed ))
8586 (setq *news* (format nil " Decrease speed to ~a x" star-speed)))
8687
88+ (defun toggle-fullscreen ()
89+ (if fullscreen
90+ (sdl :resize-window screen-width screen-height :sw t :resizable t )
91+ (sdl :resize-window screen-width screen-height :sw t :fullscreen t ))
92+ (setf fullscreen (not fullscreen)))
93+
8794(defun handle-key (key)
8895 (case key
8996 (:sdl-key-escape
94101 (set-game-running *paused* ))
95102 (:sdl-key-r
96103 (clear-global-vars))
104+ (:sdl-key-f11
105+ (toggle-fullscreen))
97106 (:sdl-key-minus
98107 (decrease-star-speed))
99108 (:sdl-key-equals
103112 (clear-global-vars)
104113 (set-game-running t )))))
105114
115+
116+
106117; ; draw the information line by line
107118(defun draw-information (&rest infos)
108119 (let ((x 10 )
119130 (:up (decf *screen-pos-y* scroll-speed))
120131 (:down (incf *screen-pos-y* scroll-speed))
121132 (otherwise (error " unknown direction!" ))))
133+
122134(defun fix-screen-pos-overflow ()
123135 (when (> *screen-pos-x* screen-rightmost)
124136 (setq *screen-pos-x* screen-rightmost))
128140 (setq *screen-pos-y* screen-bottommost))
129141 (when (< *screen-pos-y* screen-topmost)
130142 (setq *screen-pos-y* screen-topmost)))
143+
131144(defun move-screen-on-worldmap ()
132145 (let ((x (sdl :mouse-x)) (y (sdl :mouse-y)))
133146 (when (or (<= x margin-left)
@@ -264,12 +277,13 @@ the outter rect. the rect is filled by VALUE/FULL-VALUE"
264277 (format t " fullscreen: ~a~% " fullscreen)
265278 (sdl :window screen-width screen-height
266279 :fullscreen fullscreen
280+ :resizable t
267281 :title-caption " Star War"
268282 :icon-caption " Star War" )
269283 (set-game-running t )
270284 ; ; music background
271285 (sdl-mixer :open-audio)
272- (let ((music (sdl-mixer :load-music " background.mp3" )))
286+ (let ((music (sdl-mixer :load-music (portable-pathname " background.mp3" ) )))
273287 (sdl-mixer :play-music music :loop t )
274288 (sdl :with-events ()
275289 (:quit-event () (sdl-mixer :Halt-Music)
@@ -284,6 +298,12 @@ the outter rect. the rect is filled by VALUE/FULL-VALUE"
284298 (handle-mouse-button button x y t ))
285299 (:mouse-button-up-event (:button button :x x :y y)
286300 (handle-mouse-button button x y nil ))
301+
302+ (:video-resize-event (:w w :h h)
303+ (setq screen-width w)
304+ (setq screen-height h)
305+ (sdl :resize-window w h)
306+ (load-world-limits))
287307 (:idle ()
288308 (unless *game-over*
289309 (sdl :clear-display bg-color)
0 commit comments