Often the working-out-the-small-details process that precedes the implementation of a program is the most fulfilling--and FRUSTRATING--part of programming.
overheard somewhere in the CIT...
Who needs to know about my squares? Well, my pieces each have 4 squares. My board displays my squares. My board's border is made up of squares. My board is actually an 2D matrix of squares. My users control my squares with keyboard presses--or do they? Don't my users only see pieces?
How much must my square class know? A square is one-fourth of a Tetris piece. A square moves left, a square rotates, a square moves right, a square falls down the board at regular intervals, a square can drop at the touch of the space bar. A square has a color and a position and x coordinates and y coordinates. A square can stop in mid-air when paused. A square can land on top of another square. A square can become part of the Tetris board, part of a filled horizontal row that removes itself and causes all rows above it to redraw themselves in lower positions. A square can receive messages from other squares. Sometimes a square can move around generously. Sometimes a square can move around a little bit. Sometimes a square can't move around at all.
Every class in the diagram has a name, a title bar...I know, I'll make my Storyspace lexias refer to Tetris classes! First I have to make my Tetris classes! Damn, I still haven't made my Tetris classes! The Design check is due in 2 days! I'm hungry. It's 6:26 pm. I'm going to Josiah's for a spinach rollup.
My squares can't occupy the same spaces on the board that other squares occupy. In order to move around, my squares must check to see if the space where they want to move is free. What really is a "free" space in an array of squares? If my piece is orange and my board is black, isn't a "free" space just a black space? So can't I make my squares ask the squares around them for their color in order to decide whether they can move around or not? Oooooh. A boolean. IsBlack() returns true, square moves. IsBlack() returns false, square stops.
( i write | i program | i have a homepage | i take an english class )