Add scene system and update example
This commit is contained in:
parent
e7bfc01f7b
commit
f54f9c4b40
3 changed files with 197 additions and 115 deletions
|
|
@ -293,7 +293,7 @@
|
|||
|
||||
;; Event bus interface
|
||||
(export register-event-bus remove-event-bus fetch-event-bus
|
||||
push-event peek-event pop-event)
|
||||
clear-event-bus push-event peek-event pop-event)
|
||||
|
||||
;; Register a new event bus
|
||||
(define (register-event-bus name)
|
||||
|
|
@ -315,6 +315,18 @@
|
|||
name)
|
||||
#f))
|
||||
|
||||
(define (clear-event-bus name)
|
||||
(assert (symbol? name))
|
||||
(let ((event-bus (fetch-event-bus name)))
|
||||
(if event-bus
|
||||
(begin
|
||||
(for-each
|
||||
(lambda (key)
|
||||
(hash-table-delete! event-bus key))
|
||||
(hash-table-keys event-bus))
|
||||
#t)
|
||||
#f)))
|
||||
|
||||
;; Fetch an event bus by name, or #f if it doesn't exist
|
||||
(define (fetch-event-bus name)
|
||||
(assert (symbol? name))
|
||||
|
|
@ -366,7 +378,7 @@
|
|||
(key key-press-key))
|
||||
|
||||
;; Add a new action to the input actions alist
|
||||
(export register-action)
|
||||
(export register-action push-actions)
|
||||
(define (register-action name type . data)
|
||||
(assert (symbol? name))
|
||||
(assert (member type '(key-press)))
|
||||
|
|
@ -378,22 +390,22 @@
|
|||
input-actions)))
|
||||
|
||||
;; Default global system for simple input management
|
||||
(add-system
|
||||
(make-system
|
||||
'push-actions
|
||||
0
|
||||
'global
|
||||
'()
|
||||
(lambda ()
|
||||
(for-each
|
||||
(lambda (action)
|
||||
(cond
|
||||
((key-press? (cdr action))
|
||||
(when (key-pressed? (key-press-key (cdr action)))
|
||||
(push-event 'input
|
||||
(car action)
|
||||
(cdr action))))))
|
||||
input-actions))))
|
||||
(define push-actions
|
||||
(make-system
|
||||
'push-actions
|
||||
0
|
||||
'global
|
||||
'()
|
||||
(lambda ()
|
||||
(for-each
|
||||
(lambda (action)
|
||||
(cond
|
||||
((key-press? (cdr action))
|
||||
(when (key-pressed? (key-press-key (cdr action)))
|
||||
(push-event 'input
|
||||
(car action)
|
||||
(cdr action))))))
|
||||
input-actions))))
|
||||
|
||||
;; Render queue exports
|
||||
(export register-render-queue push-render-object evaluate-render-queue)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue