31 lines
767 B
Common Lisp
31 lines
767 B
Common Lisp
(ql:quickload "lispbuilder-sdl")
|
|
|
|
(defparameter *rand-color* sdl:*white*)
|
|
(defun test-sdl ()
|
|
(sdl:with-init ()
|
|
(sdl:window 500 500 :title-caption "sdl test")
|
|
(setf (sdl:frame-rate) 60)
|
|
|
|
(sdl:with-events ()
|
|
(:quit-event () t)
|
|
(:key-down-event ()
|
|
(when (or
|
|
(sdl:key-down-p :sdl-key-q)
|
|
(sdl:key-down-p :sdl-key-escape))
|
|
(sdl:push-quit-event)))
|
|
(:idle ()
|
|
|
|
(when (sdl:mouse-left-p)
|
|
(setf *rand-color* (sdl:color :r (random 255) :g (random 255) :b (random 255))))
|
|
|
|
(sdl:clear-display sdl:*black*)
|
|
|
|
(sdl:draw-box
|
|
(sdl:rectangle-from-midpoint-* (sdl:mouse-x) (sdl:mouse-y) 20 20)
|
|
:color *rand-color*)
|
|
|
|
(sdl:update-display)))))
|
|
|
|
(sb-int:with-float-traps-masked
|
|
(:invalid :inexact :overflow)
|
|
(test-sdl))
|