Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


I learned C++ and SFML, What now?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
11 replies to this topic

#1 _greyfox()   Members   -  Reputation: 1133

Like
0Likes
Like

Posted 18 June 2012 - 04:49 AM

Hi good people!

OK, So I am learning C++ for more than a year now. I have watched some online tutorials (which sucked) So I decided to buy a book. I have read the book and I can say I am comfortable with the language now. After that I read some documentations on SFML. Now i'm trying to make Arkanoid, Breakout clone. But I don't know how to do things, what classes I should write, how every class interacts with each other. How to handle maps. And I need to learn some math about vectors and stuff. But I can't find a book or tutorial that covers it all...
I can find books but they are written for 3D games, and 3D maths. I don't know what to do. I'm REALLY lost...

I would like to hear how YOU learned to program games. What did you read, what tutorials have you read/watched? And how much math do I really need to learn.
“There are thousands and thousands of people out there leading lives of quiet, screaming desperation, where they work long, hard hours at jobs they hate to enable them to buy things they don't need to impress people they don't like.”― Nigel Marsh

Sponsor:

#2 Inuyashakagome16   Members   -  Reputation: 835

Like
2Likes
Like

Posted 18 June 2012 - 06:39 AM

Have you checked out http://www.gamefromscratch.com/page/Game-From-Scratch-CPP-Edition.aspx ? Great set of tutorials using SFML and C++ to make a small Pong game. Not a huge game, but still enough to give you an idea what you'll need.

#3 _greyfox()   Members   -  Reputation: 1133

Like
0Likes
Like

Posted 18 June 2012 - 07:33 AM

Have you checked out http://www.gamefroms...PP-Edition.aspx ? Great set of tutorials using SFML and C++ to make a small Pong game. Not a huge game, but still enough to give you an idea what you'll need.

Yeah I have checked it. But this is TOTALY not enough. It is really awesome article. Only if there could be more...
So yeah... I guess i'm doomed
“There are thousands and thousands of people out there leading lives of quiet, screaming desperation, where they work long, hard hours at jobs they hate to enable them to buy things they don't need to impress people they don't like.”― Nigel Marsh

#4 szecs   Members   -  Reputation: 2172

Like
1Likes
Like

Posted 18 June 2012 - 07:37 AM

I learned by doing. At the time I didn't have internet or programmer friends, so apart from some very basic stuff, I made games on my own.

I guess that's the best way: doing it. Not just reading some book or maybe do the exercises in it.

For the specific examples you wrote:

1. What classes should you write? Well, that's a reason why I don't think learning C++ as a first language is good. Starting to think in classes up front is not a beginner topic in my opinion, but maybe I'm wrong about that one. Just hack for starting. Heck the shit out of the code so you learn what can be done or not, what leads to an unmaintainable mess, and what not etc.

2. Class interaction: the same as above (again: it's just my opinion, someone correct me if I'm wrong). Don't think in therms of classes, think in terms of desired behaviour, functions, and how you can break down bigger tasks to smaller ones that you can tackle, test, whatever. The more precisely and detailed you design the behaviour, the closer you will be to actually implementing it.

3. Map handling. There's no "map handling". There is file loading (not necessarily), arrays, data in the arrays, and accessing/manipulating the data.

4. Yup, you have to learn some maths, some "vector algebra" most importantly.


Maybe you should start smaller. Like Pong.


So to sum up: start small, invent and hack, and learn by trying things out on your own, not from some game making tutorials. you have to learn problem solving, and you can only do that on your iwn. Tutorials are only good (in my opinion) for very specific things, like explaining the use of specific features of specific APIs. Just like documentations. Use them as references but don't try to learn to think from them.


(I have the feeling there there are some BS in my post, but anyway...)

Edited by szecs, 18 June 2012 - 07:42 AM.


#5 _greyfox()   Members   -  Reputation: 1133

Like
0Likes
Like

Posted 18 June 2012 - 07:51 AM

