Here is an example of how the game should look:
When you are finished, your game should contain the following:
To make the assignment easier, you may want to break it up into simpler stages such as:
Your test cases will be a major part of your grade on this assignment. Remember, many of your functions have graphical output, which makes them difficult to test. This puts an even greater burden on how well you test your non-graphical functions. We expect to see you sustain this burden.
You will want the following clipart images:
Remember, you can insert an image into your Racket code by selecting "Insert Image..." from the "Insert" menu, or by copying and pasting an image into your code. Your definition of an image to use for drawing would look like:(define MY-IMAGE
)
You may also find
the Racket documentation on big-bang
to be useful. You'll want a big-bang
that reacts to key-presses,
knows when to stop, can draw itself and continually moves the rocket. You'll
need to figure out which of the big-bang
clauses will allow you
to do this.
Remember to think about what you want in your world - and how you'll need to change your world before starting to program, and use the design recipe.
You will also find the Racket documentation on drawing your own images to be useful - especially on how to overlay one image above another in a given position.
For generating random numbers, look at the documentation on random
here.
You shouldn't have to copy-paste any code. If you find yourself duplicating code, you make wish to rethink the structure of your world.
Finally, you may want to look through the fully worked-out example of a universe program (Flight Lander) in How to Design Worlds. Note that the text uses an older version ofbig-bang
, so read it
for the ideas and most, but not all, of the code.
Your Racket should look like Racket, not Java. We expect you to follow the formatting conventions below:
(define (add-two num) (+ num 2))not:
(define (add-two num) (+ num 2) )
Name your variables using dashes to separate words. Don't camel case, don't use
underscores. You want
my-function
not MyFunction
, my_function
or My-Function
.
Try to keep the total length of your lines around 80 characters. You can bring arguments down to a new line if you have too many. Breaking up different arguments onto separate lines allows the reader to see what expressions are arguments to what other functions. This is much easier to read:
(a-very-long-function-name a-long-input-argument an-even-longer-input-argument an-even-even-longer-input-argument)than:
(a-very-long-function-name a-long-input-argument an-even-longer-input-argument an-even-even-longer-input-argument)
If you bring arguments down to a new line, many coders will put all of the arguments on their own line, even if multiple arguments could be fit on the same line. However, this depends on the coder.
Comments - you should have them and they should say things that the function name doesn't already say.
Constants - should be named in all caps with hyphens.
E.g: (define SOME-CONSTANT 2)
Again, you'll want to include the image.ss
teachpack to get access
to image processing function. You can find it in the Add Teachpack menu,
(Language/Add Teachpack) in the HtDP/2e section, in the center of the screen.
Also, since you'll be using world programming, please include Universe.ss
, from the same middle column.
And also remember to uninstall the 17.ss
teachpack while working with image.ss
.
rocket.rkt
, with code implementing the finished game.