Jump to content

  • Log In with Google      Sign In   
  • Create Account

Concepts needed to make Tetris


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 Lesic   Members   -  Reputation: 107

Like
0Likes
Like

Posted 24 May 2012 - 06:28 PM

Hi community. The summer is here for me, and I am going to college next year. I will be majoring in Computer Science. I want to accomplish something this summber, so I decided to make a classic game, tetris. I know the basics of game programming, and I choose C# and XNA to make the game. I don't want to watch tutorials and follow the instructions to make a game, so I want to know the concepts I need in order to make a tetris game. Then i will learn what I need, and hopefully I can create a game. Any advice is welcomed and appreciated, thanks.

Sponsor:

#2 frob   Moderators   -  Reputation: 22718

Like
3Likes
Like

Posted 24 May 2012 - 10:38 PM

Start with a basic game loop. You have to know how to write code that won't block, code that doesn't leak memory or resources, and otherwise runs robustly.

You'll use XNA to display stuff, so naturally you'll need an understanding of math through algebra for a 2D game. You'll need to learn about textures and surfaces and displaying text, and so on.

The game itself can be played as a simple text-based set of boxes or as a set of pretty graphical boxes. Either way, the core game is identical. Personally I'd recommend you start with a plain text version just so you can focus on making the game instead of making an animation system. You'll need some understanding of arrays, but the game is simple enough that you don't need more complex math to implement it. You just need to test if you can move the shape to the next coordinate, and if so, do it.

Next you'll probably want to make it graphical. Moving a well-written game core over to a graphical system is very straightforward; instead of drawing text you draw images. Of course, if you didn't go the route of writing a text-based set of boxes first then you are likely to confuse the two, ending up with trying to move a hybrid collection of graphical objects inside a logical space. Don't do that unless you feel like not completing your project in a timely manner.

You'll want menus to display your game options, your game credits where you can state how awesome you are, high score screens, etc. That means either hard coding the menus or writing a more complex system that enumerates the available menu choices and sends the commands off to the controlling system; it is more work but more versatile. Since your goal is writing a quick-and-dirty game, I suggest hard coded menus for now.

You don't want the scores to vanish when the game is started over, so you'll need to learn enough about serialization to save and load the scores and other info. Fortunately C# makes this very easy. You may also want to save and load a game in progress, again C# makes this very easy.


You may be interested in the TDD Tetris example at https://github.com/orfjackal/tdd-tetris-tutorial. It is in Java, but they walk you through the first half of writing a Tetris style game that is fully self-testing. They start off with a text-based board, work their way up through text-based pieces, then provide a simple set of directions to go through the rest of the game. Once you have that working in C# it would be pretty easy to add an XNA front end to it.

Check out my book, Game Development with Unity, aimed at beginners who want to build fun games fast.

Also check out my personal website at bryanwagstaff.com, where I write about assorted stuff.


#3 jbadams   Senior Staff   -  Reputation: 19350

Like
0Likes
Like

Posted 25 May 2012 - 06:03 AM

You may be interested in the TDD Tetris example at https://github.com/orfjackal/tdd-tetris-tutorial. It is in Java, but they walk you through the first half of writing a Tetris style game that is fully self-testing.

What an excellent resource, thanks for sharing that link! Posted Image

#4 Lesic   Members   -  Reputation: 107

Like
0Likes
Like

Posted 25 May 2012 - 05:06 PM

Thanks Frob, do you have advice on the collision detection system, and on the shape transformation system?

Edited by Lesic, 25 May 2012 - 05:07 PM.


#5 frob   Moderators   -  Reputation: 22718

Like
0Likes
Like

Posted 25 May 2012 - 09:18 PM

Thanks Frob, do you have advice on the collision detection system, and on the shape transformation system?

There isn't really much to collision detection. You check each of the four tiles to see if there is a blank space in that direction. Four tests along the lines of if(occupied(x,y)) and you're done.

Rotation is similarly not very difficult, especially if you follow the step-by-step tutorial I linked to above.


Check out my book, Game Development with Unity, aimed at beginners who want to build fun games fast.

Also check out my personal website at bryanwagstaff.com, where I write about assorted stuff.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS