Skip to main content
Share Your Experience: Take the 2024 Developer Survey

Questions tagged [c++]

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

Filter by
Sorted by
Tagged with
73 votes
9 answers
39k 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." ...
gkimsey's user avatar
  • 1,003
16 votes
3 answers
4k views

What's the largest "relative" level I can make using float?

Just like it was demonstrated with games like dungeon siege and KSP, a large enough level will start to have glitches because of how floating point works. You can't add 1e-20 to 1e20 without losing ...
jokoon's user avatar
  • 5,253
52 votes
10 answers
25k 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 ...
PrettyPrincessKitty FS's user avatar
39 votes
3 answers
25k 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 ...
Juicy's user avatar
  • 581
39 votes
5 answers
15k 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
5 answers
26k 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 ...
ultifinitus's user avatar
  • 1,912
9 votes
5 answers
8k views

How to lead a moving target from a moving shooter

I saw this question: Predicting enemy position in order to have an object lead its target. My situation is a little different though. My target moves, and the shooter moves. Also, the shooter's ...
Azaral's user avatar
  • 376
137 votes
9 answers
103k 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 ...
58 votes
9 answers
20k 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 ...
BlueRaja - Danny Pflughoeft's user avatar
21 votes
2 answers
22k views

Implementing a camera / viewport to a 2D game

What is the most practical way to implement camera/viewport to a 2D-game? I've read, that I should store the object world position instead of position relative to the screen? Current situation: I ...
bluekirai's user avatar
  • 313
5 votes
2 answers
12k views

An efficient way for generating smooth circle

I'm looking for creating smooth circle. OpenGL supports point, line, and triangle. To create other primitives like circle, we utilize the preceding shapes. In my case, I've utilized points as follows: ...
CroCo's user avatar
  • 245
4 votes
3 answers
4k views

Optimized rendering of a cube mesh world

I want to render a cube-mesh (a.k.a. Minecraft-style) world. If I render each existing cube it will eat up FPS pretty quickly. How can I optimize it? I understand that the point is to not render ...
Tamás Szelei's user avatar
44 votes
2 answers
22k 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 ...
Truncheon's user avatar
  • 547
29 votes
2 answers
14k 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.
hemogoblin's user avatar
19 votes
1 answer
20k views

Fast, accurate 2d collision

I'm working on a 2d topdown shooter, and now need to go beyond my basic rectangle bounding box collision system. I have large levels with many different sprites, all of which are different shapes and ...
Neophyte's user avatar
  • 583
11 votes
2 answers
9k views

How to implement the interaction between engine parts?

I want to ask a question about how the information exchange between game engine parts should be implemented. The engine is separated in four parts: logic, data, UI, graphics. In the beginning I made ...
Userr's user avatar
  • 113
82 votes
17 answers
59k 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 ...
80 votes
11 answers
36k 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 ...
KaareZ's user avatar
  • 1,943
68 votes
9 answers
24k 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 ...
Bugster's user avatar
  • 2,034
66 votes
9 answers
110k 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 ...
25 votes
9 answers
31k 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?
MrValdez's user avatar
  • 731
8 votes
3 answers
4k views

How can I tile Perlin noise to more accurately represent a world map?

I'm currently working on my game. I would like to generate the world map with Perlin noise, and wrap it just like a real world map. I've found a algorithm to create a map wrapped along X and Y axis: ...
Nereid Regulus's user avatar
6 votes
3 answers
23k views

How do I calculate how an object will move from one point to another?

Here's the problem: A player starts the game in the 0 coordinate (x=0,y=0). When the user clicks on the screen, it returns the coordinates of the destination. Now the player has to move from its ...
user avatar
1 vote
1 answer
9k views

OpenGL calculate UV sphere vertices

I am trying to implement a class Sphere in C++. Therefore I want to calculate the vertices in the constructor of the class (or in a seperate function..). Although ...
linux_lover's user avatar
0 votes
2 answers
908 views

Floating point precision issue with Box2D

I'm using Box2D and I am putting edge tiles as b2Bodies so that the tile world can have physics: The problem is that there are 3 b2_kinematic bodies under the player right beside each other. Every so ...
jmasterx's user avatar
  • 2,099
36 votes
9 answers
69k 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 ...
Tucker Morgan's user avatar
32 votes
3 answers
143k views

Is it possible to use C++ with Unity instead of C#?

The title kind of says it all. Is it possible to replace C# with C++ on a game using Unity?
DJMcMayhem's user avatar
29 votes
4 answers
6k 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 ...
Skeith's user avatar
  • 1,287
25 votes
4 answers
17k 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 ...
BarakatX2's user avatar
  • 1,076
