diff options
| author | Gene Pasquet <dev@etenil.net> | 2026-04-08 01:05:50 +0100 |
|---|---|---|
| committer | Gene Pasquet <dev@etenil.net> | 2026-04-08 01:05:50 +0100 |
| commit | 995342fb74fdd1ba5aeaa172a428538e7dd0dcdc (patch) | |
| tree | 82a60034eaa097191d360fe07e4ef3a52dae9c2a /world.scm | |
| parent | 0c3a700aa94a0256c5e5b1a14819f10b3d3e869b (diff) | |
Code cleanup
Diffstat (limited to 'world.scm')
| -rw-r--r-- | world.scm | 31 |
1 files changed, 15 insertions, 16 deletions
@@ -95,24 +95,23 @@ (loop (cdr es) (cons (cons gid e) acc)))) (loop (cdr es) acc)))))) + (define (sync-member-to-origin e origins) + (let* ((gid (entity-ref e #:group-id #f)) + (o (and gid (not (entity-ref e #:group-origin? #f)) + (assq gid origins)))) + (if o + (let ((origin (cdr o))) + (entity-set (entity-set e #:x (+ (entity-ref origin #:x 0) + (entity-ref e #:group-local-x 0))) + #:y (+ (entity-ref origin #:y 0) + (entity-ref e #:group-local-y 0)))) + e))) + ;; Snap member #:x/#:y to origin + #:group-local-x/y. Call after moving origins (tweens, etc.). (define (scene-sync-groups! scene) - (let* ((ents (scene-entities scene)) - (origins (group-origin-alist ents))) + (let ((origins (group-origin-alist (scene-entities scene)))) (scene-entities-set! scene - (map (lambda (e) - (if (and (entity-ref e #:group-id #f) - (not (entity-ref e #:group-origin? #f))) - (let* ((gid (entity-ref e #:group-id)) - (o (assq gid origins))) - (if o - (let ((origin (cdr o))) - (entity-set (entity-set e #:x (+ (entity-ref origin #:x 0) - (entity-ref e #:group-local-x 0))) - #:y (+ (entity-ref origin #:y 0) - (entity-ref e #:group-local-y 0)))) - e)) - e)) - ents)) + (map (lambda (e) (sync-member-to-origin e origins)) + (scene-entities scene))) scene)) ) |
