1

我想使用lispbuilder绘制表面,但我无法将用户指南/api 转换为工作示例。

这是我目前拥有的:

(defun func (version)
  (sdl:with-init ()
    (sdl:window 1023 768 :title-caption "Move a rectangle using the mouse")
    (setf (sdl:frame-rate) 60)
    (setf *map-surface* (sdl:load-image "...src/resources/map.jpg"))
    (sdl:with-events ()
      (:quit-event () t)
      (:key-down-event ()
               (sdl:push-quit-event))
      (:idle ()
         (sdl:draw-surface *map-surface*) 

         ;; Change the color of the box if the left mouse button is depressed
         (when (sdl:mouse-left-p)
           (setf *random-color* (sdl:color :r (random 255) :g (random 255) :b (random 255))))

          ;; Clear the display each game loop
          (sdl:clear-display sdl:*black*)

          ;; Draw the box having a center at the mouse x/y coordinates.
          (sdl:draw-box (sdl:rectangle-from-midpoint-* (sdl:mouse-x) (sdl:mouse-y) 20 20)
                 :color *random-color*)

          ;; Redraw the display
          (sdl:update-display))))))

但它根本不绘制表面。我已经检查了表面是否加载成功。我也很感激推荐一个涵盖该库的教程/论文,因为实际的“用户指南”并不是真正适合初学者的。

4

1 回答 1

0

实际上,一切正常。但是当您每次都重绘屏幕时((sdl:clear-display sdl:*black*)),您看不到图片。尝试注释掉这一行...

于 2012-04-26T15:44:36.107 回答