17 votes
5 answers
13k views

When should vector/list be used?

I can understand when to use lists, but I don't understand when it is better to use vectors than using lists in video games: when it is better to have fast random access ? (And I understand why it's ...
jokoon's user avatar
  • 5,253
16 votes
4 answers
5k views

How to load a spherical planet and its regions?

I'm designing a game partially composed of planets exploration. I want to use pseudo-random generation for them, regenerating from a defined seed when I have to load them rather than store every ...
Aracthor's user avatar
  • 1,009
16 votes
1 answer
21k views

Implementing a skybox with GLSL version 330

I am trying to get a skybox working with OpenGL 3.3 and GLSL version 330. I could not find a completely modern OGL skybox tutorial anywhere on the web, so I modernised an older one (using ...
sm81095's user avatar
  • 543
12 votes
2 answers
16k views

I am looking to create realistic car movement using vectors

I have goggled how to do this and found this http://www.helixsoft.nl/articles/circle/sincos.htm I have had a go at it but most of the functions that were showed didn't work I just got errors because ...
bobthemac's user avatar
  • 223
4 votes
2 answers
6k views

Calculate matrix transformation components separately

It is possible to calculate the translation, rotation and scale that were used to build a matrix? I mean if I have a matrix M can I calculate the rotation, scale, ...
amit's user avatar
  • 93
1 vote
1 answer
8k views

How should I rotate vertices around the origin on the CPU?

I have tried using glm::rotate and such. glm::translate works fine, but rotate doesn't work (if I rotate before/after a translation). Here is my current setup: ...
user avatar
1 vote
3 answers
2k views

How do I fix my planet-facing camera?

Summary I'm having trouble implementing a camera controller suitable for first person use around a planet. The camera needs to be oriented correctly according to gravity (vector from camera ...
moldyviolinist's user avatar
150 votes
22 answers
49k 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 ...
munificent's user avatar
77 votes
9 answers
136k 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 ...
32 votes
1 answer
16k views

What is the difference between an impulse and a force related to a physics engine?

What is the difference between an application of an impulse and an application of a force in relation to a physics engine?
Casey's user avatar
  • 2,035
28 votes
2 answers
30k 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?
Ólafur Waage's user avatar
26 votes
1 answer
14k 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 ...
nosmirck's user avatar
  • 785
25 votes
2 answers
14k 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 ...
Dollarslice's user avatar
  • 3,420
19 votes
2 answers
15k views

What are the common rendering optimization techniques for the geometry pass in a deferred shading renderer? [closed]

I have been developing a game engine using OpenGL 3 and C++ (and glfw for window management). I have advanced so far, got most of the things done except sound entities and optimizations. The engine ...
deniz's user avatar
  • 505
19 votes
1 answer
6k views

Normals vs Normal maps

I am using Assimp asset importer (http://assimp.sourceforge.net/lib_html/index.html) to parse 3d models. So far, I've simply pulled out the normal vectors which are defined for each vertex in my ...
KaiserJohaan's user avatar
  • 1,464
16 votes
6 answers
7k views

Should an object in a 2D game render itself?

I'm making a 2D street fighter-like game that is not tile based. Usually people recommend that entities be given to a renderer that render them, not them render themselves, but it seems the inverse is ...
jmasterx's user avatar
  • 2,099
16 votes
5 answers
12k views

Starting out with OpenGL when most tutorials are out of date [closed]

I'm sure there are already a bunch of questions like this asked, but the constant updating of the OpenGL library throws them all away, and in a month or two, the answers here will be worthless again. ...
Codesmith's user avatar
  • 279
14 votes
1 answer
8k views

Different shaders for different objects DirectX 11

I am learning Direct3D 11, and in all basic tutorials I found on shader writing, Vertex and Pixel shaders are written so they transform whole scene same way. ...
jantobola's user avatar
  • 255
13 votes
5 answers
3k views

Custom Content Package for Files

I am about to purchase quite a few model packs from a website for prototyping my game. In the contract it states that I must protect them as to prevent the public from gaining access to them. I ...
Aidan Knight's user avatar
13 votes
3 answers
3k views

Game loop, how to check for conditions once, do something, then not do it again

For example, I have a Game class and it keeps an int that tracks the player's lives. I have a conditional ...
EddieV223's user avatar
  • 427
13 votes
1 answer
4k views

Programming a climbing system like tomb raider

I was wondering if anyone knew or had knowledge of how to program a climbing system like the one found in tomb raider/uncharted. I had thought of just having bounding boxes at all the climbable ...
MulletDevil's user avatar

1
2 3 4 5
8