-
Notifications
You must be signed in to change notification settings - Fork 1
david-fong/tetris
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
game.py: RUN THIS TO PLAY A GAME OF TETRIS Cell: An entry in a Game object's grid Game: Contains all representation of a game ShapeFrame: Displays a Shape object GameFrame: Displays and interfaces for a Game object TetrisApp: Packs a number of GameFrames together shapes.py: file with classes for representing shapes Pair: A coordinate pair that can produce a shifted version of itself Tile: A pair with four views (one for each 90 degree rotation around a pivot) Shape: A collection of Tile objects sharing pivot behaviour data.py: file with dictionaries used by game.py Instructions to edit for custom game settings below... ===================================================================================== NOTE: Any time you create settings for data related to a new shape size, You must create key bindings to access <shape size> stockpile slots. I. CREATING A NEW SHAPE SIZE, <n>: You will need to: 1. Add a dictionary entry, <n> to data.SHAPES, and add at least one key-value pair to it where the key is the string 'default', and its value is a dictionary of shapes with at least one shape in it (see II). 2. Add a dict entry, <n>, to data.COLOR_SCHEMES, and add at least one key-value pair to it where the key is the string 'default', and its value is a color scheme (See III). 3. Ensure that there are enough keybindings to access <n> slots (see III). 4. Add to data.DEFAULT_NUM_ROWS/COLS. II. ADDING YOUR OWN SHAPES (for an existing shape size): See data.SHAPES: It maps shape sizes to: a dict of named shape sets: Ie. a dict from shape names (string) to Shape objects, where the shapes consist of <shape size> or fewer tiles. In your shape sets, use the shape names as those in the default shape set: The colors from the default shapes will be used for your shapes. A Shape is constructed with a list of coordinate pairs following these rules: 1. Each coordinate pair is in the first quadrant: x, y >= 0. 2. The base of the shape must be longer than its height. 3. The base and height cannot exceed <shape size>. 3. The constructor expects that no coordinate pairs are duplicates. Within the constraints of those rules, the orientation is up to you. All rotation logic will be handled by the Shape constructor. When you create a new shape, you must give it a color (see III below). III. ADDING YOUR OWN COLOR SCHEMES (for an existing shape size): See data.COLOR_SCHEMES: It maps shape sizes to: a color scheme: Ie. a dict from existing shape names (See II) to color strings. A color string may be an english word such as 'green', or a hex string. Color words are system dependant. Not all words will work. Hex strings consist of a '#' followed by six HEX digits. (google 'hex color picker' for a helpful interface) IV. CREATING YOUR OWN KEY-BINDINGS (for an existing shape size): See data.BINDINGS: It maps a number of players to a player-bindings set: Ie. a dictionary from an action's special constant to a list of keysyms (strings) for a given player to perform that action. Run keysym.py, and press a key to display its keysym in the created window. Ideally, all players share the same bindings to pause the game. Avoid using 'Caps_Lock' for any key bindings, since other keys are case sensitive
About
2018 winter break project to learn python