Simplifying engine interface #14
1 changed files with 9 additions and 4 deletions
|
|
@ -37,15 +37,20 @@
|
||||||
;; Generic accessors and mutators for position, rotation, scale, anchor, and parent
|
;; Generic accessors and mutators for position, rotation, scale, anchor, and parent
|
||||||
;; This allows us to abstract across different transform types - (position) will work for
|
;; This allows us to abstract across different transform types - (position) will work for
|
||||||
;; screen-transform and 2D-transform, with type checking
|
;; screen-transform and 2D-transform, with type checking
|
||||||
(export position set-position! rotation set-rotation! scale set-scale!
|
(export global-position position set-position! rotation
|
||||||
anchor set-anchor! parent set-parent!)
|
set-rotation! scale set-scale! anchor set-anchor!
|
||||||
|
parent set-parent!)
|
||||||
|
|
||||||
(define (position component)
|
(define (global-position component)
|
||||||
(assert (record? component))
|
(assert (record? component))
|
||||||
(if (null? (parent component))
|
(if (null? (parent component))
|
||||||
((rtd-accessor (record-rtd component) 'position) component)
|
((rtd-accessor (record-rtd component) 'position) component)
|
||||||
(v+ ((rtd-accessor (record-rtd component) 'position) component)
|
(v+ ((rtd-accessor (record-rtd component) 'position) component)
|
||||||
(position (parent component)))))
|
(global-position (parent component)))))
|
||||||
|
|
||||||
|
(define (position component)
|
||||||
|
(assert (record? component))
|
||||||
|
((rtd-accessor (record-rtd component) 'position) component))
|
||||||
|
|
||||||
(define (set-position! component position)
|
(define (set-position! component position)
|
||||||
(assert (record? component))
|
(assert (record? component))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue