Sign in to follow this  
johns700

suggested C++ API for beginner

Recommended Posts

johns700    122
Hey, I've just been looking through the 'Suggested projects for beginning programmers' section of this website and saw projects like Tetris and Pacman which say to use an API of your choice when making these games. I was just wondering what API I should use when starting out and trying to create games like these??? Any suggestions would be greatly appreciated! Cheers

Share this post


Link to post
Share on other sites
Gage64    1235
I would suggest SFML.

Although it has less resources than other popular libraries (SDL, Allegro), it is object oriented and (IMO) easier to work with.

Besides, once you've learned the basics of SFML (from the tutorials on the website and the documentation), you'll probably be able to read tutorials that use other APIs and translate the code to SFML.

Share this post


Link to post
Share on other sites
BlackSeeds    156
I used Allegro. for some of my early 2d stuff found it easy to use and has a good community, I found it easy to get into with some examples and reference materials. I haven't used it for ages as I have been just working on 3D. But certainly had fun using it :)

Share this post


Link to post
Share on other sites
NicoG    172
For pure Windows I would stick to http://hge.relishgames.com/.
This is a fairly easy to use 2D-Api. For XPlatform-2D I would point you to Clanlib or Allegro.
If you want to start out directly with 3D, I would recommend Irrlicht.
regards

Share this post


Link to post
Share on other sites
daviangel    604
Yeah do yourself a favor and use something like Allegro or SDL that has a short learning curve compared to straight win32 api or MFC that I'm using right now to make a tetris game!

Share this post


Link to post
Share on other sites
ManTis    1025
I suggest that you DON'T use C++ as a first language. Unless of course you developed in it for years now and want to try games programming. If so, SDL is always a good choice. If not, try out Python or C#, you'll save yourself TONS of grief. No, "But ManTis, all professional games are made in C++, lulz!" is not a good argument.

Share this post


Link to post
Share on other sites
Quote:
Original post by ManTis
I suggest that you DON'T use C++ as a first language. Unless of course you developed in it for years now and want to try games programming. If so, SDL is always a good choice. If not, try out Python or C#, you'll save yourself TONS of grief. No, "But ManTis, all professional games are made in C++, lulz!" is not a good argument.


That's just your opinion. c++ has many advantages over other languages. It's by far the most portable language (especially when talking about non-pc platforms). There are more c++ engines available and they are more mature. And it doesn't force you to use a garbage collector.

Share this post


Link to post
Share on other sites
Julian90    736
Quote:
Original post by captainfreedom
Quote:
Original post by ManTis
I suggest that you DON'T use C++ as a first language. Unless of course you developed in it for years now and want to try games programming. If so, SDL is always a good choice. If not, try out Python or C#, you'll save yourself TONS of grief. No, "But ManTis, all professional games are made in C++, lulz!" is not a good argument.


That's just your opinion. c++ has many advantages over other languages. It's by far the most portable language (especially when talking about non-pc platforms). There are more c++ engines available and they are more mature. And it doesn't force you to use a garbage collector.


C is more portable then C++.

Share this post


Link to post
Share on other sites
ManTis    1025
Quote:
Original post by captainfreedom
Quote:
Original post by ManTis
I suggest that you DON'T use C++ as a first language. Unless of course you developed in it for years now and want to try games programming. If so, SDL is always a good choice. If not, try out Python or C#, you'll save yourself TONS of grief. No, "But ManTis, all professional games are made in C++, lulz!" is not a good argument.


That's just your opinion. c++ has many advantages over other languages. It's by far the most portable language (especially when talking about non-pc platforms). There are more c++ engines available and they are more mature. And it doesn't force you to use a garbage collector.


You consider 'forcing you to use a garbage collector' bad thing for a beginner? Did you even read my post? Notice that I'm not arguing that C++ is in any way worse than those languages. It just has more traps and pitfalls that beginner (and experienced ones too) programmers tend to fall into. Language with less quirks is a solid recommendation, especially if it's as powerful as those two.