I learned by doing. At the time I didn't have internet or programmer friends, so apart from some very basic stuff, I made games on my own.

I guess that's the best way: doing it. Not just reading some book or maybe do the exercises in it.

For the specific examples you wrote:

1. What classes should you write? Well, that's a reason why I don't think learning C++ as a first language is good. Starting to think in classes up front is not a beginner topic in my opinion, but maybe I'm wrong about that one. Just hack for starting. Heck the shit out of the code so you learn what can be done or not, what leads to an unmaintainable mess, and what not etc.

2. Class interaction: the same as above (again: it's just my opinion, someone correct me if I'm wrong). Don't think in therms of classes, think in terms of desired behaviour, functions, and how you can break down bigger tasks to smaller ones that you can tackle, test, whatever. The more precisely and detailed you design the behaviour, the closer you will be to actually implementing it.

3. Map handling. There's no "map handling". There is file loading (not necessarily), arrays, data in the arrays, and accessing/manipulating the data.

4. Yup, you have to learn some maths, some "vector algebra" most importantly.


Maybe you should start smaller. Like Pong.


So to sum up: start small, invent and hack, and learn by trying things out on your own, not from some game making tutorials. you have to learn problem solving, and you can only do that on your iwn. Tutorials are only good (in my opinion) for very specific things, like explaining the use of specific features of specific APIs. Just like documentations. Use them as references but don't try to learn to think from them.


(I have the feeling there there are some BS in my post, but anyway...)


Thanks! Your post really helped me out.
“There are thousands and thousands of people out there leading lives of quiet, screaming desperation, where they work long, hard hours at jobs they hate to enable them to buy things they don't need to impress people they don't like.”― Nigel Marsh

#6 ZeroBeat   Members   -  Reputation: 522

Like
1Likes
Like

Posted 18 June 2012 - 07:55 AM

Just pratice really. I used xoax.net to get a foot on C++ and then I found some tutorials online how to make a win32 project. And I had Sams Teach Yourself C++ in 24 Hours book. I followed along the book and the tutorials but I was making my own stuff rather than what they were doing. My goal was a small rpg text game. Which I was able to make somehow.

I guess similar to how you are feeling now, I felt kind of lost just following tutorials from the very begining. When I tried to do my own stuff, I was like frozen so to say.

While making that game, I acutally thought I would quit C++. Its too complex and I didnt know what the hell I was doing. There is a learning curve and you can only get over it by experiance and not giving up I guess. My little text game saw 3 revisions. But as I build it up, I started to see that my class design didnt work. Thought how to do it better.
I started planing things. Just a small plan.

Slowly you would get better and see how things are connected and how to make better classes. Initially there was only 1 class. But by breaking up the game and building it up step by step I got better.

Dont worry you are not doomed. Just relax a bit. Take a step back. Maybe try to plan the classes on paper to see how they make look like in the game. Who knows, maybe it would work ;)

#7 Inuyashakagome16   Members   -  Reputation: 835

Like
1Likes
Like

Posted 18 June 2012 - 08:06 AM


Have you checked out http://www.gamefroms...PP-Edition.aspx ? Great set of tutorials using SFML and C++ to make a small Pong game. Not a huge game, but still enough to give you an idea what you'll need.

Yeah I have checked it. But this is TOTALY not enough. It is really awesome article. Only if there could be more...
So yeah... I guess i'm doomed

It at least gives you a framework of sorts to understand. You should be looking at each part individually, not the whole picture.

I learned by doing. At the time I didn't have internet or programmer friends, so apart from some very basic stuff, I made games on my own.

I guess that's the best way: doing it. Not just reading some book or maybe do the exercises in it.

For the specific examples you wrote:

1. What classes should you write? Well, that's a reason why I don't think learning C++ as a first language is good. Starting to think in classes up front is not a beginner topic in my opinion, but maybe I'm wrong about that one. Just hack for starting. Heck the shit out of the code so you learn what can be done or not, what leads to an unmaintainable mess, and what not etc.

