Created
November 19, 2013 00:41
-
-
Save MattS8/7538130 to your computer and use it in GitHub Desktop.
Updated file and replaced the old (meh st x y ev) function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
world x y ev -> world | |
;; adds a sound to world if not already in the world | |
(define (meh st x y ev) | |
(cond [(string=? ev "button-down") | |
(cond ;[(in-tone-button x y (length INSTRUMENT BOXES)) (determine-tone-button x y)] | |
[(in-area-event x y ERASER_CENTER_X ERASER_CENTER_Y (image-width ERASER) (image-height ERASER)) (make-world empty START-IMG)] | |
[(in-area-event x y CANVAS_CENTER_X CANVAS_CENTER_Y CANVAS_SIZE CANVAS_SIZE) (make-world (addSound (world-lon st) (- x (- CANVAS_CENTER_X (/ CANVAS_SIZE 2))) (- y (- CANVAS_CENTER_Y (/ CANVAS_SIZE 2)))) (addImage (world-bg st) x y))] | |
[else st])] | |
[(and (string=? ev "drag")(in-area-event x y CANVAS_CENTER_X CANVAS_CENTER_Y CANVAS_SIZE CANVAS_SIZE)) | |
(make-world (addSound (world-lon st) (- x (- CANVAS_CENTER_X (/ CANVAS_SIZE 2))) (- y (- CANVAS_CENTER_Y (/ CANVAS_SIZE 2)))) (addImage (world-bg st) x y))] | |
[else st])) | |
;; x y center_x center_y image_width image_height -> boolean | |
;; returns whether or not the event occured in one of | |
;; - tone-button | |
;; - eraser | |
;; - canvas | |
(define (in-area-event x y c_x c_y width height) | |
(and (> x (- c_x (/ width 2))) (< x (+ c_x (/ width 2))) | |
(> y (- c_y (/ height 2))) (< y (+ c_y (/ height 2))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment