What are some fundamentals that go into making a Tetris game?

  • (2 Pages)
  • +
  • 1
  • 2

19 Replies - 1305 Views - Last Post: 03 December 2011 - 05:12 PM Rate Topic: -----

#1 jakeks97  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 29-November 11

What are some fundamentals that go into making a Tetris game?

Posted 29 November 2011 - 08:19 PM

Hey everyone,

I was just wondering what aspects of C++ and SDL I need to know before/while I make a Tetris remake. Just to clarify, I mean like arrays, pointers etc... I have been using C++ for the past week or so and I am finding the concepts quite easy to grasp as I have used Visual Basic for 2 years prior so I don't think this is a 'bad' project for me to tackle first.

Thanks, Jakeks97
Is This A Good Question/Topic? 0
  • +

Replies To: What are some fundamentals that go into making a Tetris game?

#2 aaron1178  Icon User is offline

  • Dovakiin, Dragonborn
  • member icon

Reputation: 169
  • View blog
  • Posts: 1,298
  • Joined: 22-October 08

Re: What are some fundamentals that go into making a Tetris game?

Posted 29 November 2011 - 08:48 PM

Well, with any game it is a good idea to have a firm grasp on linear algebra and trig. But with programing, I would suggest that you look into arrays, structures, classes, pointers and maybe pick up a book on graphics programming.

Hope this helps
Was This Post Helpful? 1
  • +
  • -

#3 SixOfEleven  Icon User is offline

  • using Caffeine;
  • member icon

Reputation: 945
  • View blog
  • Posts: 6,342
  • Joined: 18-October 08

Re: What are some fundamentals that go into making a Tetris game?

Posted 30 November 2011 - 10:42 AM

For a Tetris remake you will definitely want an understanding of arrays. The play field is basically a 2D array that can either have a block in it or be empty. Pointers and classes would be helpful though you wouldn't technically have to use classes for this project but it does help.
Was This Post Helpful? 1
  • +
  • -

#4 Fib  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 161
  • View blog
  • Posts: 554
  • Joined: 12-March 09

Re: What are some fundamentals that go into making a Tetris game?

Posted 30 November 2011 - 12:03 PM

I feel that the fundamentals are arrays, pointers, memory management, drawing sprites, drawing strings (the strings may also be sprites) frame rates, and code organization (not required, but will help tremendously as the game increases in complexity).

Also with any game, it is important to understand what goes into a game loop.

Game Loop Example:

bool quit = false;

Initialize();
LoadAssets();

while(!quit)
{
     HandleInput();
     Update();
     Draw();
}



Also in a game loop, there needs to be some way to control how many times update and draw are called per second. In other words controlling the frame rate.

This post has been edited by Fib: 30 November 2011 - 12:05 PM

Was This Post Helpful? 1
  • +
  • -

#5 jakeks97  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 29-November 11

Re: What are some fundamentals that go into making a Tetris game?

Posted 01 December 2011 - 05:04 AM

Thanks for your advice - I have bought a few books (c++ in 21 days, beginning c++ game programming and API design for c++) so hopefully that allows me to learn more about arrays etc...!
Was This Post Helpful? 0
  • +
  • -

#6 anonymous26  Icon User is offline

  • D.I.C Lover

Reputation: 0
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: What are some fundamentals that go into making a Tetris game?

Posted 01 December 2011 - 03:17 PM

Why did you buy those books?
Was This Post Helpful? 0
  • +
  • -

#7 jakeks97  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 29-November 11

Re: What are some fundamentals that go into making a Tetris game?

Posted 02 December 2011 - 12:54 AM

View Postjakeks97, on 01 December 2011 - 05:04 AM, said:

Thanks for your advice - I have bought a few books (c++ in 21 days, beginning c++ game programming and API design for c++) so hopefully that allows me to learn more about arrays etc...!


Because I decided that i need to get better at C++ before attempting Tetris. Also API is for down the line... What books would you recommend?

