在 Mac OS X 上安装 lispbuilder-sdl

install lispbuilder-sdl on Mac OS X

有人在 Mac OS X 上开发普通的 lisp 游戏吗?最近,我想在 Mac OS X 上设置一个 lisp 游戏开发。但是我卡住了。

Operating System version: 
    ProductName:    Mac OS X
    ProductVersion: 10.11.4
    BuildVersion:   15E65

sbcl version: 
    SBCL 1.3.3

我找到 Github 存储库页面:https://github.com/lispbuilder/lispbuilder/wiki/DownloadInstallation 并遵循 OS X 安装部分。我尝试安装 SDL 1.2 的运行时库和运行时二进制文件以及 SDL 2.0 的开发库。它的行为如下:

当我 运行 一些简单的代码 运行 在 Linux 上使用 lispbuilder-sdl 时:

(defun draw-a-box-in-window ()
(sdl:with-init
  ()
(let ((width 500)
      (height 500))
  (sdl:window width height)
  (setf (sdl:frame-rate) 60)
  (sdl:clear-display
   (sdl:color
    :r 127
    :g 127
    :b 127))
  (sdl:draw-box
   (sdl:rectangle
    :x (floor (/ width 3))
    :y (floor (/ height 3))
    :w (floor (/ height 3))
    :h (floor (/ height 3)))
   :color (sdl:color
           :r 200
           :g 200
           :b 200))
  (sdl:update-display)
  (sdl:with-events
      ()
    (:quit-event () t)
    (:key-down-event ()
                     (when (sdl:key-down-p :sdl-key-q)
                       (sdl:push-quit-event)))))))
(draw-a-box-in-window)

发生错误:

arithmetic error FLOATING-POINT-INEXACT signalled
[Condition of type FLOATING-POINT-INEXACT]

Restarts:
0: [RETRY] Retry SLIME evaluation request.
1: [*ABORT] Return to SLIME's top level.
2: [ABORT] abort thread (#<THREAD "worker" RUNNING {1005D039E3}>)

Backtrace:
0: ("bogus stack frame")
1: ("foreign function: -[NSPlaceholderNumber initWithDouble:]")
2: ("foreign function: +[CALayer defaultValueForKey:]")

有人知道怎么解决吗?谢谢。

你好@aries_liuxueyangm,我向你推荐这个解决方案。

(ql:quickload 'lispbuilder-sdl)

(asdf:operate 'asdf:load-op :lispbuilder-sdl)
(asdf:operate 'asdf:load-op :cocoahelper)

(defparameter *random-color* sdl:*white*)

(defun draw-a-box-in-window ()
(sdl:with-init
  ()
(let ((width 500)
      (height 500))
  (sdl:window width height)
  (setf (sdl:frame-rate) 60)
  (sdl:clear-display
   (sdl:color
    :r 127
    :g 127
    :b 127))
  (sdl:draw-box
   (sdl:rectangle
    :x (floor (/ width 3))
    :y (floor (/ height 3))
    :w (floor (/ height 3))
    :h (floor (/ height 3)))
   :color (sdl:color
           :r 200
           :g 200
           :b 200))
  (sdl:update-display)
  (sdl:with-events
      ()
    (:quit-event () t)
    (:key-down-event ()
                     (when (sdl:key-down-p :sdl-key-q)
                       (sdl:push-quit-event)))))))


(defun main (argv &aux (argc (length argv)))
  (draw-a-box-in-window)
)

(sb-int:with-float-traps-masked (:invalid :inexact :overflow) (main *posix-argv*))