8585 (setq star-speed speed ))
8686 (setq *news* (format nil " Decrease speed to ~a x" star-speed)))
8787
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+
8894(defun handle-key (key)
8995 (case key
9096 (:sdl-key-escape
95101 (set-game-running *paused* ))
96102 (:sdl-key-r
97103 (clear-global-vars))
104+ (:sdl-key-f11
105+ (toggle-fullscreen))
98106 (:sdl-key-minus
99107 (decrease-star-speed))
100108 (:sdl-key-equals
104112 (clear-global-vars)
105113 (set-game-running t )))))
106114
115+
116+
107117; ; draw the information line by line
108118(defun draw-information (&rest infos)
109119 (let ((x 10 )
120130 (:up (decf *screen-pos-y* scroll-speed))
121131 (:down (incf *screen-pos-y* scroll-speed))
122132 (otherwise (error " unknown direction!" ))))
133+
123134(defun fix-screen-pos-overflow ()
124135 (when (> *screen-pos-x* screen-rightmost)
125136 (setq *screen-pos-x* screen-rightmost))
129140 (setq *screen-pos-y* screen-bottommost))
130141 (when (< *screen-pos-y* screen-topmost)
131142 (setq *screen-pos-y* screen-topmost)))
143+
132144(defun move-screen-on-worldmap ()
133145 (let ((x (sdl :mouse-x)) (y (sdl :mouse-y)))
134146 (when (or (<= x margin-left)
@@ -265,6 +277,7 @@ the outter rect. the rect is filled by VALUE/FULL-VALUE"
265277 (format t " fullscreen: ~a~% " fullscreen)
266278 (sdl :window screen-width screen-height
267279 :fullscreen fullscreen
280+ :resizable t
268281 :title-caption " Star War"
269282 :icon-caption " Star War" )
270283 (set-game-running t )
@@ -285,6 +298,12 @@ the outter rect. the rect is filled by VALUE/FULL-VALUE"
285298 (handle-mouse-button button x y t ))
286299 (:mouse-button-up-event (:button button :x x :y y)
287300 (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))
288307 (:idle ()
289308 (unless *game-over*
290309 (sdl :clear-display bg-color)
0 commit comments