Jump to content

  • Log In with Google      Sign In   
  • Create Account

I know a good amount of C++ but what do i need to know about game programming?


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
16 replies to this topic

#1 Zero_Breaker   Members   -  Reputation: 367

Like
1Likes
Like

Posted 28 July 2014 - 03:39 AM

After getting competent enough with C++ i had this problem for a while.

 

Even though I could read code properly when the code was from a command line program, when it came to a pong SFML program i was confused even though i used the documentation to see if i could understand the code i was very confused because i don't know how game programming works.

 

I searched the forums and saw that there were similar problems but not exactly like my problem.

 

I realize that there are way too many more things to learn about game programming other than just C++ such as the main game loop and frame movement etc.

 

So my question would be, how would i design game programs?


Edited by Zero_Breaker, 28 July 2014 - 03:47 AM.


Sponsor:

#2 jHaskell   Members   -  Reputation: 1022

Like
0Likes
Like

Posted 28 July 2014 - 06:05 AM

What game programming tutorials have you run through?  The SFML tutorials aren't a bad starting point, but those mainly focus on the SFML API.  There are plenty of good tutorials on this site, and Google will pop up plenty more.

 

If you have a solid grasp on C++, then the next big step is to understand graphics programming which falls into two categories.  Concepts that are largely API agnostic (ie what is a texture, pixel, sprite, coordinate systems, etc), and then of course the specific graphics API that you will be using.  C++ itself has no graphics capabilities whatsoever.  SFML, SDL, DirectX, etc.

 

Once you have the basics of drawing something to the screen, you can then look at the game loop, moving sprites around on the screen, dealing with collision detection, and so on and so forth.



#3 Zero_Breaker   Members   -  Reputation: 367

Like
0Likes
Like

Posted 28 July 2014 - 06:29 AM

I see. It makes sense because i was so stressed because at the moment because i don't get why after learning a good amount of C++ and getting used to it i still don't understand programming enough and i can't see why i cannot understand or write code that simply moves a circle left and right.



#4 Althar   Members   -  Reputation: 329

Like
1Likes
Like

Posted 28 July 2014 - 10:15 AM

Programming is easy - engineering software is a completely different ball-game.

 

I would recommend Game Engine Architecture by Jason Gregory for understanding what components are involved in making games - based on that, even if you do not understand all of it, you should have the insight to look deeper into particular subjects (game states, AI, game objects, etc.) 

 

