How exactly are video games made?

Started by
15 comments, last by DekuTree64 10 years, 10 months ago

I'm hearing a lot of the same thing when it comes to this topic and it seems most people are pretty confident and in the same mind. So I can't help but think I must be missing something pretty crucial if I can't seem to rationalize the very concept that an entire community keeps talking about. I suppose this confusion comes from one primary basis, which is, how do you translate code into an interactive environment?
So I keep hearing, that people design models in Blender or draw them for use with animation, then they'd download some shaders and use Dynamic Link Libraries with all that support to examine and configure the input/output. I've heard it all.

What I don't understand is that there is a huge gray area in between where I am at now, and how any of that works. Truth be told, I could go and purchase Unity3D right now if I wanted to. Heck, UDK engine is free as long as 25% of revenue is handed back to Epic. I'm sure I could thrive off of that crap if I had the determination but I want to start from the basics and the reason I am doing this is because I want to understand the basics. I want to know how I got there. Not download an engine and have the fish handed to me, I want to learn how to catch the fish myself. Get it?

Here's my problem, then.

I've decided to use C++ (no, duh?) and I'm finding it to be typical in terms of Object Oriented Programming. That's great. I've learned all the basic concepts and I intend to keep learning before I even attempt to make my crappy spin off of Pong - but before we even go there, I want to get some answers on where you'd have to take the language to get that kind of interaction up on screen.

So far I've been learning about if statements, arrays, classes, variables, operators - all the noob jazz. If I want to get something up in console I'd just type cout << "Hello world!" << endl; in one of the statements in my main function and then return 0. SUPER simple stuff, I know. What I'm having trouble understanding is how I can go from typing text into a console, and using this exact same language to render graphics onto a screen and have characters move around. Let's say that I wanted to remake the original NES Super Mario's first level (no way I'm doing this, but hypothetically) in C++. How do I draw up a graphic of Mario with a running animation, add in a background and put in my static objects, and then interact with them. It looks good on paper to make all these objects and classes but I don't know how the hell you'd get there.

Can we really talk on the most basic level? Can someone explain this gray area to me? What steps does someone need to take to get from displaying text on a console to displaying interactive images such as Pong? To type "Game Over" would I still use the cout << "Game Over" << endl; statement or something completely different? Would I just call another class which tells it to position the text in the middle of the screen and in a white, ASCII font? I'm so confused and I can't even fathom how you'd get 3D graphics on screen with textures and enemy AI if I can't even grasp this concept.

Really, as I said. I just need a basic explanation, dumbed down as much as possible to its core foundations of how a programming language such as C++ displays images on a screen that a user can interact with in full functional environments. Even if it's just something like Pong, or the original Mario, or Donkey Kong. Really, really basic stuff.

Advertisement

You need a graphics library. Something that let you "communicate" with your graphic device.

You should look at openGL or direct3d.

Can we really talk on the most basic level?

no, we can't. Graphics programming is complicated.

The short answer is: you need to use an API or an engine/framework to do graphical stuff.

API will let you talk to the graphics hardware in terms of triangles, buffers, shaders and textures. There is nothing "plug and play", you'll need to have a very strong grasp of vector math and space transforms. You will have to write your own material management system, your own 3d file importer.. everything everything everything has to be coded by you. You don't "download shaders" and you don't stick dll together... you write shaders (and the app code that goes with them) and write dll.

If this is the way you have chosen.. stop trying to guess, buy yourself the OpenGL Programming Guide (aka, the "Red Book") and go with it until your eyes bleed.

Until you'll understand that you're trying to achieve something complicated that will probably keep you busy for the next 3-4 years you'll just be frustrated... so be serious, buy yourself a good book about C++, a good book about OpenGL and a good book about math applied to 3D graphics and get going.

Using Engine/Frameworks will simplify some of the things above... so you go from full WYSIWYG editor engines a-la Unity/UDK to 3D frameworks a-la Ogre.

This will give you a more gentle way in into graphics programming.

Stefano Casillo
TWITTER: [twitter]KunosStefano[/twitter]
AssettoCorsa - netKar PRO - Kunos Simulazioni

Yeah, all we really do is tell an API what we want to happen and it does it for us.

The real clever programmers are the ones who develop the implementations of OpenGL / DX and write the drivers for the GPU.

Kind of similar to the difference between the expert furniture craftsman and the guys who make wooden toys to sell to kids. We all probably come under the latter ;)

EDIT:

Apologies if I insulted someones profession. Sometimes those wooden toys can still be very innovative! ;)

http://tinyurl.com/shewonyay - Thanks so much for those who voted on my GF's Competition Cosplay Entry for Cosplayzine. She won! I owe you all beers :)

Mutiny - Open-source C++ Unity re-implementation.
Defile of Eden 2 - FreeBSD and OpenBSD binaries of our latest game.

I think you really just need to push through and actually try it for yourself. Once you manage to create an actual game -- even a very basic one -- with graphics everything should click into place for you. Pong is an excellent game to learn these things, as it's very simple but contains many of the things present in larger more complicated games.

As mentioned above, you'll need an API that allows you to draw graphics on the screen. I would suggest SDL or SFML. Both of very capable and very popular, but a bit simpler than jumping in to OpenGL or DirectX. Pick one, find a tutorial that shows you how to draw a single image on the screen, and work from there. Find and follow a "how to make pong" tutorial if you need to for your first game.

All of this will make sense if you just push on and actually go through the process, and once you've had that experience you'll be able to ask more pointed questions about any specifics you're still curious about.