2. Class interaction: the same as above (again: it's just my opinion, someone correct me if I'm wrong). Don't think in therms of classes, think in terms of desired behaviour, functions, and how you can break down bigger tasks to smaller ones that you can tackle, test, whatever. The more precisely and detailed you design the behaviour, the closer you will be to actually implementing it.

3. Map handling. There's no "map handling". There is file loading (not necessarily), arrays, data in the arrays, and accessing/manipulating the data.

4. Yup, you have to learn some maths, some "vector algebra" most importantly.


Maybe you should start smaller. Like Pong.


So to sum up: start small, invent and hack, and learn by trying things out on your own, not from some game making tutorials. you have to learn problem solving, and you can only do that on your iwn. Tutorials are only good (in my opinion) for very specific things, like explaining the use of specific features of specific APIs. Just like documentations. Use them as references but don't try to learn to think from them.


(I have the feeling there there are some BS in my post, but anyway...)

That's very true. Start small, LIKE PONG. I started with SFML with that tutorial I posted and I edited a few of the classes and played with the shapes. All of that is experience and learning you'll need.

#8 DFPercush   Members   -  Reputation: 106

Like
1Likes
Like

Posted 18 June 2012 - 08:29 AM

I actually got into game programming by learning how "Metroid" worked. Not the best example for a pc-based modern game though.
As far as 2d games go, it's a lot easier than 3d, so that's one advantage of starting with a breakout game. Basically you're dealing with sprites, and backgrounds which are just bigger sprites that get drawn first. A 2d "map" is usually represented by an array. You can make it a static 2d array like map[100][100], or you can make it a 1d and use math to figure out how to translate from 2d coordinates to a 1d array offset:
[source lang="cpp"]offset = (coordY * width) + coordX;[/source]
Each element in the array would be a tile number, and you could then render the image for that tile to the screen. Put that in 'for' loops for x and y and you've got yourself a map. For ease (not so efficient) you could just store a separate sf::Image for each tile. I'm not sure if SFML lets you render only part of the image or not, but what I've done in the past with DirectDraw (before it was obsolete) and windows GDI, was to basically have a "tileset" image divided into a 16x16 grid of tiles. Then you c an find the x/y coordinates of the tile you want within the source image by:
[source lang="cpp"]sourceY = int(tileNum / tilesPerRowInSourceImage) * tileHeight;sourceX = int(tileNum % tilesPerRowInSourceImage) * tileWidth;[/source]
Of course that's limited to 256 tiles, but you can make the dimensions larger. If you're using openGL textures though, you want to make your source image size a power of 2 or certain drivers might try to do a messy resize on it. I usually reserve tile # 0 for transparent.

One caveat is that certain image formats and GL textures put the origin (0,0) at the bottom-left of the image, while some systems start at the top left. If that happens just use (height-y) obviously. Not sure about SFML, I'm just starting to learn that myself.

There's a free program called "Mappy" that might be good for designing your levels. That will give you some test data to work with at least. It can save a raw format that you can just binary read into your map array. It's based on that second approach where all the tiles are stored in a single image.

