Still not confident in my game programming skills in C++ and SFML

Started by
5 comments, last by Lightness1024 11 years, 4 months ago

Hi, I made some games in ActionScript 3 and recently switched over to C++ a month ago. I already knew some things about C++ because AS3 is quite similar to it. So I chose SFML as my API to use to create games with.

After going through this tutorial: http://www.gamefromscratch.com/page/Game-From-Scratch-CPP-Edition.aspx I learned quite a bit about SFML, but after finishing through it, I still don't feel very confident with using SFML and C++.

Can someone lead me in the right direction to make myself more confident with the language and API? Basically what I'm trying to say is, is that when I see C++ and SFML code, I understand it (well, most of it) but when I am trying to create my own, I am braindead, I don't really know what to do.


I am planning to recreate my games I already created in AS3, but of course, there's the barrier of me not being so confident as I was with AS3.

Thanks.

Advertisement

Well, you could start by creating a window. After that, you can make the window display images. Then perhaps animate those images. Then keep adding the features you need. Do things in the order of difficulty, from easy to hard, from simple to complex. You are at least confident that you can make a window, right?

as ultramailman mentioned, try not to look at it as one big task. when you do that, you'll get the ol' "step 1: everything" problem.

My suggestion is the take your simplest AS3 game and try to recreate that.

start with the basics, as already mentioned:

1) create a window

2) draw still images to the window

3) draw animated images to the window

4) handle basic keyboard controls, like knowing when a button is pressed

5) handle basic mouse controls, such as button click and mouse movement

if you can get those 5, that's the core for most of your other apps i'd imagine. Then you build features from there.

Personally, I always recommend people avoid external libraries (i.e. SFML, SDL, OpenGL, etc.) when first learning C++. Why? Because it's a heck of a lot to take in at first, and if you don't have a good foundation to build on and decently understand the language you're writing in, learning a library isn't going to do you a whole lot of good.

So maybe take a step back and work on purely C++. Make console games. You might be surprised to see how this "restriction" might actually help you think creatively.

If your "C++ foundation" is already properly laid, however, think of the simplest game you can. Maybe tic-tac-toe or Pong, and try to recreate it (and keep it simple!). Try to program "properly," but also don't shoot for perfection, because I'll tell you right now your code will be far from perfect in many of your early (and even later) projects.

[size=2][ I was ninja'd 71 times before I stopped counting a long time ago ] [ f.k.a. MikeTacular ] [ My Blog ] [ SWFer: Gaplessly looped MP3s in your Flash games ]
"I already knew some things about C++ because AS3 is quite similar to it."

That you would say this creates the impression you know practically no C++. These two languages are extremely different.

I think the most crucial question at this point is, what's your motivation in switching languages at this point? Why are you switching into C++ specifically? For most people, if their goal is to just keep developing their own games, C++ is overkill.

I half-agree with Cornstalks' advice. You can use external libraries if you like, but you must put serious attention to learning the features of the core language. One good resource for language detail is Sutter's GotW column: http://herbsutter.com/gotw/

To work effectively with C++, you have to understand and (eventually) remember a large portion of the stuff discussed in GotW. You don't learn it just by reading, of course; you should constantly try the things discussed on your own, and when there are recommendations or best practices, you should adapt some of your existing code to adhere to them.

Thanks for the recommendations!

Of course I know how to create a window :P I'll try what ultramailman and IkarusDowned are saying. When you break it down like that, it is actually seemingly easy. I think my problem is, is that I need to break things down into simple and easy steps and not stray off from what I need to accomplish in my project.

I don't think my C++ foundation is properly laid just yet, I still need a full understanding of pointers, inheriting, etc.

Stroppy Katamari, actually I beg to differ, their syntax's are similar, but not exactly the same. Such as creating functions, variables, while loops, for loops, etc. Obviously c++ is more esoteric and has more features/capabilities to it. I did go learn the basics of c++, what I meant when I said "I already knew some things about C++ because AS3 is quite similar to it" is that since I know AS3, learning the basics of C++ wasn't really that hard at all.

Anyways, Sutter's GotW is actually very, very helpful. If you have any more of these kinds helpful links, I will appreciate it.

I would say that you are right, in fact you didn't learn only a language (AS3), you learned imperative programming. which in any language of this paradigm, will break down to the exact same things and concepts (loops, ifs, functions..). Why, because the CPU is doing so.

There are other paradigms, like functional programming (lisp..), and logical programming (prolog..). Both have different way of thinking the program design/execution flow.

But indeed, knowing AS3 made you know C++, somehow. Of course, while this is true, it is also false because after the paradigm, there is all the rest: software engineering. And that one, is the big one. It takes a few weeks to master the imperative programming paradigm, it takes a few decades to master software engineering.

C++ is the one language that has all, or almost everything, and is also the one language that can actually not be mastered. Even the persons writing the standard are discovering new rules, new patterns, new ideas, new smells, new pitfalls, new must-not-do, on a monthly basis... and it is a real never ending live feed to learn programming (in C++ particularly).

So good luck on your way with that, I know I love that adventure.

GotW is a bit hard at first, I would recommend programming on yourself a bit, shooting yourself in the foot, you tend remember better things like that :)

After, you can go back to read the C++ faq lite and GotW as much as you want, and agree as an equal thinker to the great minds that wrote it. But going as a beginner, you will only be able to say "oh really, hmm, ok then I'll take the advice". Its funnier to have the experience to actually having come up yourself with what is said in those Faqs/GotW.

You will notice on those pedants sources, that the standard is mentioned quite a lot. It is actually a good thing to DO read it. However, the 2003 version is around 800 pages, the 2011 is around 1800 pages (or 1600?). It is a brain twister, it is like reading the civil code book. And if you are not native in english it is even more difficult.

But please, about this, take my advice : the very C++ standard paper, is a much better source than any book and tutorials/resource found on the net written by average Joe. Because more often than not, people who think they can go teach others, only learned through compiler reporting; which is a bad way, especially when that compiler is from microsoft.

but anyways.

If you have difficulties at planning the tasks, don't worry, it is actually full time job for many people in this world. And to do it, it requires to know what is possible, and how it is possible also, at last on a vague latent zone of your brain. You have difficulty planning things when you are too unsure about the way to do achieve it.

For example, if you want to draw a 3D rotating cube, and when you think about how to start, and you can't come up with anything, it is because you don't know how to do it yet. So you need to start draw 2D things instead, and suddenly things are getting clearer "ah yes, I know drawing a thing is drawing pictures or sprites, I know pictures because I have manipulated them in paint or so". You want to make it cross the screen "ah yes, I know I can use a loop to increment a position variable and draw at each iteration". Because you have imperative programming knowledge.

Just continue on this path and one day you'll arrive "Ah, the 3D cube, now I know i need a representation of the vertices in memory, a model matrix and a projection matrix, I need a line drawing routine, and maybe a timer to adjust the rotation speed..." etc etc

so just do like the others said, tic tac toe etc...

One last word, about SFML, it is actually a good library to start with because it has a good C++ design. If you had started with OpenGL for example, it would have taught you old C-style design.

good luck

This topic is closed to new replies.

Advertisement