From bd40ca3c62fccbd4f917bfbbb95867dbd02954f5 Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Fri, 2 Sep 2016 11:11:56 +0100 Subject: [PATCH] Simplify `touching` notifications --- racket/syndicate-gl/2d.rkt | 4 ++-- racket/syndicate-gl/examples/basic.rkt | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/racket/syndicate-gl/2d.rkt b/racket/syndicate-gl/2d.rkt index 63b7e0c..13027f1 100644 --- a/racket/syndicate-gl/2d.rkt +++ b/racket/syndicate-gl/2d.rkt @@ -62,7 +62,7 @@ (struct mouse-state (x y left-down? middle-down? right-down?) #:transparent) ;; Assertion. Indicates that the mouse is touching a particular touchable. -(struct touching (id user-x user-y state) #:transparent) +(struct touching (id) #:transparent) ;; Shared state maintained by program. Prelude and postlude are to be ;; sealed instruction lists. It is an error to have more than exactly @@ -308,7 +308,7 @@ (define user-point (untransform-point xform (make-rectangular x y))) (define ux (real-part user-point)) (define uy (imag-part user-point)) - (and (contains? ux uy) (touching id ux uy state)))) + (and (contains? ux uy) (touching id)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/racket/syndicate-gl/examples/basic.rkt b/racket/syndicate-gl/examples/basic.rkt index b7fa634..8a9ed8b 100644 --- a/racket/syndicate-gl/examples/basic.rkt +++ b/racket/syndicate-gl/examples/basic.rkt @@ -36,7 +36,7 @@ (define (draggable-shape name orig-x orig-y z plain-image hover-image) (actor (field [x orig-x] [y orig-y]) - (define/query-value touching? #f (inbound (touching name _ _ _)) #t) + (define/query-value touching? #f (inbound (touching name)) #t) (assert (outbound (simple-sprite #:touchable-id name #:touchable-predicate in-unit-circle? z (x) (y) 50 50 @@ -58,7 +58,7 @@ (on (retracted (key-pressed $k)) (keys-down (set-remove (keys-down) k))) (define (key->delta k distance) (if (set-member? (keys-down) k) distance 0)) - (define/query-value touching? #f (inbound (touching 'player _ _ _)) #t) + (define/query-value touching? #f (inbound (touching 'player)) #t) (on-start (draggable-mixin touching? x y)) (on (message (inbound (frame-event _ _ $elapsed-ms _))) @@ -97,7 +97,7 @@ (actor* (until (message (inbound (key-event #\q #t _)))) (assert! (outbound 'stop))) -(actor (during (inbound (touching $id _ _ _)) +(actor (during (inbound (touching $id)) (on-start (log-info "Touching ~v" id)) (on-stop (log-info "No longer touching ~v" id))))