Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [c++]

C++ is a statically typed, free-form, multi-paradigm, compiled, general-purpose programming language.

142
votes
22answers
40k views

STL for games, yea or nay? [closed]

Every programming language has its standard library of containers, algorithms, and other helpful stuff. With languages like C#, Java, and Python, it's practically inconceivable to use the language ...
127
votes
9answers
83k views

What are some programming design patterns that are useful in game development? [closed]

I have a few books on Design Patterns, and have read some articles, but cannot intuitively figure out which programming design patterns would be useful in game development. For example, I have a book ...
81
votes
9answers
77k views

Why don't C++ Game Developers use the boost library? [closed]

So if you spend any time viewing / answering questions over on Stack Overflow under the C++ tag, you will quickly notice that just about everybody uses the boost library; some would even say that if ...
78
votes
17answers
55k views

C++ low-level optimization tips [closed]

Assuming you already have the best-choice algorithm, what low-level solutions can you offer for squeezing the last few drops of sweet sweet frame rate out of C++ code? It goes without saying that ...
72
votes
9answers
121k views

Easy to use cross-platform 3D engines for C++ game development? [closed]

I want to try my hand at writing a 3D game. However I don't want to start at such a low level of drawing individual triangles and writing my own 3D object loader and so on. I've heard of things like ...
69
votes
10answers
24k views

Is UDP still better than TCP for data-heavy realtime games?

I know that UDP is usually recommended for real-time multiplayer games with high data usage. Most articles are serval years old, and since ~80% of all data transmitted on the internet is TCP, a lot ...
67
votes
9answers
21k views

How can you put all images from a game to 1 file?

I've just finished a basic RPG game written in C++ SFML, I've put a lot of effort into the game and I'd want to distribute it, however I've ran into a small issue. Problem is, I have well over 200 ...
65
votes
9answers
91k views

Good GUI for OpenGL? [closed]

I am starting to learn OpenGL with FreeGLUT using the Superbible and the knowledge I have from my elementary graphics to brush up on my skills. To get more from this experience I want to integrate a ...
64
votes
9answers
22k views

What's a way to implement a flexible buff/debuff system?

Overview: Lots of games with RPG-like statistics allow for character "buffs", ranging from simple "Deal 25% extra damage" to more complicated things like "Deal 15 damage back to attackers when hit." ...
62
votes
6answers
42k views

How does Lua work as a scripting language in games?

I'm a little hazy on what exactly Lua is and how a game that is programmed in C++ would use it. I'm asking primarily about how it is compiled and run. For instance when you use a program written in C+...
52
votes
10answers
19k views

Game State 'Stack'?

I was thinking about how to implement game states into my game. The main things I want for it are: Semi-transparent top states-being able to see through a pause menu to the game behind Something OO-I ...
49
votes
7answers
4k views

When prototyping, how can I more easily explore game behaviour?

I build indie games myself, but I'm usually out of energy once I've taken a newly developed game to a level where it's possible to play with behavior, so I settle for refinement instead of exploration....
48
votes
10answers
19k views

C++: Smart pointers, Raw pointers, No Pointers? [closed]

Within the scope of developing games in C++, what are your preferred patterns in regard to use of pointers (be it none, raw, scoped, shared, or otherwise in between smart and dumb)? You might ...
48
votes
9answers
14k views

How are deterministic games possible in the face of floating-point non-determinism?

To make a game like an RTS networked, I've seen a number of answers here suggest to make the game completely deterministic; then you only have to transfer the users' actions to each other, and lag ...
44
votes
2answers
18k views

How to create adjustable formula for RPG level up requirements?

I'm trying to create a formula that can be modified simply by changing two values: number_of_levels, and last_level_experience. This is to enable people modding the game to change the levelling ...
42
votes
6answers
5k views

Is it unprofessional to leave game resources to the open eye?

I'm still having problems packing my resources, after going through complicated APIs and basically just zip files which are exhausting my brain, I thought I could also pack the game with the resources ...
42
votes
7answers
10k views

What are the performance difference between unsigned and signed integers? [closed]

I am aware of the performance hit when mixing signed ints with floats. Is it any worse to mix unsigned ints with floats? Is there any hit when mixing signed/unsigned without floats? Do the ...
41
votes
1answer
7k views

Why are all OpenGL function calls prefixed with “q” in the Doom 3 source code?

Why is every OpenGL call prefixed with a "q" in the Doom 3 source code? Are they custom functions or a different library, and if so, why use that over OpenGL? Any Google search comes up with the Qt ...
40
votes
6answers
16k views

How do we solve big video memory requirements in a 2D game?

How do we solve big video memory requirements in a 2D game? We are developing a 2D game (Factorio) in allegro C/C++, and we are facing a problem with increasing video memory requirements as the game ...
39
votes
5answers
13k views

Any tips for creating cross-platform games? [closed]

Do you have any tips/recommendations when creating a cross-platform game in C/C++?
38
votes
7answers
23k views

How can one implement hot-swappable C++ modules?

Fast iteration times are key to developing games, much more so than fancy graphics and engines with truckloads of features in my opinion. No wonder many small developers choose scripting languages. ...
38
votes
1answer
2k views

How do I create particles that react to the player and enemies?

I'm currently making a game with my own game engine which I've written in C++ and I'm using the most recent directx SDK. The game is a top down space shooter (with a pretty interesting twist) and I'...
36
votes
3answers
19k views

When several classes need to access the same data, where should the data be declared?

I have a basic 2D tower defense game in C++. Each map is a separate class which inherits from GameState. The map delegates the logic and drawing code to each object in the game and sets data such as ...
36
votes
4answers
18k views

Entity/Component Systems in C++, How do I discover types and construct components?