Share this post


Link to post
Share on other sites
Jovan    100
Quote:
Original post by johns700
Hey, I've just been looking through the 'Suggested projects for beginning programmers' section of this website and saw projects like Tetris and Pacman which say to use an API of your choice when making these games.

I was just wondering what API I should use when starting out and trying to create games like these???

Any suggestions would be greatly appreciated! Cheers


Hi johns700,

This might be a bit hard for you to believe, but the above posts are delusive in helping you. You should not start game programming with C++. You will fall into a lot of problems with the language it self.

This forum has seen an incredible amount of newcomers wanting to begin game programming with C++ and/or start their first game off as another WoW/MMO clone. Blank truth: it just isn't happening. I'll explain why. There are a few problems with C/C++, which I will explain now:


  1. C, and consenquently C++, does not shield the programmer from the system. The memory is almost-fully exposed to you and it's quite easy to mess things up like having game objects that do not exist. Put another way: C was originally used to program an Operating System known as UNIX; C++ adds a poorly implemented model that's oriented around objects/classes to a language that's oriented around procedures/functions. Hell ensues.

  2. Continuing from number one, this makes debugging a nightmare, and for beginners reading things like core dumps and following addresses and basically "why something happened" is very very hard, you have to understand the language and what it does underneath to understand some of the errors that arise.

  3. Continuing from number two, the language is quite big and you have to remember a lot of things to figure out why something happened the way it did. In short, you'll have to read an introductory book on programming in C++, followed by a few books that discuss the topics that no one else discusses, then read the reference book by the author of C++, Bjarne Stroustrup.

  4. And finally, there are parts of the language that are not explicitly defined. That is, who knows what might happen.

  5. Last but not least, C++ is a general purpose language meant for programming for the hardware to programming every day applications. This is NOT something you want for a game because it exposes you to things you shouldn't have to think about when programming a game.



Instead, I reject the posts above and urge you to try basic "game development" suites meant to ease you into harder stuff (such as C and C++). Afterwards, you can use a few languages that aren't as "harsh" as C or C++.

Firstly, there's the suite known as Multimedia Fusion 2, or MMF. A few of my friends made games this way very quickly.

Secondly, there is another suite known as Game Maker. GM is akin to MMF in a few ways so take your pick.

Now, you can use a programming language that is less likely to cause you problems. Unfortunately, you still have to read the manuals. The good part is, these languages are thought out and they provide walkthroughs and tutorials.

There is Python. Python has a moderately good game library called PyGame. Note their C++-poking logo. Python is clear and has good documentation.

As a side note, a lot of modern C++ games use Python or some other scripting language to actually hide as much C++ as possible. They do this for more practical reasons other than the fact that problems are harder to detect when using an "open" language like C or C++.

Either way, I hope this has persuaded you to not use C++ as your first game programming language, as it has a high chance of leading you to failure.

Share this post


Link to post
Share on other sites
MaulingMonkey    1730
Quote:
Original post by captainfreedom
Quote:
Original post by ManTis
I suggest that you DON'T use C++ as a first language. Unless of course you developed in it for years now and want to try games programming. If so, SDL is always a good choice. If not, try out Python or C#, you'll save yourself TONS of grief. No, "But ManTis, all professional games are made in C++, lulz!" is not a good argument.


That's just your opinion. c++ has many advantages over other languages. It's by far the most portable language (especially when talking about non-pc platforms). There are more c++ engines available and they are more mature. And it doesn't force you to use a garbage collector.


"That's just your opinion." C++ has many disadvantages over other languages, especially when approached as a first language. It's rife with undefined behavior, it's hard to debug, and it indulges in one of the most complex grammars out there. This is evidenced by it's comparatively huge compile times, and it's lack of portability between different compilers, and it's poor intellisense support. Worse, this complexity isn't put to good use -- instead, it's just the consequences of it's messy evolution from C, adding even more brittleness to the code.

