can someone post some tetris code

Started by
8 comments, last by sirGustav 18 years ago
ok so everyone says to start with tetris, well ive been trying to follow along with some guides on how to program it, but none of them provide a pieced together source code, so could someone give me a link to the source code of a tetris clone?
Advertisement
Hmm.. there's not much to it. Look on sourceforge.net, I know there are tetris games there. LTris comes to mind.

Really, there's nothing to tetris. Move the piece down. If it will hit anything already on the board next move, make it part of the board. If there is a full row, remove it, move the rest down. Put a new piece on the board. Pretty easy. But yeah, look on sourceforge, you'll find tetris clones there.
too bad i have no idea how to draw an object in a window =/

ive been trying to learn openGL but its kinda confusing, although i heard its easier than DirectX. also im only 14 so anything past regular C++ programing and into making games is a bit of a stretch :p though i hope to learn OpenGL and DirectX by the end of high school and at least make a few games.
Quote:Original post by knightmare99
too bad i have no idea how to draw an object in a window =/


You don't need tetris source code then, you need books and study. It might be a bit soon for you to be jumping into OpenGL and DirectX, start with easy 2d APIs. Try SDL, it's easy and pretty minimal. Clanlib is also good, but gets heavy on the OO stuff, and has a lot of features you won't really need. Plus, there are a LOT of SDL tutorials out there to get you started. But remember, tutorials are just that, to get you started! There's no substitution for reading the docs and practice, practice, practice! Don't expect to magically know everything when the time comes.

As for programming in general, get a copy of "The C++ Programming Language". It might be a bit heavy for you, but get through it. You need persistence if you're going to get on your feet so far ahead of the curve. 90% of the headaches newbies face are compiler errors having to do with the language itself, not understanding them, and spending countless hours googling for a solution. Knowing how to solve problems when they come up only comes from reading and experience.

Or you could go an easier route. I would suggest Python and Pygame. Python is not as fast as C++, but it's a dynamic, highly-reflective language that's generally easy to work with. Of course, it requires learning a whole new language, but there are at least 2 free books for learning python on the web, and a LOT of good documentation.
well theres no way im leaving c++ because i did read through one of those books on the language in general and i am pretty comfortable in programing in general, its just that this is the first time ive steped into making a program draw things, well that is outside of win32 programming, but win32 is really just about calling messages and procedures that windows include files already have there for you.
I've got some here
"Don't try. Do it now."
Who told you to start with a Tetris clone? Have you first tried making number games, text-based games, etc...? If so, you might consider making a Pong clone for your first game that uses graphics. Before getting caught up in how to make either game, you'll need to learn how to draw a sprite to the screen and be able to move it (at least). You don't need to move to SDL or Python or anything else, sounds like you just need a beginning game programming book.
Quote:So where do I start?

Tetris.

Tetris is the perfect game to begin your journey on the path to becoming an able bodied game developer. Why? Because Tetris contains the all the elements found in every game, and can be done with just about the least amount of work. Also, you don't have to be an artist to make a good looking Tetris game.


thats why im starting with tetris

also if by text games and number games you mean stuff that pops up in a console window then yes, i have.
Tetris coed!
Tetris clone in an hour with C++

This topic is closed to new replies.

Advertisement