-(defun load-image2 (image-file &key (transparent-color nil))
- (let ((address-image (load-image image-file :transparent-color transparent-color)))
- (list
- (lambda (x y) (print-surface x y address-image))
- (lambda () (SDL_FreeSurface address-image)))))
-
-(defun apply-surface (x y source destination)
- (let ((offset (SDL_Rect x y 0 0)))
- (SDL_BlitSurface source 0 destination offset)
- (free offset)
- destination))
-
-(defun apply-surface-old (x y source destination &optional (clip nil))
- (cond ((null clip)
- (apply-surface2 x y (surface-address source) (surface-address destination) 0 0 0 0 0))
- ((integerp clip)
- (apply-surface2 x y (surface-address source) (surface-address destination) 0 0
- (surface-clip-w source) (surface-clip-h source) clip))
- (t
- (apply-surface2 x y (surface-address source) (surface-address destination)
- (first clip) (second clip) (third clip) (fourth clip) 0)))
- destination)
-
-
-(defun print-image (x y image-file &optional (clip nil))
- (init-video-mode)
- (let ((image (load-image image-file)))
- (print-surface x y image clip)
- image))
-
-
-(defun clean-screen ()
- (fill-screen *background-color*))
-
-(defun refresh-screen ()
- (clean-screen)
- (funcall-procs #'print-mob)
- (flip))
-
-
-(defun filled-circle (radius &optional (color '(:red 255 :green 255 :blue 255)))
- (init-video-mode)
- (let ((new-surface (create-surface (1+ (* radius 2)) (1+ (* radius 2)))))
- (sge_FilledCircle (surface-address new-surface)
- radius radius radius
- (getf color :red)
- (getf color :green)
- (getf color :blue))
- (setf (surface-shape new-surface)
- `((,radius ,radius) ,radius))
- new-surface))
-
-
-(defun filled-rect (width height &optional (color '(:red 255 :green 255 :blue 255)))
- (init-video-mode)
- (let ((new-surface (create-surface width height)))
- (sge_FilledRect (surface-address new-surface)
- 0 0 width height
- (getf color :red)
- (getf color :green)
- (getf color :blue))
- (setf (surface-shape new-surface)
- (make-rectangle 0 0 width height))
- new-surface))
-
-
-;;; TTF Subsystem
-(defstruct font address)
-
-(let ((ttf nil))
-
- (defun init-ttf ()
- (cond ((null ttf) (progn (init-sdl) (setq ttf (TTF_Init))))
- (t ttf)))
-
- (defun quit-ttf ()
- (setq ttf (TTF_Quit))))
-
-
-(defun open-font (font-name tam)
- (init-ttf)
- (let ((font (get-resource 'font font-name tam)))
- (if (null font)
- (progn (setq font (make-font :address (TTF_OpenFont font-name tam)))
- (set-resource 'font font font-name tam)))
- font))
-
-
-(defun render-text (text-message
- &key (color '(:red 255 :green 255 :blue 255))
- (font-name "lazy.ttf") (tam 28))
- (init-ttf)
- (let ((message (get-resource 'text text-message color font-name tam)))
- (if (null message)
- (progn
- (setq message
- (make-surface
- :address (render-text2 (open-font font-name tam)
- text-message
- (getf color :red)
- (getf color :green)
- (getf color :blue))))
- (set-resource 'text message text-message color font-name tam)))
- message))
-
-
-(defun print-text (x y text-message
- &key (color '(:red 255 :green 255 :blue 255))
- (font-name "lazy.ttf") (tam 28))
- (init-video-mode)
- (init-ttf)
- (let ((message (render-text text-message :color color :font-name font-name :tam tam)))
- (print-surface x y message)
- message))
-