Undefined behavior and this complex grammar, in turn, makes one of the very foundations of learning -- trial and error, experimentation -- both hard and very misleading in what it teaches, which is very bad when you're already struggling with the basics of programming. This isn't just opinion, this is fact.

While C++ has it's place, and it can very easily be a good idea to learn it at some point, this does not mean it's what we recommend for a first language. It's a good idea to learn multiple languages "eventually" anyways.

I'd recommend C# (with XNA or SlimDX), or Python (with PyGame), unless, as ManTis already mentioned, you're already experienced with C++.

Share this post


Link to post
Share on other sites
Ezbez    1164
Quote:
Original post by captainfreedom
That's just your opinion. c++ has many advantages over other languages. It's by far the most portable language (especially when talking about non-pc platforms). There are more c++ engines available and they are more mature. And it doesn't force you to use a garbage collector.


These threads always do turn into C++ vs. the world, don't they? This one wasn't even a "which language?" thread. No, C++ is no the most portable language. By any measure where C++ would do well, C would do better. By any *sane* measurement (like, say, of platforms that a beginner could want to target), Java and Python would crush C++. Both of those languages allow you to deploy once and target many, many platforms. Many programs can get away with absolutely no code change for different platforms. Yes, there are more "C++ engines" available, but most of them have bindings to other languages or there are others in other languages that are better (eg: SFML has bindings in like half a dozen languages. C# has XNA which is a great choice for a beginner. Torque is available on C# also). And not using a garbage collector is usually a bad thing, and always is a bad thing for a beginner.


And on the actual question, I haven't used SFML, but it seems very high quality. I used SDL, which is also great, but SFML seems to be at least as good. I'd recommend one of those.

Edit: Woa, lots more posts. I must, however, take fault with Jovan, even though I agree with him for most of his post. Jovan states on that beginning game programming with C++, "it just isn't happening." That's blatantly false. Many, many people have started with C++ and made games with it. That doesn't mean that C++ is the best choice, which is where I agree with Jovan again, but C++ is possible. Pretending that it is some killer beast that will eat your brains out as soon as you write your first open bracket is just as wrong as those that say that C++ is a great choice to begin with.

Share this post


Link to post
Share on other sites
ManTis    1025
Just to clarify: 'experienced' in C++ does not mean 'I wrote hello world last week' or 'I'm reading a really good book, Total Noob's Learn C++ in 24hours for dummies'. Don't want to sound patronizing, but C++ takes AGES to become experienced in it.

Share this post


Link to post
Share on other sites
Maybe you guys should read the actual title of this thread. The OP is looking for a good c++ api.
In other words, he has already decided to use c++. It's a free country, people are allowed to use any language they want and just maybe he has good reasons for using that language.

Share this post


Link to post
Share on other sites
Jovan    100
Quote:
Original post by captainfreedom
Maybe you guys should read the actual title of this thread. The OP is looking for a good c++ api.
In other words, he has already decided to use c++. It's a free country, people are allowed to use any language they want and just maybe he has good reasons for using that language.


No one can ultimately stop him. I'm just trying to persuade him to try something else, and telling him exactly why he shouldn't use C++ because he is looking for "suggested projects for beginner programmers".

Share this post


Link to post
Share on other sites
johns700    122
Wow! Thanks for all the the advice guys. It has given me a much better idea on where I should begin, although I haven't quite made my mind up yet...

I do have experience with C# but was told that C++ was the way to go if I wanted to develop games (as it is the industry standard?) so I thought I'd switch to C++. However, after reading through the replies maybe I will start developing games in an easier language like C# or Python and then maybe switch to C++.

If any one else has any thing to add to the discussion I'm glad to listen.

Thanks heaps guys!





Share this post


Link to post
Share on other sites
NicoG    172
hmm, perhaps you guys should just take into account that he perhaps is ready or willing to take these pitfalls and become a good programmer. Well, yes, a Game is a bad thing to practice / learn C++, but it is a way to do it.
I haven't started with Games, I started with Console Apps and I fell in all those little Pitfalls you mentioned, especially pointers where a long time a book with seven seals for me until a friend of mine(he studies Electronics and Machine Programming here in Germany (Robots and that stuff)) explained me in 4 hours how they work :D and how to use them.
And perhaps the OP also wants to work through all that like many others did....
Just my 2 Copper
rya

edit:
If you have exp. with C# use it. There are also some apis for C# I think. If you want to switch to the "real programmers", ok just kiddin', if you want to do that I described above, then goto C++.
Its your choice. I didn't regret it.

Share this post


Link to post
Share on other sites
MaulingMonkey    1730
Quote:
Original post by captainfreedom
Maybe you guys should read the actual title of this thread. The OP is looking for a good c++ api.
In other words, he has already decided to use c++. It's a free country, people are allowed to use any language they want and just maybe he has good reasons for using that language.


Maybe you shouldn't make too many assumptions based on the title of threads. While "just maybe he has good reasons", the converse is also true: He may not have good reasons. We provide the dissenting opinion that we do so that he can make an informed choice. Should he choose to do so, the original poster can always reply to provide their rationale and reasons if they feel they're applicable, and this often happens. Until then, all but they are in the dark, and given the amount of knee-jerk FUD that tends to justify such decisions, it'd be irresponsible to not ensure everyone has a chance at an informed decision.

We even explicitly acknowledged one of those possible "good reasons" -- simply knowing C++ already. See where we're coming from?

Quote:
If any one else has any thing to add to the discussion I'm glad to listen.

Since you mentioned experience with C# and I forgot to mention this: For 2D games like Tetris and Pacman, you could even just use the System.Drawing stuff. Just overload the Paint event for a form and use the eventArguments.Graphics object and you should be able to draw things on the form:


using System.Drawing;
using System.Windows.Forms;

Image example = Image.FromFile(@"C:\foo\bar\image.png");

private void ExampleForm_Paint(object sender, PaintEventArgs e) {
// Clear the entire form:
e.Graphics.Clear( Color.Pink );

// Draw an image in the center -- x/y are the top left corner of the image:
int x = Width/2-example.Width/2;
int y = Height/2-example.Height/2;
e.Graphics.DrawImage( example, x, y );
}

Share this post


Link to post
Share on other sites
ManTis    1025
And I heartilly recommend XNA, as it handles not only graphics, but also input, sound, networking, however deep you want to go. I use it for making games and level editors, even though at work I have to code in C++.

Share this post


Link to post
Share on other sites
johns700    122
Ok cool, well thanks for everything guys. After reading all your comments I've decided to start making games using C# and XNA to get a feel for making games and the concepts involved.

On the side I will start learning C++ by reading through books and stuff I guess. After I comfortable with both (making games with C# and using C++) I will move onto making games using C++.

I feel that this is the best path for me at the moment.

Thanks for everything!!! Was a great help hearing everyones opinions.

Share this post


Link to post
Share on other sites
Maveryck    122
Go Java!!! :D

Personally, I believe it comes down to a person's motivation as to which programming language to learn first. It's not a right or wrong choice, to learn C++ over Python, it's simply a decision that one person makes, that another would not.

Me. I started with Java, and w/very little programming knowledge - a little VBA, but nothing beyond that.

At the time, it was everyone's opinion that I should start w/Visual Basic.NET. Nope, stubborn bastard that I am, I forged ahead and hit the ground running, then cursing, kicking, screaming and threatening to toss the computer out the window, when a simple applet wouldn't run correctly. But, I believe that every programmer, beginner or experienced goes through these throes of frustration thoughout their programming endeavors.

Bottom line...It's a personal choice. Currently, I'm learning C++ with the hope & plan of eventually moving into game programming. Does knowing Java give me a better advantage at learning C++? Some would say no, others would say yes. I say...who gives a poop. I'm gonna learn it anyway.

Maveryck.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this