Questions tagged [c++]
C++ is a statically typed, free-form, multi-paradigm, compiled, general-purpose programming language.
337
questions
69
votes
9answers
29k 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."
...
14
votes
3answers
2k 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 ...
52
votes
10answers
22k 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 ...
39
votes
3answers
23k 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 ...
39
votes
5answers
14k 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
5answers
20k 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 ...
7
votes
5answers
6k 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 ...
131
votes
9answers
95k 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 ...
21
votes
2answers
18k 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 ...
4
votes
3answers
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 ...
43
votes
2answers
20k 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 ...
54
votes
9answers
17k 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 ...
19
votes
1answer
19k 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 ...
10
votes
2answers
8k 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 ...
29
votes
2answers
11k 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.
81
votes
17answers
58k 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 ...
68
votes
9answers
102k 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 ...
67
votes
9answers
23k 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 ...
80
votes
11answers
32k 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 ...
26
votes
9answers
27k 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?
6
votes
3answers
20k 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 ...
34
votes
9answers
59k 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 ...
29
votes
4answers
5k 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 ...
15
votes
1answer
18k 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 ...
12
votes
2answers
14k 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 ...
15
votes
4answers
4k 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 ...
28
votes
2answers
119k 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?
24
votes
4answers
14k 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 ...
17
votes
5answers
12k 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 ...
2
votes
3answers
9k views
how to detect same keyboard key press only once
I am designing a keyboard class that can detect the keyboard key press only one time but I still cannot figure out the way to do it. My goal is just check and perform the action only once when the ...
1
vote
1answer
6k 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:
...
1
vote
1answer
943 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 ...
0
votes
2answers
592 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 ...
146
votes
22answers
45k 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 ...
75
votes
9answers
131k 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 ...
16
votes
2answers
12k 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 ...
27
votes
2answers
25k 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?
13
votes
5answers
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 ...
28
votes
1answer
12k 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?
16
votes
5answers
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.
...
24
votes
2answers
11k 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 ...
18
votes
1answer
5k 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 ...
5
votes
2answers
6k views
How can I improve my collision detection's performance?
I'm new to programming and want to speed up the collision detection in my C++ 2D platformer game engine.
Currently, only the player's collision detection works: Every frame, the player's update ...
16
votes
6answers
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 ...
14
votes
1answer
7k 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. ...
12
votes
1answer
3k 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 ...
13
votes
3answers
2k 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
...
10
votes
3answers
2k views
Proper way to handle destruction of game entities
Imagine a game world where loads and loads of entities are dynamicly loaded all the time, I would represent that as a list of entities perhaps, but what about removing them?
While when adding i ...
6
votes
2answers
12k views
Toggle Fullscreen at Runtime
Using the library GLFW, I can create a fullscreen window using this line of code.
glfwOpenWindow(Width, Height, 8, 8, 8, 8, 24, 0, GLFW_FULLSCREEN);
The line for ...
4
votes
2answers
6k 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: ...