M example.lisp => example.lisp +9 -4
@@ 27,15 27,20 @@
;; It is possible to update the scene description, and it will update the
;; screen.
-(sleep 1)
+(sleep 0.5)
(setf (fairy:width *rec*) 200)
-(sleep 1)
+(sleep 0.5)
(setf (fairy:origin *rec*) (gamekit:vec2 230 20))
-(sleep 1)
+(sleep 0.5)
+(setf (fairy:visible *rec*) nil)
+(sleep 0.5)
+(setf (fairy:visible *rec*) t)
+
+(sleep 0.5)
(setf (fairy:boundary *root*) (gamekit:vec2 240 50))
;; And even remove an element from the scene
-(sleep 1)
+(sleep 0.5)
(fairy:delete-child *root* *rec*)
M fairy.lisp => fairy.lisp +12 -7
@@ 4,6 4,7 @@
element
origin
scale
+ visible
rectangle
width
height
@@ 24,16 25,20 @@
:accessor origin)
(scale :initarg :scale
:initform nil
- :accessor :scale)))
+ :accessor :scale)
+ (visible :initarg :visible
+ :initform t
+ :accessor visible)))
(defmacro defdraw ((el class) &rest body)
`(defmethod draw ((,el ,class))
- (with-slots (origin scale) ,el
- (gamekit:with-pushed-canvas ()
- (when scale (gamekit:scale-canvas scale scale))
- (gamekit:translate-canvas (gamekit:x origin)
- (gamekit:y origin))
- ,@body))))
+ (with-slots (origin scale visible) ,el
+ (when visible
+ (gamekit:with-pushed-canvas ()
+ (when scale (gamekit:scale-canvas scale scale))
+ (gamekit:translate-canvas (gamekit:x origin)
+ (gamekit:y origin))
+ ,@body)))))
(defclass rectangle (element)
((width :initarg :width