Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defun game (&optional (width 320) (height 240) (speed 1))
- (let ((altitude (/ height 2)))
- (sdl:with-init ()
- (sdl:window width height :title-caption "My game")
- (setf (sdl:frame-rate) 60)
- (sdl:with-events ()
- (:quit-event () t)
- (:idle ()
- (sdl:clear-display sdl:*white*)
- (setf speed (if (or (< altitude 10) (> altitude (- height 10)))
- (- speed)
- speed))
- (sdl:draw-box (sdl:rectangle-from-midpoint-*
- (/ width 2) (incf altitude speed) 20 20) :color sdl:*red*)
- (sdl:update-display))))))
- (defun calculate-speed (speed altitude height)
- (if (or (< altitude 10) (> altitude (- height 10)))
- (- speed)
- speed))
- (defun update-altitude (speed altitude height)
- (+ altitude (calculate-speed speed altitude height)))
- (defun game (&optional (width 320) (height 240) (speed 1))
- (let ((altitude (/ height 2)))
- (sdl:with-init ()
- (sdl:window width height :title-caption "My game")
- (setf (sdl:frame-rate) 60)
- (sdl:with-events ()
- (:quit-event () t)
- (:idle ()
- (sdl:clear-display sdl:*white*)
- (setf altitude (update-altitude speed altitude height))
- (sdl:draw-box (sdl:rectangle-from-midpoint-*
- 150 altitude 20 20)
- :color sdl:*red*)
- (sdl:update-display))))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement