Jump to content
  • Advertisement
Sign in to follow this  
Supaflyfrank

Programming Tetris

This topic is 4078 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

I am thinking of creating a Tetris game in C++. My question is how would I represent the blocks in the game. I was thinking that I could simply represent the already fallen pieces in an array. Also I can have all the pieces be represented by a base class called Piece and Extended it to the various shapes. But what I am wondering how should I represent the fallen piece? Should I create a new object and delete it as soon as it on top of the other blocks? Just curious on how this is taken care of. Any suggestions?

Share this post


Link to post
Share on other sites
Advertisement
Making a single piece class is easier. A really object oriented design could have separate classes for pieces and shapes, with 6 instances of the shape class to represent the 6 pieces (each instance would contain the data for its shape). I usually just hard code the shapes into the piece class itself and use a number to track which shape it is supposed to be.

Really you don't even need to use classes at all. It's simple enough that you could easily code it without classes (unless you're using a language like Java).

For the fallen peices, just delete the peice and add its blocks to the board. In normal tetris, once peices land it is only the blocks they are made of that matter.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!