Thanks
Was This Post Helpful? 0
  • +
  • -

#8 anonymous26  Icon User is offline

  • D.I.C Lover

Reputation: 0
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: What are some fundamentals that go into making a Tetris game?

Posted 02 December 2011 - 07:33 AM

Yeah, I gathered that. I've looked through those combo 'learn C++ with game programming', and I wouldn't recommend any of those types of books for the following reasons:

1. You won't learn as much C++ as a book dedicated to the language, which makes it bad.
2. They can only give you a very, very narrow perspective in programming games. Quite pointless.

Learn C and C++ to a very competent level first, then look into game programming.
Was This Post Helpful? 0
  • +
  • -

#9 jakeks97  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 29-November 11

Re: What are some fundamentals that go into making a Tetris game?

Posted 03 December 2011 - 04:38 AM

View PostButchDean, on 02 December 2011 - 07:33 AM, said:

Yeah, I gathered that. I've looked through those combo 'learn C++ with game programming', and I wouldn't recommend any of those types of books for the following reasons:

1. You won't learn as much C++ as a book dedicated to the language, which makes it bad.
2. They can only give you a very, very narrow perspective in programming games. Quite pointless.

Learn C and C++ to a very competent level first, then look into game programming.


I took your advice and have bought Thinking in C++: Introduction to Standard C++, Volume One (2nd Edition) (Vol 1)and The C++ Programming Language Special Edition.

Thanks for all of your advice.
Was This Post Helpful? 0
  • +
  • -

#10 jakeks97  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 29-November 11

Re: What are some fundamentals that go into making a Tetris game?

Posted 03 December 2011 - 05:14 AM

View Postjakeks97, on 03 December 2011 - 04:38 AM, said:

View PostButchDean, on 02 December 2011 - 07:33 AM, said:

Yeah, I gathered that. I've looked through those combo 'learn C++ with game programming', and I wouldn't recommend any of those types of books for the following reasons:

1. You won't learn as much C++ as a book dedicated to the language, which makes it bad.
2. They can only give you a very, very narrow perspective in programming games. Quite pointless.

Learn C and C++ to a very competent level first, then look into game programming.


I took your advice and have bought Thinking in C++: Introduction to Standard C++, Volume One (2nd Edition) (Vol 1)and The C++ Programming Language Special Edition.

Thanks for all of your advice.


I also forgot to mention C++ Primer Plus.
Was This Post Helpful? 0
  • +
  • -

#11 anonymous26  Icon User is offline

  • D.I.C Lover

Reputation: 0
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: What are some fundamentals that go into making a Tetris game?

Posted 03 December 2011 - 07:30 AM

Don't buy every book out there! You don't need to do that, as most information will be duplicated.

Go to a bookstore and browse the C++ books. Buy one that you feel is a comfortable read.

One book that I will certainly recommend is 'The C Programming Language' by Kernighan and Richie. Trust me, this book is gold. ;)
Was This Post Helpful? 0
  • +
  • -

#12 Serapth  Icon User is offline

  • D.I.C Head

Reputation: 53
  • View blog
  • Posts: 153
  • Joined: 17-August 11

Re: What are some fundamentals that go into making a Tetris game?

Posted 03 December 2011 - 12:41 PM

View PostButchDean, on 03 December 2011 - 07:30 AM, said:

Don't buy every book out there! You don't need to do that, as most information will be duplicated.

Go to a bookstore and browse the C++ books. Buy one that you feel is a comfortable read.

One book that I will certainly recommend is 'The C Programming Language' by Kernighan and Richie. Trust me, this book is gold. ;)


And horribly improper for a beginning C++ programmer. Its time to start treating C++ like the separate language it is. Recommending K&R C to a C++ programmer is like recommending a Porsche owner buy the Volkswagen user manual

Its a good book, remarkably concise and I highly recommend it; to C programmers.