Otherwise, +1 for SFML which is a good framework to work from; you may also find that Gameplay3D is good starting point, as it focuses on games specifically (which is not the case of SFML, which is, as its name states, a multimedia library.



#5 Zero_Breaker   Members   -  Reputation: 367

Like
0Likes
Like

Posted 28 July 2014 - 12:41 PM

I will check out the Game Engine Architecture but what i mean is i don't know how to use SFML to create a game because i do not know how you would use SFML or a game engine that requires scripting to create a game since i don't know how to design the way the game works.

 

I don't how i am supposed to structure my classes,functions,variables,pointers to make a game and i certainly don't know much game programming related techniques when you use a framework such as SFML.

 

For example i didn't know that to make a circle move left or right on a screen requires you to go into vectors and timed movement and etc. I think game programming is something completely different then your regular command line programs which greatly help your understanding of how things work.



#6 Althar   Members   -  Reputation: 329

Like
0Likes
Like

Posted 28 July 2014 - 12:54 PM

If you are really unsure about how to go about writing interactive software, I would suggest a middle-ground between something visual/shiny & your familiar command line : a Hangman.

 

It sounds really "basic", but you would be surprised the amount you will learn from it :

 

  • Displaying the state of the game on-screen : ASCII text & symbols will do
  • Handling user input : cin & standard line prompt will probably do the trick & I will assume you are familiar with printing & reading basic key inputs
  • Score logic to monitor how well the player is doing
  • Game states (once the player guesses the word, make him progress to a more complicated word)
  • File loading : you can learn how to load external content into the game to expand the list of words.

It is quite a common "mini-project" for novice programmers to take on, so chances are you will find a ton of resources on the web as well as a myriad of ways to approach and solve the problem.


Edited by Althar, 28 July 2014 - 12:54 PM.


#7 dejaime   Crossbones+   -  Reputation: 4027

Like
0Likes
Like

Posted 28 July 2014 - 02:14 PM

I like to think of games as simulations with fancy looks and with made up rules. Some of them are real-time, some aren't, some have a really complex UI, some doesn't.

 

The best way I found to understand the inner workings of a game software (that is not that different if you really have C++ experience) is by creating one.

Get the simplest of all, not real time, no fancy graphics, no fancy rules. Just go for a memory game like this one, for example.



#8 Zero_Breaker   Members   -  Reputation: 367

Like
0Likes
Like

Posted 28 July 2014 - 02:22 PM

@Althar Thanks i will try that out. But the problem is that there so many game programming concepts that i just feel very overwhelmed by and don't know what to do. I bought the SFML game development ebook but it didn't explain things very well to me and some of the code introduced in the book was missing which gave me a lot of errors and bugs whenever i compiled the program example.

 

EDIT: @dejaime Thanks i will try that but i wasn't trying to make anything fancy with looks. I was just trying to make a circle move left and right on screen which is quite difficult to do with SFML for me.


Edited by Zero_Breaker, 28 July 2014 - 02:28 PM.


#9 Althar   Members   -  Reputation: 329

Like
0Likes
Like

Posted 28 July 2014 - 04:13 PM

All I can say is : have patience & persevere.

 

Start small & things will start to click. There is no shame in doing "simple things", as long as you do them well and understand the full extent of what it is you are doing. You will most certainly learn a lot more than say spending 2 years trying to desperately piece together a 3D MMORPG game by copying and pasting code from various tutorials / web until your brain starts to melt before your "Franken-code".

 

Expect to be overwhelmed with things you do not understand time and time again - this happens to us all, all the time; even the grey wolves who have been in the industry for donkeys, can feel "lost" when faced with a new system, API or even platform...



#10 Endemoniada   Members   -  Reputation: 312

Like
0Likes
Like

Posted 28 July 2014 - 07:36 PM

If I were you I wouldn't even consider using an existing game engine or framework. Start small and work your way up. 2D is the way to go at first, maybe a tile based game where you move one tile at a time (with no animation). Learn how to get stuff to the screen, once you can do that it's just a matter of what to put where and when. Your programming will get better as you go along as well, you're sure to learn new concepts and put them to work in a real-world application.


Edited by Endemoniada, 28 July 2014 - 07:36 PM.


#11 Zero_Breaker   Members   -  Reputation: 367

Like
0Likes
Like

Posted 29 July 2014 - 12:25 AM

@Althar I guess that's the truth really. I am not trying anything complex either the thing is i am trying to do very simple things so i get used to things and i have no shame in doing simple things because how can you make a complex program if you can't even make simple programs? I also don't copy and paste because it a very bad practice unless you know the code and you re-write it so i don't copy and paste most of my code.

 

I just felt very overwhelmed and lost when i came across SFML and the game development book was not explaining some game programming concepts well enough for me.

 

The first project in that book was to make a sprite just move left and right on the screen with no collision detection which i thought should've been understandable but was quite complicated and cryptic for me.

 

I also don't learn much from most tutorials, some of them are helpful but most are meh to me, i prefer fully fledged books which have a good amount of explanation although there are some books which are full of fluff and take time to get to the point and there are some which are not well explained enough and cryptic but most of the books i get are straightforward (C++ Primer 5th edition) and help me learn better.

 

@Endemoniada I tried to use Unity 3D to make a simple 2D platformer but i couldn't because back then i didn't understand programming enough and yeah i want to make 2D game first after several simple C++ and SMFL projects.

 

And just for the record i am not trying to make a full blown 2D action game yet, i am trying to to do simple projects like making a shape pop up on the screen and make it move left and right. Just wanted to point that out but yeah i guess you guys are correct and that is that i should just get stuff on the screen and do simple things and i would eventually get the concepts after a while. Thanks for the advice guys :)



#12 tonemgub   Members   -  Reputation: 1116

Like
4Likes
Like

Posted 29 July 2014 - 01:49 AM

"Full fledged" books are not really that useful once you get past learning a programming language. For games, you mostly deal with graphics and math. Graphics is provided by the library you use. I wouldn't start with SFML though - there are simpler graphics APIs out there - I think the simplest one out there today (and also the most accessible) is the HTML5 canvas 2D API.

 

The problem with books is that they focus too much on concepts and don't really deal that much with explaining the code. They usually just throw in some code, and when they do try to explain it, they do a worse job than the official documentation for whatever API is used, often with lacking or false statements about what the API functions do. And if you don't stick to just one language/library, you will learn the basic concepts involved with graphics in no time, without ever reading any books.

 

IMHO, right now you need start practicing writing code and stick to it... I agree too that tutorials might not be what you need, but they sure are better than code without comments - it doesn't get any easier. And don't be afraid to copy paste code - as long as you also try to understand it. Otherwise, you would need a lot of imagination and ingenuity to come up with your own code for everything - we're not geniuses.

 

tl;dr

I started with Pascal BGI graphics. At the same time, I was also writing and dissecting Winamp visualizer scripts - I was intrigued by how they looked so 3D-ish - so my final-year project in high school was a simple 3D wireframe graphics editor/visualiser implemented in Pascal, using BGI, and the 3D-faking technique I learned from Winamp. I even implemented a MessageBox function and a file-open/save dialog for it from scratch - just drew some rectangles for the boxes and text for input - because I was doing windows programming at the same time, I implemented these as a sort of Windows modal dialog boxes - each with it's own window procedure, and I even named the few window messages I implemented similar to the Windows messages. :)

Before this, I was doing text-based graphics using block-text characters in DOS (but this can't really be called graphics) :) - but I gave that up quickly because the screen was too slow to refresh.

Also at the same time, I moved on to Windows GDI with Turbo C++, and the biggest problem I had (aside from the new language) was that the function names were all different, and the new concepts like "device context" were really confusing. But I decided to be patient and push forward.

These were all easy to understand, as there were a lot of simple examples - the high school trigonometry classes helped me a lot with the math in the Winamp scripts, and since then they stuck.

During all this, my only sources of documentation were the Pascal help files and the win32 help file (which is now held in MSDN), and a few example programs from Pascal, Turbo C++ (they were actually C-only programs; I only learned C++ a lot later).

I did all this during the last year of high school, on a 486 computer. :)



#13 Zero_Breaker   Members   -  Reputation: 367

Like
0Likes
Like

Posted 29 July 2014 - 02:56 AM

@tonegub Thanks a lot for the advice smile.png ! I have to agree that some books have very badly commented and unexplained code and i would agree that most of the time tutorials explain code better than books but for me books kind of expand and give you a good theoretical explanation on some features of a language and what they do in depth.

 

But yeah for the writing code i fully agree, i am very persistent but sometimes i just feel burnt out or lose my patience because there are so many things that i have to go through again and sometimes i run into some very cryptic books which don't explain the code and i feel like ripping my hair out but calm down after 5 minutes.

 

And as i said before i copy and paste something if i know what it does and then re-write it to change anything etc or i use code that's been already made since it saves you time and the person wants people to use it.

 

But overall your post is very helpful smile.png !


Edited by Zero_Breaker, 29 July 2014 - 02:57 AM.


#14 AlexWalters22   Members   -  Reputation: 419

Like
1Likes
Like

Posted 07 August 2014 - 07:07 PM

Lazy Foo man. http://lazyfoo.net/tutorials/SDL/index.php

 

    It goes through many of the things you will need to know about the basic game loop. Input handling, image loading and rendering, sound, basic collision detection, and some things that are more difficult to understand like frame-independent movement. It also goes over things that are included in common games like a game camera and background tiling. It gives you a full(ish) understanding of basic 2D games. It's also a native C library (which means native C++ too). So yeah, that's good.

 

    Books probably won't help you too much until you understand the basic game loop.They tend to be somewhat unfocused in some places because when your an expert, you can forget what was difficult for a beginner. Also, I wouldn't worry about coming up with amazing solutions to problems(or any solution without research), or copying others code(as tonemgub said) as long as you try(really try) to understand it. Eventually you will get to a point where you do understand, and then you will really want to change copied code or rewrite poorly understood code (because you can do it better).I struggled with the frustration at not being able to come up with a solution on my own for a while before I realized I would just get there eventually with some perseverance and a touch of diligence.

 

I hope Lazy Foo helps you and if you have some specific questions I would love to answer them, send me an email or a PM on here, and I will get back to you! Much luck to you on your journey.


Edited by AlexWalters22, 07 August 2014 - 07:15 PM.


#15 flodihn   Members   -  Reputation: 242

Like
0Likes
Like

Posted 08 August 2014 - 01:29 AM

If you want to learn about game programming, why not choose an game engine like Unity, they have a huge community and when you searching for example how to do something, almost everytime somebody have already posted a solution in their forums or stackoverflow. And if they don't you can get friendly help from the community.

 

If you choose Unity, I do recommend skipping their javascript in favour of C#. Their javascript is a weird custom scripting language that is not really javascript and might cause confusion for beginners.



#16 yellowsputnik   Members   -  Reputation: 658

Like
2Likes
Like

Posted 08 August 2014 - 05:11 AM

I found the book "Game Coding Complete" very useful to understand how to create a game. So if you feel comfortable learning from books, that's the one I'd recommend for someone who already knows how to program.



#17 Jason Z   Crossbones+   -  Reputation: 5045

Like
1Likes
Like

Posted 09 August 2014 - 05:49 AM

First of all, you should know that it is normal for being overwhelmed when you get started in a new area of programming.  Even if you know a particular language, it can be quite difficult to sit down and read the designs for a particular industry.  So don't stress out about it - just take it one piece at a time and make progress.

 

I think the other advice that was already given about learning how the main loop works is a good place to start.  Once you know that, then you can move on to the update method and all of the things that are done there - rendering, then audio, etc...  But make a concerted effort to only concentrate on one topic at a time, and you will be able to digest the information more easily.






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