Question: drracket coding of bouncing ball, below code the ball does not move, pls help to advise #lang racket ( require 2 htdp / image )

drracket coding of bouncing ball, below code the ball does not move, pls help to advise
#lang racket
(require 2htdp/image)
(require 2htdp/universe)
(define WIDTH 605)
(define HEIGHT 535)
(define BALL-RADIUS 10)
(define TOP (+0 BALL-RADIUS))
(define BOT (- HEIGHT 1 BALL-RADIUS))
(define LEF (+0 BALL-RADIUS))
(define RIG (- WIDTH 1 BALL-RADIUS))
(define-struct ball (x y dx dy))
TOP
BOT
LEF
RIG
(define BALL (circle BALL-RADIUS "solid" "white"))
(define MTS (rectangle WIDTH HEIGHT "solid" "green"))
(define B1(make-ball (/ WIDTH 2)(/ HEIGHT 2)4-3))
;check if ball near edges
(define (touch-top? b)
(<=(+(ball-y b)(ball-dy b)) TOP))
(define (touch-bot? b)
(>=(+(ball-y b)(ball-dy b)) BOT))
(define (touch-rig? b)
(<=(+(ball-x b)(ball-dx b)) RIG))
(define (touch-lef? b)
(>=(+(ball-x b)(ball-dx b)) BOT))
; Bounce the ball off the edges
(define (bounce-top b)(make-ball (ball-x b)(+ TOP 1)(ball-dx b)(-(ball-dy b))))
(define (bounce-bot b)(make-ball (ball-x b)(- BOT 1)(ball-dx b)(-(ball-dy b))))
(define (bounce-lef b)(make-ball (+ LEF 1)(ball-y b)(-(ball-dx b))(ball-dy b)))
(define (bounce-rig b)(make-ball (- RIG 1)(ball-y b)(-(ball-dx b))(ball-dy b)))
; Move the ball
(define (glide b)(make-ball (+(ball-x b)(ball-dx b))(+(ball-y b)(ball-dy b))(ball-dx b)(ball-dy b)))
; Handle mouse click to create a new ball
(define (handle-mouse b x y event)
(cond [(equal? event "button-down")(make-ball x y (-5(random 11))(-5(random 11)))]
[else B1]))
(define (render-ball b)
(place-image (circle BALL-RADIUS 'solid 'white)(ball-x b)(ball-y b)(empty-scene WIDTH HEIGHT 'green)))
; Determine the next state of the ball based on its position
(define (next-ball b)
(cond
[(or (touch-top? b)(touch-bot? b))(make-ball (ball-x b)(ball-y b)(ball-dx b)(-(ball-dy b)))]
[(or (touch-lef? b)(touch-rig? b))(make-ball (ball-x b)(ball-y b)(-(ball-dx b))(ball-dy b))]
[else (make-ball (+(ball-x b)(ball-dx b))(+(ball-y b)(ball-dy b))(ball-dx b)(ball-dy b))]))
;Main program start here
(big-bang (make-ball (/ WIDTH 2)(/ HEIGHT 2)44)
(on-tick next-ball)
(on-draw render-ball)
(on-mouse handle-mouse))

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!