As it sounds like you have enough books for now, you don't really need more recommendations, but C++ without Fear is a good book for beginners and Effective C++ is a must read, eventually.
Was This Post Helpful? 0
  • +
  • -

#13 anonymous26  Icon User is offline

  • D.I.C Lover

Reputation: 0
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: What are some fundamentals that go into making a Tetris game?

Posted 03 December 2011 - 12:50 PM

View PostSerapth, on 03 December 2011 - 07:41 PM, said:

And horribly improper for a beginning C++ programmer. Its time to start treating C++ like the separate language it is. Recommending K&R C to a C++ programmer is like recommending a Porsche owner buy the Volkswagen user manual

Actually, no. You are wrong. You should be aware that in programming games, you actually use both C and C++ - generally the closer you get to the hardware, the more C is used over C++. Secondly, Software Development Kits (SDKs) written to be used with the C and C++ languages are actually written in C (possibly with some C++) in their own implementation(s) for the reasons given just now.

View PostSerapth, on 03 December 2011 - 07:41 PM, said:

Its a good book, remarkably concise and I highly recommend it; to C programmers.

Correction, this is an outstanding book! If you can't see its worth then I have nothing to add.

View PostSerapth, on 03 December 2011 - 07:41 PM, said:

As it sounds like you have enough books for now, you don't really need more recommendations, but C++ without Fear is a good book for beginners and Effective C++ is a must read, eventually.

Those are good book in your opinion. I would suggest that the OP goes to a book store with the list that we have suggested, and pick out two at the most after having thumbed through them. Getting books with duplicate information is a waste of time and money.

This post has been edited by ButchDean: 03 December 2011 - 12:51 PM

Was This Post Helpful? 0
  • +
  • -

#14 Serapth  Icon User is offline

  • D.I.C Head

Reputation: 53
  • View blog
  • Posts: 153
  • Joined: 17-August 11

Re: What are some fundamentals that go into making a Tetris game?

Posted 03 December 2011 - 02:31 PM

View PostButchDean, on 03 December 2011 - 12:50 PM, said:

Actually, no. You are wrong. You should be aware that in programming games, you actually use both C and C++ - generally the closer you get to the hardware, the more C is used over C++. Secondly, Software Development Kits (SDKs) written to be used with the C and C++ languages are actually written in C (possibly with some C++) in their own implementation(s) for the reasons given just now.


I strongly disagree, on this, you are the one that is wrong. Recommending a C book to a new C++ developer is simply wrong, period. Of course there are aspects of C++ that are going to benefit from knowledge of C, as the language started as a superset ( I say started, as both languages have diverged greatly since 1983 and this is no longer factually true ). What language SDKs are written in has very little to do with what a new programmer needs to know, and the aspects of C++ that are still C will be covered in most modern C++ books. Suggesting a book like K&R C to a new C++ developer will lead them down the wrong path from day one. To this day you already see C++ programmers mixing new/malloc, streams/printf and various other constructs that do not mix. They are different programming langauges and should be treated as such. I am not saying there isn't value in picking up C at some point in time, but to suggest it when just starting out and learning, you are just muddying already murky waters and making it more difficult for the student.

Quote

Correction, this is an outstanding book! If you can't see its worth then I have nothing to add.


Seriously, you are going to argue over the amount of superlatives I used? I acknowledge K&R C as a good ( fine outstanding ) book, but that doesn't change the fact it is a poor recommendation for someone just setting out to learn C++.

Quote

Those are good book in your opinion. I would suggest that the OP goes to a book store with the list that we have suggested, and pick out two at the most after having thumbed through them. Getting books with duplicate information is a waste of time and money.


