Answered step by step
Verified Expert Solution
Question
1 Approved Answer
THIS EXERCISE SHOULD BE DONE IN BEGINNING STUDENT LANGUAGE IN DR RACKET. Functions to Avoid equal? equal~ ? eq ? eqv? assq assoc assv member
THIS EXERCISE SHOULD BE DONE IN BEGINNING STUDENT LANGUAGE IN DR RACKET. Functions to Avoid
equal?
equal~
eq
eqv?
assq
assoc
assv
member
member?
memq
remove
removeall Unless otherwise stated, for all function design problems you must provide i a signature, ii a purpose statement, iii checkexpects, and iv the actual code, in the language specified at the top of this page.
Unless otherwise stated, for all data design problems you must provide i a definition, ii an interpretation, iii examples, and iv a template.
Some exercises may require you to design additional data for full credit, even if this isn't made explicit in the question. A Simple Game
Work on designing a small program which allows you to move a dot by clicking the mouse. The program should display a black background with a white dot at some given initial location and then when the user clicks the dot should appear at the mouses location instead. To do this, we will follow the same steps for designing programs as we did in the previous lab.
Remember to do the full function design recipe for every bigbang handler, including checkexpects.
Step : What stays the same?
Exercise Define some constants to describe what stays the same throughout the game. What images will you need in order to draw the program?
Step : What changes?
The only thing that changes in this program is the location of the dot. How can we best represent this? Think about the types of data you know and choose one that represents a location in d space. This will be your world state.
Step : Which handlers do we need?
Exercise Write the signature and purpose statements for the handler functions you will need. Recall that bigbang always requires a todraw clause. Which other clauses will you need based on the program description? If you are having trouble take a look at the documentation, and if you are still confused, ask a tutor or TA for assistance.
Step : Main Function
Now that weve decided on our handler functions, we can put together our main function which will call bigbang. Recall that we write this function first because in this course we follow a top down programming approach. That means larger functions go at the top of our program and smaller functions go underneath.
Exerddot, starts up the bigbang program.
Step : Design your handlers
Exercise Design the handlers you decided on in step
Give your program a try! Recall that the dot should only change positions when the mouse is clicked, and not every time the mouse moves.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started