Public Group

# Teris principles

This topic is 4764 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi Everyone, I've started an attempt at making my first game. I'm trying to make a Tetris clone, as suggested in the excelent article written in the beginners section of this website. Basically i'm stuck! What i've done is written the code so that it draws a gaming area then it builds an invisable grid in the back ground, which i call the logical grid. The logical is an array of structures. Each structure contain the x,y coordinates of the top corner of each block in the logical grid and a state variable to say weather or not is active. The idea behind it is that i can just tell the program to paint blocks at say grid number 5 or check the state of grid block number 20 and so on. So the logical grid is a kind of organizing structure (for want of a better description). But i get the feeling i'm making it to complicated for myself but i cant really see any other effective way of doing it! So my question really is, is there a universal or generic kind of way that Tetris is made? Many thanks, Samtor

##### Share on other sites
I think you're making things a little too complicated. The way Tetris is usually done is to have a grid as a simple array of integers. The number in the array is either 0 (empty) or a non-zero value indicating the colour of the block occupying that space. Since it is a grid, coordinate values are already known for each block. The block the player is currently moving is generally drawn separately.

##### Share on other sites
Just use an array slightly larger than the actual playfield... comes in handy when you move your pieces far to the left or right, because they are normally 4x4. I already explained it in another post earlier:

##### Share on other sites
Thanks for your help. I think your right in that i was making it over complicated for my first time. Although i think the way i was doing it might have worked if i'd thought about it for longer. Oh well lesson number one learned 'dont over complicate things'. I'm also using DirectX 9. Which i was having trouble translating it into code but i think i'm going to try and separate the logic from the graphics as it where. So i'll have my array keeping track of whats going on in the game then have the graphics, using a separate array to reperesent whats going on in the game array. As oppsed to having the array store graphical info such as grid points aswell as the active states of the blocks.

Samtor

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 17
• 14
• 10
• 9
• 11
• ### Forum Statistics

• Total Topics
634094
• Total Posts
3015498
×