6.8

Assignment 10

home work!

Programming Language BSL or BSL+

Due Date Mon 2/20 at 11:59pm

Possible Points 106

Purpose To design a large program.

Typaholic!

Every new piece of data requires the four steps of the design recipe for new data.

Every new function requires the four steps of the design recipe for functions.

Your assignment this week is to implement Typaholic! in big-bang. Typaholic! is a type-training video game in which words fall from the sky and stack up as they reach the bottom. If you enter a word as it falls the word is cleared from the screen. Once it has reached the bottom, though, it is stuck there. The game ends when a newly-generated falling word overlaps with a stuck word. Here is a link to a sample video of gameplay.

If you would like your game to look like the one in the video, the following are the graphical constants that were used:
(define GRID-HEIGHT 40)
(define GRID-WIDTH 40)
(define CELL-HEIGHT 15)
(define CELL-WIDTH 15)
(define ACTIVE-COLOR "green")
(define TYPING-COLOR "purple")
(define STUCK-COLOR "red")
(define SCENE-HEIGHT (* GRID-HEIGHT CELL-HEIGHT))
(define SCENE-WIDTH (* GRID-WIDTH CELL-WIDTH))
(define SCENE (empty-scene SCENE-WIDTH SCENE-HEIGHT))

Details:

Feel free to extend the game with additional functionality (down arrow speeding up the game, a loading menu, words moving sideways, being able to use left/right arrows when typing, etc.) but no extra credit will be given unless all of the above specifications are met and the design recipe is followed.

Hints:
  • The output of big-bang is the last state the world was in before someone quits or stop-when returns #true. Use this last state to compute the score.

  • on-tick is the most complex part of this game. Break it down into the steps it takes and use helpers. Keep in mind every function should have one job (this is always true). Take care in the order you call the helper functions, too, so you don’t do something like move falling words before you check whether or not they need to become stuck words.

  • We recommend adding the following two functions to your wishlist:
    ; maybe-generate-new-moving-word : ? -> ?
    ; Maybe generate a new moving word if it's the appropriate time
     
    ; generate-new-moving-word/text : ? String -> ?
    ; Generate a new moving word with this text
    where ? is your data definition for the world.

  • explode is a function that breaks up a string up into its list of 1Strings (strings of size 1) and should be useful when rendering a word.

  • big-bang clauses work independently of each other. When writing the on-tick clause, only think about what changes over time. When writing the to-draw clause, only think about how to render the world. When writing the on-key clause, only think about how the world changes when someone enters a key. When writing the stop-when clause, only think about what causes the game to stop.

  • Use string-alphabetic? and check the length of the string to see if the player input just a letter ("tab", for example, is alphabetic, but not just a letter).

  • Start early.

  • Test thouroughly.

  • Adhere to the design recipe the entire way through.

  • Come to office hours if you need any help or just want to check that you’re on the right track.

Note: This homework, unlike every other this semester, is designed to be equivalent to two assignments (which is why we did not have a Monday assignment this week). Because of this, it will be graded as two homework assignments. For example, if the grade received is 93/106, the student will receive a 53/53 and a 40/53. This is done so that the "drop the lowest grade" policy cannot be abused. It will have ultimately little effect on students who complete the assignment. Beware the grade displayed on blackboard will be out of 106. This splitting calculation will be done at the end of the semester by the course staff.