A Little Game Design Problem (2D Array)

wfunction

Well-known member
Joined
Oct 31, 2006
Messages
46
Programming Experience
1-3
I am creating a game (Tetris). Everything is going well, but I have a small problem:
Graphics (and the general coordinate system) takes an ordered pair (x, y) for the location, which is opposite to that of arrays (row, column), because row is actually y. How do I fix this problem? It wouldn't help to reverse them, because then the painting is done sideways and looks weird.

Also, how should I implement a Board class internally (keep an array of Pieces, etc.)?

Thanks!
 
I dont see the problem? How has the way that something is stored in memory got any problem with how it is shown on screen?

If your board is 10 wide x 30 high, what is the prblem with making your array 10 x 30?
Or even if you made it 30 x 10, i still dont see how its an issue to blit it on screen, just turn the array loops round so they read many Y for every X, not many X for every Y...

just remember that graphics Y go DOWNWARDS.. 0,0 is the top left, but from maths we classically think of it as bottom left.. its all realtive and doesnt matter in the slightest, once youre aware of it!


Also, your last question is rather huge. We dont really do homework on this forum...
 
Back
Top