One major hurdle to overcome is how to handle collision detection. There are math formulas on the internet for this, if you know the right math jargon to look for. You'd probably want something like "line segment intsersect test". There's one that can tell you the exact coordinates where it intersects. I like it better than a simple yes/no test because it lets you get right up to the edge. What I did once upon a time was to loop through all the non-zero tiles on the screen, and for each edge of the tile, figure out the x/y coordinates of the line that represented that edge. Then calculate the line segment from the current position to next frame position of the ball, and see if these intersect. (Edit: This can be optimized by only looking at tiles which are near to the ball. You can also eliminate half the edges by paying attention to the velocity of the ball. if it's traveling right, you only need to check the left edges of tiles, and so on.)

As for classes, it's really not necessary to make it fully OOP, but it wouldn't hurt to learn how to make a proper OOP project. I would at least have a class for the paddle or "Vaus", maybe one for user input cause you want to store the state of the input devices every time you get an input event from SFML, and probably one for the map. If you can manage to display a basic tile map I think you'll start figuring the rest of it out from there. Good luck! Posted Image

Edited by DFPercush, 18 June 2012 - 08:40 AM.


#9 Cornstalks   Crossbones+   -  Reputation: 6991

Like
3Likes
Like

Posted 18 June 2012 - 09:22 AM

Now i'm trying to make Arkanoid, Breakout clone. But I don't know how to do things, what classes I should write, how every class interacts with each other. How to handle maps. And I need to learn some math about vectors and stuff. But I can't find a book or tutorial that covers it all...

One of the best things about programming is that it doesn't matter if you know exactly to do. You learn every day. Just take a stab at it. Practice. You won't get it perfectly right the first time (or the first several times), but you sure as heck will learn a lot.

And if you can't find resources online to help you, here's what you can do: take your best guess at solving it and do your best. Once you hit a roadblock or can't get your head around something, come and post on these forums, showing people what you want to do, what you've tried, and what the problem is. You'll learn a lot.
[ 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 ]

#10 _greyfox()   Members   -  Reputation: 1133

Like
2Likes
Like

Posted 18 June 2012 - 11:07 AM

Thanks guys! You gave me some really good advice's. I don't use forum very much (I made only 6 posts or so) But from now I'm going to use it more often :)
“There are thousands and thousands of people out there leading lives of quiet, screaming desperation, where they work long, hard hours at jobs they hate to enable them to buy things they don't need to impress people they don't like.”― Nigel Marsh

#11 GameCreator   Members   -  Reputation: 771

Like
3Likes
Like

Posted 18 June 2012 - 12:46 PM

Now i'm trying to make Arkanoid, Breakout clone. But I don't know how to do things, what classes I should write, how every class interacts with each other. How to handle maps. And I need to learn some math about vectors and stuff. But I can't find a book or tutorial that covers it all...
I can find books but they are written for 3D games, and 3D maths. I don't know what to do. I'm REALLY lost...

I would like to hear how YOU learned to program games. What did you read, what tutorials have you read/watched? And how much math do I really need to learn.

I haven't read the other responses but:

For a Breaktout and Arkanoid clone, you don't need vectors. You can work just with x and y and their respective velocities. Will being comfortable with vectors help? Sure.

I learned very early on (many years ago) by copying code from books and then modifying them. Today, this is equivalent to taking examples from SFML and changing them around. Or take pieces you want from each. It's really just a matter of practice and experimentation.

Finally, being on forums is a great thing. Posting "stupid" questions here and other forums helped me a lot because there are some nice people out there. When you can, try to reciprocate and help others in turn. You'll still learn things too and people will appreciate it as much as you did.

Edited by GameCreator, 18 June 2012 - 12:56 PM.


#12 wicked357   Members   -  Reputation: 1174

Like
3Likes
Like

Posted 19 June 2012 - 07:58 AM

Thanks guys! You gave me some really good advice's. I don't use forum very much (I made only 6 posts or so) But from now I'm going to use it more often Posted Image


Thats good this place is a great resource for all sorts of information and help. When I started I was doing a school project that threw me into DirectX 9 for my first game. It was rough but don't focus on all the bloat of what is in a game atm. Focus on the basic structure of how a game is programmed. From there think in parts till you get a good grasp of what you want to do. For instance, create a window in SFML... from there add a shape like a rectangle which SFML is ready to create already with one simple line. Then look at taking in user input to move the shape around.

I know that might sound very elementary but reading only gets you so far, putting it to use is where you will do most your learning. Try writing it out first with what you want to accomplish, sometimes this helps to see the bigger picture. Try not to take on too much it is good to challenege yourself but too much can be overwhelming and highly discouraging. Even stay away from graphics if you are not comfortable yet and make some console type games, like random numbe guessing game, hangman, text-based RPG (doesn't have to be big just a few rooms with objects in it and maybe a monster or two) that can actually be a fun project.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS