Assignment 10
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.
(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:
- The game will be launched with a main function that takes in the tick-frequency (see the big-bang docs for on-tick).
- The output will be the score of the game which is the inverse frequency times the amount of ticks before the game ended (more on this below in hints). This is essentially “how long the player lasted times how impressive it was they lasted that long”.
- Every other tick a new word is generated. Do not generate words every tick.
- When a new word is generated, it should always be at the top of the screen, but where it will be along the x-axis should be random. Be sure the whole word fits on the screen.
- The text of the newly generated word will be randomly selected from some list of words. As long as you have two or more words in this list, that is fine. All words should be at least length 1 and be strictly alphabetical (no numbers/symbols) and lower-case.
- Words should always get stuck right before they go out the bottom of the gameplay section of the screen or before they overlap with a word already stuck.
- Falling and moving words should be shown with a different color.
- Every tick falling words should fall one row.
- The player should be able to see what they are typing.
- The player should be able to use backspace (even if the string is empty, so be careful).
- Hitting “enter” will trigger falling word elimination and will clear what the player was typing.
- All falling words that matched the user input after they hit enter will be cleared.
- The player entering anything like numbers or punctuation or special keys like tab should have no effect (unless you extend functionality).
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.
- 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 indepdently 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.
- 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.