Can anyone help me, figure out what is wrong with this function I have, I am trying to get the objects to bounce back as soon as they hit the top and bottom of the Window, but when I run this one of the objects stay on top and the other keeps on going.
(define (up-and-down y-pos-pair)
;;get the balls
(define b1 (first y-pos-pair))
(define b2 (second y-pos-pair))
;; move the balls (struct ball (color ypos velocity trip) #:transparent)
(set! b1 (ball (ball-color b1) (+(ball-ypos b1) ball1V) (ball-velocity b1) (ball-trip b1)))
(set! b2 (ball (ball-color b2) (+(ball-ypos b2) ball2V) (ball-velocity b2) (ball-trip b2)))
;;bounce the ball on the borders
(cond
[(>= (ball-ypos b2) HIGHEST-Y-POS)(set! b2 (ball (ball-color b2) (- HIGHEST-Y-POS 1) (* ball1V -1) (ball-trip b2)))]
)
(list b1 b2)
#|(let* (ss
[b1 (ball 'red (+ (ball-ypos(first y-pos-pair)) ball1V) ball1V (ball-trip (first y-pos-pair))) ]
[b2 (ball 'blue (+ (ball-ypos(second y-pos-pair)) ball2V) ball2V (ball-trip (second y-pos-pair)))]
)
;;(list b1 b2)
(cond ;;
[(>= (ball-ypos b1) HIGHEST-Y-POS)(set! b1 (ball 'red (+ (ball-ypos b1) ball1V) -1 (ball-trip b1)))]
)
(list b1 b2)|#
#| (cond
[(>= (ball-ypos b1) HIGHEST-Y-POS)()]
)
(cond
[(>= (ball-ypos b1) HIGHEST-Y-POS)()]
)
(cond
[(>= (ball-ypos b1) HIGHEST-Y-POS)()]
)|#
)
;;(list (ball 'red (+ (ball-ypos(first y-pos-pair)) ball1V) ball1V (ball-trip (first y-pos-pair)))
;;(ball 'blue (+ (ball-ypos(second y-pos-pair)) ball2V) ball2V (ball-trip (second y-pos-pair)))))
;;(list ball1 ball2)