~lthms/fairy.lisp

7a1807a92f0351b8e15f9669c50c8626e5c1e815 — Thomas Letan 6 years ago d0888ca
refactor: width and height becomes true generic method
2 files changed, 10 insertions(+), 0 deletions(-)

M fairy.lisp
M tiled.lisp
M fairy.lisp => fairy.lisp +4 -0
@@ 43,6 43,10 @@
                                     (gamekit:y origin))
           ,@body)))))

(defgeneric width (el))

(defgeneric height (el))

(defclass rectangle (element)
  ((width :initarg :width
          :initform (error "Must supply a width")

M tiled.lisp => tiled.lisp +6 -0
@@ 20,6 20,12 @@
  (let ((tileset (cl-tiled:load-tileset (tileset el))))
    (setf (change-tileset el) tileset)))

(defmethod fairy:width ((el tile))
  (cl-tiled:tileset-tile-width (tileset el)))

(defmethod fairy:height ((el tile))
  (cl-tiled:tileset-tile-height (tileset el)))

(fairy:defdraw (el tile)
    (with-slots (tileset current get-resource) el
      (let* ((image (cl-tiled:tileset-image (tileset el)))