Skip to content

Instantly share code, notes, and snippets.

@PuercoPop
Created February 21, 2020 20:06
Show Gist options
  • Save PuercoPop/602c1fb39204d181aec7e413bdb5bdb5 to your computer and use it in GitHub Desktop.
Save PuercoPop/602c1fb39204d181aec7e413bdb5bdb5 to your computer and use it in GitHub Desktop.
(defclass entity ()
()
(:documentation "Used to track all entities"))
(defmacro defentity (name parents &body (attributes))
`(defclass ,name ,(append parents (list 'entity)) ,attributes))
(defentity wall (drawable)
((color :initform (rgb 255 255 255))
(char :initform #\#)))
;; I need/want to generate a texture for each char before entering the main loop
;; So something like this
(defun generate-drawable-texture (drawable)
(let* ((color-slot-def (find-slot drawable-class 'color))
(color (funcall (slot-definition-initfunction color-slot-def)))
(surface (sdl2-ttf:render-text-solid +font+
(string (drawable-char drawable))
(red (drawable-color drawable))
(green (drawable-color drawable))
(blue (drawable-color drawable))
(alpha (drawable-color drawable))))
(texture (create-texture-from-surface *renderer*
surface)))
(free-surface surface)
texture))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment