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

Started by
15 comments, last by Jason Z 9 years, 8 months ago

@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 :)

Advertisement

"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. :)

@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 !

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.

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.

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.

 

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.

This topic is closed to new replies.

Advertisement