Hope that helps! smile.png

- Jason Astle-Adams

I think you really just need to push through and actually try it for yourself. Once you manage to create an actual game -- even a very basic one -- with graphics everything should click into place for you. Pong is an excellent game to learn these things, as it's very simple but contains many of the things present in larger more complicated games.

As mentioned above, you'll need an API that allows you to draw graphics on the screen. I would suggest SDL or SFML. Both of very capable and very popular, but a bit simpler than jumping in to OpenGL or DirectX. Pick one, find a tutorial that shows you how to draw a single image on the screen, and work from there. Find and follow a "how to make pong" tutorial if you need to for your first game.

All of this will make sense if you just push on and actually go through the process, and once you've had that experience you'll be able to ask more pointed questions about any specifics you're still curious about.

Hope that helps! smile.png

Thank you for this reply. It was encouraging, gave me a place to start and did not make me feel overwhelmed. It was very constructive in a sense that it made me feel as if I am at the right starting point and I can make a basic clone of Pong over time in order to steadily increase my knowledge. I understand there are lots of people that have never been introduced to programming before and are immediately convinced that they are able to create the next big World of Warcraft killer, and I refuse to not be realistic about this. It will probably take me ten or more years before I make a complete platformer that is fluent in what it does - maybe more.

Any advice you can give me would be invaluable. I'm checking out those Graphics API's and bookmarking them so that once I've read through a decent amount of C++ tutorials and understand how to write basic programs, I'll move onto them and progress from there. Again, thanks so much for taking the time out to give me a pointer in the right direction and encouraging words.

To everyone else, thanks for your input. I understand now that there is a Graphics API that's needed to allow the code to communicate with the card. Can I ask, though, why has nobody mentioned Direct X? To my knowledge, that's a very big one, unless I've missed something.

The first post mentioned a major component of DirectX called Direct3D. There is also Direct2D, Direct Sound. If you want to see graphics at it's most simple then have a look at the OpenGL Redbook. An nVidia programmer named Mark Kilgard came up with a no-frills wrapper called GLUT to start up a window that can handle graphics and input with only a few lines of code required by the user. This allows you to look at only what is essential for getting started without being distracted and confused with all the Windows API stuff. The Redbook stuff is pretty old but still works just fine, and since it uses GLUT you can focus only on what's required to draw to the screen. Once you get that down, you might want to have a look at collision detection code. Pong doesn't need much. When the ball hits the paddle, multiply the 'Y' velocity by -1.0. When the ball hits a wall, multiply the 'X' velocity by -1.0;

http://www.cse.chalmers.se/edu/year/2012/course/TDA361/redbook.pdf

I think there is also a GLUT version written for DirectX if you would prefer that.

Consider it pure joy, my brothers and sisters, whenever you face trials of many kinds, 3 because you know that the testing of your faith produces perseverance. 4 Let perseverance finish its work so that you may be mature and complete, not lacking anything.

The first post mentioned a major component of DirectX called Direct3D. There is also Direct2D, Direct Sound. If you want to see graphics at it's most simple then have a look at the OpenGL Redbook. An nVidia programmer named Mark Kilgard came up with a no-frills wrapper called GLUT to start up a window that can handle graphics and input with only a few lines of code required by the user. This allows you to look at only what is essential for getting started without being distracted and confused with all the Windows API stuff. The Redbook stuff is pretty old but still works just fine, and since it uses GLUT you can focus only on what's required to draw to the screen. Once you get that down, you might want to have a look at collision detection code. Pong doesn't need much. When the ball hits the paddle, multiply the 'Y' velocity by -1.0. When the ball hits a wall, multiply the 'X' velocity by -1.0;

http://www.cse.chalmers.se/edu/year/2012/course/TDA361/redbook.pdf

I think there is also a GLUT version written for DirectX if you would prefer that.

All of this exists for D3D as well it is called DXUT and can be found here when the SDK is installed: <Program Files>\Microsoft DirectX SDK (June 2010)\Samples\C++\DXUT11\Core.

D3D has a bit of a steeper learning curve then GL but it plateaus out quickly, once you get your head around the Vertex and Index buffers. DXUT also has a documentation section in the DX SDK documentation explaining how to use it.

Worked on titles: CMR:DiRT2, DiRT 3, DiRT: Showdown, GRID 2, theHunter, theHunter: Primal, Mad Max, Watch Dogs: Legion


Can I ask, though, why has nobody mentioned Direct X? To my knowledge, that's a very big one, unless I've missed something.

In general, Direct X (or OpenGL) is more low level than people need to accomplish their goals. It's there, you can use it, but for the majority of games (and all For Beginner's first games), SDL and SFML will do what you need with 80% less headache.

lol. Not really contributing to the topic but this thread reminds me how completely lost i am asking how web-services, and still am, servers like EC2 and weird programming languages like PHP and Ruby work.

Anyway, this may sound like a bit of a marketing advertisement but if you really want to learn the low-level stuff, i would suggest checking out gameinstitute.com. Just for $99 you can get all of their course materials from programming, art, to actually designing hardwares. The level of detail in their courses is just so ridiculous its like they're talking to 8 year olds but the topics they cover are insanely advanced and complex.

They have a separate section for learning how to make games using C++ and DirectX. It pretty much teaches you all you need to know about the math, collision, AI, and graphics work. There's also a separate section for Unity and their sample projects are almost comparable to commercial type games.

EDIT: Also, i don't work for gameinstitute. Just a long time student and have learned so much stuff throughout the years..

This topic is closed to new replies.

Advertisement