Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

this is my DrRacket code, i get define: expected at least one variable after the function name, but found none error, please help. This is

this is my DrRacket code, i get define: expected at least one variable after the function name, but found none error, please help. This is my homework : Design a game for preschool children to teach them colours, shapes and numbers. Your game must have a menu, scoreboard, game-over screen and multiple scenes for the game.

(require 2htdp/image) (define-struct shape (x y color)) (define-struct game-state (shapes score)) (define WIDTH 800) (define HEIGHT 600) (define SHAPE-SIZE 50) (define SHAPE-COLORS '(red blue yellow green)) (define MAX-SHAPES 5) (define (random-shape) (let* ((color (list-ref SHAPE-COLORS (random (length SHAPE-COLORS)))) (x (random (- WIDTH SHAPE-SIZE))) (y (random (- HEIGHT SHAPE-SIZE)))) (make-shape x y color))) (define (draw-shape shape) (overlay (rectangle SHAPE-SIZE SHAPE-SIZE 'solid (shape-color shape)) (text (shape-color shape) 12 'black))) (define (draw-state state) (above (text (format "Score: ~a" (game-state-score state)) 24 'black) (overlay (foldl (lambda (shape img) (overlay img (draw-shape shape))) empty-image (game-state-shapes state)) (rectangle WIDTH HEIGHT 'solid 'white)))) (define (update-state state) (make-game-state (remove-matched-shapes (game-state-shapes state)) (+ (game-state-score state) (count-matched-shapes (game-state-shapes state))))) (define (handle-mouse state x y button) (if (string=? button "left") (make-game-state (cons (random-shape) (game-state-shapes state)) (game-state-score state)) state)) (define (shapes-match? shape1 shape2) (and (equal? (shape-color shape1) (shape-color shape2)) (< (distance (shape-x shape1) (shape-y shape1) (shape-x shape2) (shape-y shape2)) SHAPE-SIZE))) (define (remove-matched-shapes shapes) (if (<= (length shapes) 1) shapes (filter (lambda (shape) (not (any (lambda (other) (shapes-match? shape other)) shapes))) shapes))) (define (count-matched-shapes shapes) (if (<= (length shapes) 1) 0 (- (length shapes) (length (remove-matched-shapes shapes))))) (define (game-over? state) (>= (game-state-score state) 10)) (define (handle-end state) (draw-state state)) (big-bang (make-game-state '() 0) (on-tick update-state 1) (to-draw draw-state) (on-mouse handle-mouse))

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Automating Access Databases With Macros

Authors: Fish Davis

1st Edition

1797816349, 978-1797816340

More Books

Students also viewed these Databases questions