Teaching
2500 F '11
 
Assignments
The Hand In
Set 1
Set 2
Set 3
Set 3h
Set 4
Set 4h
Set 5
Set 5h
Set 6
Set 7
Set 6h
Set 8
Set 7h
Set 9
Set 8h
Set 10
Set 9h
Set 11
Set 10h
Set 12

Problem Set 3h

Due date: 9/26 @ 11:59pm


Honors-section homework

HtDP Problems

6.3.2, 6.4.2, 6.5.2

Cowabunga!

In many parts of the world, UFOs have been abducting cows. This should not surprise you, as you are a UFO pilot who has been sent on just such a mission. As you have probably been warned, however, the base of your UFO is made of a special alloy that cannot be allowed to come in contact with the ground. Your task, therefore, is to land your UFO atop a cow without crashing on Earth... which, as you may have heard, can turn you into a participant in certain "experiments".

The goal of this problem set is to practice designing data representations using structures and functions for processing such forms of data.

How the game works:

A cow is placed at an initial position on the bottom of the screen. The cow moves left at a fixed speed until hitting the left side of the screen at which point it changes direction and moves to the right until hitting the right side, and so on.

A UFO is placed at an initial position at the top of the screen. The UFO moves downward at a fixed rate. The UFO can be moved left/right by pressing the left/right arrow keys.

The game is over when the UFO hits the ground or the cow. The game should indicate in some way whether the game was won (UFO hits cow) or lost (UFO hits ground).

Cows and UFOs

  • Design a data definition for UFOs and Cows.
  • A UFO has an X and a Y coordinate.
  • A Cow has an X coordinate and is either going left or right.
  • Define a function that moves a UFO down by some fixed amount.
  • Define a function that moves a UFO either left or right by some fixed amount.
  • Define a function that moves a Cow in the direction it is going by some fixed amount.
  • Define a function that determines if a Cow is at the edge of the screen.
  • Define a function that flips the direction of a Cow.
  • Define a function that moves a Cow in the direction it is going, unless it at the edge, in which case, the Cow should flip directions, and then move.
  • Define a function that determines if a UFO has captured a Cow.
  • Define a function that determines if a UFO has crashed on the ground.
  • Define a function that determines if the game is over.

Animation system

  • Define a data definition for Worlds. A World has a UFO and a Cow in it.
  • Define a function that handles key events (maybe moving the UFO left / right).
  • Define a function that renders the World as a Scene. Define a function that "ticks" the world (moves the UFO down and moves the Cow).
  • Use the big-bang system to start the game.
Enjoy!

last updated on Tue Nov 29 19:02:43 EST 2011generated with Racket