在Mac OS X上安装lispbuilder-sdl

时间:2016-04-23 03:03:35

标签: macos sdl common-lisp sdl-2

任何人都在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的开发库。它的行为如下:

当我运行一些在使用lispbuilder-sdl:

的Linux上运行良好的简单代码时
(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:]")

任何人都知道如何解决这个问题?感谢。

1 个答案:

答案 0 :(得分:0)

你好@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*))