7.4

Week 3 Set b

home work!

Programming Language BSL

Due Date Thursday 9/19 at 9:00pm (Week 3)

Purpose To finish our drone program and integrate it with big-bang.

Finger Exercises

Exercise 1 From HtDP, 97 98 99 100

Expectations
  • You should submit a single .rkt file containing your responses to all graded exercises via the Handin Server. We accept NO email submissions.

  • You are only allowed to use the language specified at the top of this page: failure to do so will result in a 0.

  • All elements of the design recipe are expected. Data definitions should have associated interpretations, examples, and templates. Functions should have signatures, purpose statements, tests, and code.

  • Note that there are few exceptions to these rules, such as main functions not being able to be tested.

  • Be sure to use helper functions when appropriate to keep code clear.

Graded Exercises

This assignment is a continuation of the work done with a DS in the last one.

Exercise 2 Design a function which draws the drone shoot. The photographer can be represented by a vertical rectangle of any color. The goal should be visually distinct from the rest of the ground-level. The drone, if any, should be represented by a black horizontal rectangle. The background on which all these images are placed should be a fixed size.

Be sure to use constants (and helper functions!) to keep your code as clean as possible. Also, remember that in our data definition, (0, 0) is at the bottom left, but the image library has (0, 0) at the top left!

Exercise 3 Design a function which given a DS and a KeyEvent launches the drone if it is not already in flight and the given key is "l". This should put the drone 20 pixels in the air and 15 pixels to the right of the photographer. If the drone is in flight and the given key is either "up", "right", or "left", it should move the drone 5 pixels in that direction.

Exercise 4 Compose your above functions into a big-bang program, wrapped inside a main function. The game should stop when the shoot is over, and the drone should fall 1 pixel every 1/10 of a second (see and use your code from last week’s assignment).

The function should take in an initial DS and output whether or not the shoot was a success.