Jump to content
  • Advertisement
Sign in to follow this  
Samtor

Teris principles

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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:

click here, 4th post

Share this post


Link to post
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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!