forked from Shirakumo/trial
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscene.lisp
35 lines (26 loc) · 1.06 KB
/
scene.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#|
This file is a part of trial
(c) 2016 Shirakumo http://tymoon.eu (shinmera@tymoon.eu)
Author: Nicolas Hafner <shinmera@tymoon.eu>
|#
(in-package #:org.shirakumo.fraf.trial)
(defclass scene (flare:scene event-loop)
((camera :initarg :camera :initform NIL :accessor camera)))
(defmethod enter :after ((camera camera) (scene scene))
(setf (camera scene) camera))
(defmethod register :after ((listener listener) (scene scene))
(add-listener listener scene))
(defmethod deregister :after (thing (scene scene))
(remove-listener thing scene))
(defmethod scene ((scene scene)) scene)
;; Since we have a tick event, we don't want to dupe that here.
;; animations and clock update are already handled by the method
;; combination, but defining a noop primary method prevents update
;; from being called on the children.
(defmethod flare:update ((scene scene) dt))
;; But we still need to call it in tick.
(defmethod handle :before ((event tick) (scene scene))
(flare:update scene (dt event)))
(defmethod finalize :after ((scene scene))
(stop scene)
(clear scene))