I'm working on an entity component system in C++ that I hope to follow the style of Artemis (http://piemaster.net/2011/07/entity-component-artemis/) in that components are mostly data bags and it's ...
35
votes
5answers
16k views

In 2D, how do I efficiently find the nearest object to a point?

I have a sizable game engine and I'd like a feature for finding the nearest of a list of points. I could simply use the Pythagorean theorem to find each distance and choose the minimum one, but that ...
33
votes
9answers
47k views

How do I create a save file for a C++ game?

I am coding my final for a Video game Programming course, and I want to know how to create a save file for my game, so that a user can play, and then come back later. Any idea how this is done, every ...
31
votes
1answer
6k views

How are entity systems cache-efficient?

Lately, I've been doing a lot of reading on entity systems to implement in my C++/OpenGL game engine. The two key benefits that I constantly hear lauded about entity systems are the easy ...
30
votes
3answers
8k views

Try-catch or ifs for error handling in C++

Are exceptions used widely in game engine design or it is more preferable using pure if statements? For example with exceptions: ...
28
votes
4answers
4k views

game story event programming

I have developed a game engine in c/c++ and DirectX. I have a tile engine for the maps, animated player/npc sprites, talking to the npc, menus, and level changing but there is no game, it just feels ...
27
votes
2answers
10k views

Is it safe to use Sleep() in game loop (on Windows)?

Is it safe to use Sleep() function on Windows in game loop (C++)? I want to have fixed frame rate.
27
votes
5answers
6k views

Game architecture / design question - building an efficient engine while avoiding global instances (C++ game)

I had a question about game architecture: What is the best way to have different components communicate with each other? I do really apologize if this question has already been asked a million times, ...
26
votes
2answers
23k views

I can't figure out how to animate my loaded model with Assimp

I have loaded in a model to my C++ OpenGL game. It is a COLLADA file type that I have loaded, and I setup an animation under blender for the file. The problem is I don't know how to animate the model. ...
26
votes
9answers
21k views

What C++ GUI library can you suggest? [closed]

I'm building my own game engine in C++ and I'm currently deciding on what user interface I should use. Should I use a library? Should I make my own?
26
votes
3answers
19k views

Android game development in c++

So being a primarily c/c++ developer, I've always thought that the only option for mobile game development for me was using iOS, which allows for c/c++ (and minimising objective C). I heard from a ...
25
votes
3answers
3k views

Making walls in tile-based games: what am I missing?

After spending time today to jot down some notes regarding the implementation of walls into my tile-based game, I've suddenly realized it's not going to be as simple as I imagined before. While the ...
24
votes
2answers
15k views

Quad tree vs Grid based collision detection

I'm making a 4 player co-op r-type game, and I'm about to implement the collision detection code. I've read a lot of articles and stuff about how to handle collision detection, but I'm having a hard ...
24
votes
2answers
20k views

How do you add a scripting language to a game?

Let's say I have a game written in C++. But I want to add some modding or scripting functionality to it. How would one go about adding a scripting functionality to your game?
24
votes
1answer
992 views

My game seems to be incompatible with recording software. What could be causing this?

I've just finished a little Game-Dev project for university and I need to record a video to accompany my submission (just in case they can't get my source to work). Basically my game doesn't work at ...
23
votes
4answers
9k views

How do C++ games handle memory allocation failure?

I am aware of several games which are written in C++ but do not use exceptions. Since handling of memory allocation failure in C++ is generally built around the ...
23
votes
7answers
6k views

Is C++ being replaced by C# in industry games?

In industry games I mean like Quake, CoD etc.
23
votes
3answers
8k views

Is it normal for a game to use 100% CPU?

I just implemented multi-threaded input handling in my game engine where the code that polls the OS to gather input from it and time stamps them is in a separate thread and each frame in the main ...
23
votes
4answers
11k views

Should collision detection be done server-side or cooperatively between client/server?

I am working on an online game that will have very heavy collision detection processing. Player models will collide with other players, mobs, structures, terrain, and solid objects that only exist ...
23
votes
5answers
27k views

Rotating vector3 by a quaternion

I am attempting to rotate a vector3 by a given quaternion. I know that this is true $$ v' = q \cdot v \cdot q^{-1} $$ I know that \$ q^{-1} \$ is the inverse which just \$ \frac {-q} {magnitude(q)} ...
23
votes
2answers
9k views

Animation Blending Basics

Say I have a framework with characters that can run and walk and of course, stand still. Am I right in thinking that animation blending is the process of smoothly transitioning between these by ...
23
votes
1answer
11k views

Which is the best LOD method for planet rendering?

I'm currently working on my thesis, it is an engine to render terrains of planetary size. I'm still finishing my research and I have encountered a lot of stuff about this subject, the problem is that ...
22
votes
3answers
3k views

Non-integer speed values - is there a cleaner way to do this?

Often I will want to use a speed value such as 2.5 for moving my character in a pixel-based game. Collision detection will generally be more difficult if I do that, though. So I end up doing something ...
22
votes
3answers
1k views

Do I need to learn C++ to use Open GL?

Do I need to learn C++ to use Open GL?
22
votes
3answers
6k views

Should I use text files for my save data?

My question is whether or not I should use text files to save my game data. I have some basic concerns over doing this: There's really no way to protect the data, and thus, the user could screw up ...
22
votes
3answers
7k views

How does one do unit testing in a game engine?

Much to my shame, I have never written a proper unit test, only small unorganized test programs that I would then dispose of after the test succeeded. I don't really have a clear idea of how unit ...
22
votes
1answer
10k views

File format for static and animated 3D models

I'm currently writing a 3D game in C++ with OpenGL and I'm coming to the part where to load 3D models in. Therefore I'm looking for popular file formats and techniques to display static meshs and ...