forked from Shirakumo/trial
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscene.lisp
39 lines (29 loc) · 1.1 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
36
37
38
39
#|
This file is a part of trial
(c) 2016 Shirakumo http://tymoon.eu ([email protected])
Author: Nicolas Hafner <[email protected]>
|#
(in-package #:org.shirakumo.fraf.trial)
;; FIXME: get rid of this shit or at least find a better way to do this stuff.
(defvar *scene*)
(defclass scene (flare:scene event-loop)
())
(defmethod register :after ((listener listener) (scene scene))
(add-listener listener scene))
(defmethod deregister :after (thing (scene scene))
(remove-listener thing scene))
(defmethod process :around ((scene scene))
(let ((*scene* scene))
(call-next-method)))
(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))