Well of course book recommendations are a matter of opinion, I hardly think when describing books you recommendations you need to preface with "In my opinion" as... well that is exactly what a recommendation is. That said, Effective C++ is pretty much universally praised as one of, if not the, greatest C++ book written. It is not for a beginner and he won't get too much out of it until you are ready for it. As I said earlier, the OP already has a number of good books and recommendations and really doesn't need more. I personally would recommend, especially for someone so willing to outlay so much cash on books, to consider subscribing to Safari Books Online. It's 40$ or so a month, but amazing value if you do a lot of reading. I try to get in 4 or 5 a month, so for me it is outstanding value. That said, if you can't read on a screen it may not be a great choice, but myself, combined with my tablet, it is great.
Was This Post Helpful? 0
  • +
  • -

#15 anonymous26  Icon User is offline

  • D.I.C Lover

Reputation: 0
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: What are some fundamentals that go into making a Tetris game?

Posted 03 December 2011 - 02:57 PM

View PostSerapth, on 03 December 2011 - 09:31 PM, said:

I strongly disagree, on this, you are the one that is wrong. Recommending a C book to a new C++ developer is simply wrong, period. Of course there are aspects of C++ that are going to benefit from knowledge of C, as the language started as a superset ( I say started, as both languages have diverged greatly since 1983 and this is no longer factually true ). What language SDKs are written in has very little to do with what a new programmer needs to know, and the aspects of C++ that are still C will be covered in most modern C++ books. Suggesting a book like K&R C to a new C++ developer will lead them down the wrong path from day one. To this day you already see C++ programmers mixing new/malloc, streams/printf and various other constructs that do not mix. They are different programming langauges and should be treated as such. I am not saying there isn't value in picking up C at some point in time, but to suggest it when just starting out and learning, you are just muddying already murky waters and making it more difficult for the student.

Your perception of how C and C++ is used in games shows a thorough lack of knowledge and experience in game development. If someone wishes to program games in C++, they will be writing some code in C without a doubt! Only the most basic games that anyone can write can you get away with pure C++ (whatever that is!).

All the work I have ever done in game development requires knowledge in C as well as C++. Also, if you go to a game programming interview it is likely you will also be tested on C as well. To dismiss C as a valuable language to learn in conjunction with C++ is extremely bad advice, and is one of the problems I have noticed with student programmers who know C++ to a fairly good level, but have little to no knowledge of C - that knowledge is seriously lacking and causes them problems that people like me end up fixing!

View PostSerapth, on 03 December 2011 - 09:31 PM, said:

Seriously, you are going to argue over the amount of superlatives I used?

I think I just did! :)

View PostSerapth, on 03 December 2011 - 09:31 PM, said:

Well of course book recommendations are a matter of opinion, I hardly think when describing books you recommendations you need to preface with "In my opinion" as... well that is exactly what a recommendation is. That said, Effective C++ is pretty much universally praised as one of, if not the, greatest C++ book written.

Really? Universally praised, pretty much? Okay. So is 'The C Programming Language' yet you dismiss the book as a good recommendation because it isn't a C++-specific book, which in itself isn't the most sound advice. If you are talking application programming then fine, stick with the C++-specific books, but for game programming, and professional game programmer like myself for instance, not knowing C and C++ and not knowing when each is appropriate is a fail.

View PostSerapth, on 03 December 2011 - 09:31 PM, said:

It is not for a beginner and he won't get too much out of it until you are ready for it.

Very wrong. As quoted from the Amazon listing of the book:

Quote

An indisputably classic computing text, Kernighan and Ritchie's The C Programming Language, 2nd Edition, is the standard reference for learning and using ANSI C. Written by the co-inventors of C, this concise tutorial has a well-deserved reputation for clarity and precision as it defines one of the most successful programming languages of all time. It's an essential reference, which will be useful for beginners and experienced programmers alike.


Also look at the table of contents, it starts you from the very basics.

You are assuming your opinion in a field that you clearly have very little experience of to be the truth. It is entirely up to the OP, but I would very strongly recommend they read this book first then approach the C++ one if they wish to write good games sometime in the future, or even work in the games industry. :)
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2