|
-
September 18th, 2008, 02:04 AM
#5
Re: Overriding color of drawn rectangle: how?
Hhhmmm...
the colors of my pieces are overridden by the drawrect() method
and where exactly is that happening? I dont see any calls to drawRect(), I see you placing the paint back to black, but that matters not, since there is no further drawing since.
Rest is given with the understanding, that I do not know, how close this is to the standard implementation of Tetris.
May be a bit out of original scope, but in my most humbled opinion, you are attempting to do things a bit more difficult than you would need to. Each piece in a traditional tetris, while being of variable shape, consists of blocks of equal size. Thus you could see your board, as a two dimensional array. Each Piece would know what color they are and that they occupy these "points" in the grid. "Board" keeps understanding of all the pieces in the grid, which Pieces themselves call upon and update.
Point of the whole sermon, is... do always try to avoid, as much as possible, needing to place actual progman logic in graphics painting. Do your utmost to keep the painting part as simple as you can.
And as to the color, both line color and fill color, they should be properties of the piece. Upon painting the board would simply ask for them, then fill / outline the parts of the grid they Piece occupies. Collision detection and all such are simple to handle outside pixel swetting paint.
http://java.sun.com/products/jfc/tsc...ing/index.html
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|