How long would it take to make Tetris?

Started by
19 comments, last by neXt 20 years, 1 month ago
OK, I haven''t finished learning C++ just yet, but I am going along slowly. I was just wondering how long ruffly it might take someone who only just learnt the basics of C++ to code a functioning game of Tetris?
Advertisement
2.5 hours.

-Maarten Leeuwrik
"Some people when faced with the end of a journey simply decide to begin anew I guess."
It really depends on how well you know C++ and how much time you have to work on the game. It took me about 5 months to get it working a little bit, i just wasnt interested in tetris and school was killing me anyway if you have a good grasp on most of the concepts and have time to learn some more, (you never finish learning programming stuff) you may be able to finish in a couple of months if its your very first game. Make sure you learn a decent graphics api too, gdi may be ok for a first game but make sure its the last time you use it you''ll understand what i mean if you do use gdi. you should then learn directx or opengl if your going to pursue game programming, hope i''ve answered your question. Excuse the rambling, its late and i tend to do that the later it gets and the more caffeine i drink.
A graphics

I was talking about a text-based tetris

-Maarten Leeuwrik
"Some people when faced with the end of a journey simply decide to begin anew I guess."
Ronin_54, I believe he asked how long it would take from someone who only just learned the basics of c++ . Of course it depends on how one defines "basics", but your time seems utopistic to me in any case. Programming a tetris involves quite a lot of things, like visually representing the game field, getting the user input, inverting arrays and all that jazz. Much of it goes beyond my definition of "basic level". Plus there's the factor that the programmer would be probably doing his first game, unsure of what to do and how to do. So I would say it is very likely that it will take a lot more time than two and a half hours. So stop depressing the beginners with such approximations!

[EDIT] I was a little slow. Well, anyhow.. This goes for a text-based tetris as well. [/EDIT]


rk

Edited by - rk on January 1, 2002 5:39:00 AM
Well, I got this really neat book called "Learn C++ in 21 days". Read it in a week. Started coding. Just plotting spaces at first, found some dos commando to change the background color. Jippie, I could create blocks.

Made a single class about blocks, a simple 2d array to store the game, and a function to get input (getch) and to check the keyboard (kbhit). Well, those are the main components

-Maarten Leeuwrik
"Some people when faced with the end of a journey simply decide to begin anew I guess."
I think alot of it depends on your level of logic.

Have you been thinking about what goes on when you play tetris? Do you understand how the field is represented? Do you know a logical way to get rid of lines and shift the rest of the field down?

When I made my tetris clone in OpenGL, I was amazed at how little OpenGL I actually used. Of course, I used a 2D view and didn''t really have any special effects or anything, but still, I''d say 75% of my time went into thinking about the logic of moving pieces, determining when the player has lost, etc, and 25% went into actually programming.

So, if you know the inner workings of Tetris extremely well, I guess you could do it in 2.5 hours. It took me about a month (on and off. School took most of my time. I could only work on tetris for a few hours a night)

Good luck
I got bored of my current project one day and tried a Tetris clone. Did it in about a day. No frills, but it had proper rotation (pushes away from other blocks and walls when turning), which the SNES version doesn''t even have (really; go check!) and worked great. I wouldn''t say it was "basic" though; I had a Tetrad base class which the other 7 inherited, and used polymorphism, calling member functions of the block to rotate, drop, etc. A bit complex for Tetris, but if you know that stuff, it makes it easy

Chris Barry

Jesus saves ... the rest of you take 2d4 fire damage.

Well, I think a very basic tetris (without any fancy effects) and no speed optimization could be easily done in 2.5 hours, even less. Not for a newbie, though.

Think about it, it''s really simple: grid is a 2d array, scroll down is easy, just data copy. Collision detection is brute force around the falling block. Check for filled lines is also a brute force approach. Test for gameover is simple.
I''d say around 20-30 min for the main game logic. 5-10 min for user input. 30 min or less for OpenGL graphics output. max 15 min. for everything else around it. Very basic, but it works.

I think I could do it in less than 1 hour, using a finished OGL framework (not typing all this WinAPI stuff, this takes time). We should try a competition some day
Anon, you''ve got to be one heck of a programmer to do it in an hour. It''s not as simple as people say it is. First how would you store where the current block is? Would you store it in your array or would you keep it seperate and add it to the array when it hits a block. Rotations, how would you do that. A lookup table? Pre-figured rotations? Collision detection: You''d have to test each current block for the block beneath it. Rotations again. You couldn''t allow a rotation that wasn''t possible meaning you have to do harder collision detection when it rotates. Showing the next block. When do you want to figure out what it will be. When the user fills a row? How will you do that. Will you store each type of block as a const int and randomize an integer number?

That''s just some of the logic. Now for drawing. Would you keep the blocks that are already there in an array? Would you keep the current block seperate from the array or would you keep it in the array also. When you draw the blocks, would you draw the blocks already still as a background and then the current block as a foreground. How would you store the block images in data. Would you store them as a single block and mix four of them to make a complete block? Or would you have the actual block pictures to draw on the screen.

Maybe I''m just rambling on but I''d be in awe if you could do it in under an hour

This topic is closed to new replies.

Advertisement