#lang s-exp "../../lang/wescheme.ss"
(printf "falling-ball.rkt\n")
(define-struct world (radius y))
(define WIDTH 320)
(define HEIGHT 480)
(define RADIUS 15)
(define INITIAL-WORLD (make-world RADIUS 0))
(define (tick w)
(make-world RADIUS (+ (world-y w) 5)))
(define (hits-floor? w)
(>= (world-y w) HEIGHT))
(check-expect (hits-floor? (make-world RADIUS 0)) false)
(check-expect (hits-floor? (make-world RADIUS HEIGHT)) true)
(define (render w)
(place-image (circle RADIUS "solid" "red") (/ WIDTH 2) (world-y w)
(empty-scene WIDTH HEIGHT)))
(check-expect (big-bang INITIAL-WORLD
(on-tick tick 1/15)
(to-draw render)
(stop-when hits-floor?))
(make-world 15 480))