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

learn more… | top users | synonyms

1
vote
0answers
27 views

Direct3D11: Directional Shadow Maps

I've recently implemented shadow maps on my project. However, I'd like to add a feature that allows the light direction to be dynamically changed, so that the terrain can be viewed using different ...
1
vote
2answers
51 views

c++ Opengl handle elements drawn

I am currently working on a game and I want to know if there is any way of handling with the elements i am drawing . For example : if i draw in a loop 100 cubes , how can i show / hide the cube number ...
4
votes
1answer
112 views

Event Handling in an ECS

I apologize if this has been answered already. I've looked around here, and read a few blog posts, but none seem to fully answer my question. I am writing an Entity Component System. Entity is a ...
3
votes
1answer
92 views

Reorder a set of points in order to draw a triangle fan (example)

I'm doing a light engine (c++, using sfml), and to connect the light vertices, I thought about drawing a triangle fan. Here is a representation of a triangle fan (sfml documentation): The ...
3
votes
0answers
33 views

How to link assimp lib to universal app

I cannot make assimp object loader work with universal app, and I got the same problem as this one: Assimp and directX12 universal apps I tried the static library approach mentioned in the answer of ...
15
votes
3answers
3k views

Should I use a database for storing game content? [closed]

I have a 2D Game written in C++ using SFML. I want to make the game expandable in such a way that content like items or entities could easily be added by adding a line/entry/row to a file or ...
0
votes
2answers
99 views

sf::RectangleShape's position is not same as I set it to

When I try to print my box.getSfShape()'s position it does not print out the position I set it to have. ( The box.getSfShape()'s position is by default set to 0 ) Wrong output : ( printing the ...
2
votes
1answer
199 views

Why do my Box2D bodies not fall, even though world.step is called?

I have SFML set up with a Box2D world that has gravity, but my bodies won't move. I std::cout'ed the position of the body in the game loop, but it's always at (0, 14)! No errors or warnings, just no ...
2
votes
2answers
55 views

Should I be returning weak/shared_ptrs or unique_ptr's to my resources?

A friend of mine told me instead of normal pointers, I should use unique_ptr, i asked him why unique_ptr's if some resources are going to be shares, like multiple grass tiles, or enemies. I currently ...
2
votes
2answers
73 views

Cant jump from ground collision

I have a character that starts in the air and applying gravity to it to collide with platforms in my level. At the start, the character gradually gains speed descending until it collides with a ...
2
votes
1answer
66 views

Simple 3D OBB-Collision (DirectX9, C++)

I'm trying to implement a simple OBB vs. OBB collision detection! I don't need to know where the collision occures, I only want to know whether a collision occures. The problem is, that after lot of ...
3
votes
1answer
105 views

Efficient vertex buffer memory management?

I am building a voxel engine with a similar mechanism to minecraft(yes, I know...). It works by loading and unloading individual chunks of 16*64*16 cubes each in a square grid around the player. This ...
2
votes
2answers
174 views

Cost of Using Virtual Methods to Query Properties?

Let's say you're making a tile-based roll-playing game, and you're obsessed with OOP. You have an abstract base class Tile which will be inherited from by many derived classes, like Grass Sand and ...
2
votes
2answers
77 views

How do I implement a flashlight in SDL2?

I'm a beginner trying to implement a flashlight in SDL2, but can't figure out a good way to do it. I've found a way to manipulate the background's color; changed it to dark and back to its normal ...
-5
votes
3answers
178 views

Making game totally from scratch [closed]

I'm used to make my games in Java. Java is an awesome language but to launch .jar files you need a good updated JRE. So I thought: "I'm just going to make my games in C# or C++!" Unfortunely, I can't ...
2
votes
2answers
154 views

How to allow multiple bullets on screen at once

Using my universities API, I'm making a basic 2D game where pacman can shoot ghosts I have a bullet class but at the moment, I only have one instance of the bullet could anyone help edit this ...
-4
votes
1answer
57 views

Can we port any game written in C++ with SDL to Android platform or we would need to change some codes too? [closed]

Just wanted to lean a cross-platform library!! Since SDL library supports iOS too..
2
votes
1answer
42 views

Finding pitch/yaw values from lookat vector

I have a camera class that contains a position, a pitch, and a yaw (the pitch and the yaw correspond to y and x rotation values). I want to implement a lookAt function that takes a vector and the ...
5
votes
2answers
90 views

Is there an equivalent of Unity's OnCollisionEnter() in UE4?

I've been looking for how to figure out when two objects are colliding all day. If anyone knows how to do it I would be grateful. What I really want is a similar function to Unity's ...
0
votes
0answers
54 views

Trying to get Box2D bodies to fall [SFML, Box2D, C++] [duplicate]

As the title says I'm trying to make my Box2D body to fall, but it won't work. It just stays at the same position. Sorry for the long codes but I have no idea where I'm doing something wrong, so I ...
1
vote
1answer
34 views

Vector out of range (Batch rendering & opengl)

So ive (tried to) implement a batch rendering system, and at the for loop the error pops up and I'm not shure what ive done wrong. Any suggestions to improve the system would be much appreciated. ...
1
vote
1answer
78 views

Bullet Physics / OpenGL Meshes Not Colliding

This is for a school project, and I'm having a bit of trouble with Bullet acting strangely. I have an OpenGL project with Bullet Physics library working with Assimp model loaders and Magick++ ...
2
votes
2answers
151 views

c++ text based duel game, buggy turn mechanic

so ive checked this code 100 times for mistakes and everything checks out and should be working, I've tried everything I can think of but for some reason nothing works, this makes the movement super ...
16
votes
6answers
4k views

How do I correctly use singletons in C++ engine programming?

I know singletons are bad, my old game engine used a singleton 'Game' object that handles everything from holding all data to the actual game loop. Now I'm making a new one. The problem is, to draw ...
1
vote
1answer
75 views

Drawing a lines radiating from every angle using Bresenham line algorithm

I am trying to recreate a image like this ... or just each point Using Bresenham line algorithm, but can't seem to able to do so.. The point i receive from my computation doesn't look like a like, ...
1
vote
1answer
47 views

Converting normalized device coordinates to world space coordinates flipping my sprites

I'm trying to convert my game's camera system to use world space coordinates rather than OpenGL's default normalized device coordinates, however in doing so my sprites are being rendered improperly as ...
4
votes
1answer
80 views

Where do you put the game window in fullscreen mode?

My game, like most games, supports running in fullscreen exclusive mode. And I'd like to give my players the choice of which monitor the game will display on. In order to prevent the player from ...
3
votes
3answers
195 views

How do you apply relativistic physics to a 4x strategy game?

I had the big idea of trying to create a hard science fiction 4x strategy game (with the obvious space setting), which is supposed to simulate a realistic way of creating interstellar societies while ...
-1
votes
1answer
81 views

Turning my main(int argc, char** argv) cpp file into a class doesn't work [closed]

So, I needed to access variables from my main.cpp file in another cpp file, and the best solution for that (to me) was to make the main.cpp file a class. Like this : (sorry for long codes...) ...
3
votes
1answer
44 views

How do I correctly use SDL_RegisterEvent to create SDL_UserEvents?

I've been looking to use SDL's own event messaging system to pass events around to different parts of my game, since it supports user events. However, the documentation isn't very clear. Here is the ...
1
vote
1answer
80 views

Confused about this Timer function C++

I am confused about the argument "m" of this function. I also need to know how to make this work. I am working on a simple 2d game and I am really new to programming. I don't know how to make things ...
4
votes
3answers
347 views

Efficiently Handling Entity-Interactions in a Tile-Based World

I've been programming Roguelike games lately and there's a common problem I always run into. I can't seem to find a satisfactory solution for handling Monster-Monster interactions. For the intents ...
1
vote
2answers
100 views

FPS drop when detecting collision (sfml, c++)

So, I have this small class with a collision detection function in it, it's called every frame. When I run the game I get around 8000 FPS, but when the collision function gets called it drops to ...
2
votes
1answer
29 views

How can I get direction or link of file in computer

I want to import an .obj file in my Engine or open some files : To do that I write a link or direction of that file in my computer. Like this file.open("../Engine/data/model.obj"); But I dont want ...
0
votes
1answer
111 views

How to make my components only contain raw data?

I'm reading that Components in ECS are just only data and have no logic. I'm trying to follow this and I got that working: class Sprite : public Component { public: Sprite(const std::string ...
1
vote
1answer
149 views

How can I compute delta time in a cross platform fashion in C++?

I need a way to get time for calculating the delta time. I see that OpenGL and GLFW have methods for it, but unfortunately I can't use them since I need to make server software too. What is the best ...
2
votes
1answer
82 views

How to prevent tendencies to upper-left corner? [closed]

In a 2D tile-based game I'm making, I have a loop that runs through each of the tiles to check and apply values. One of the effects is intended to make a circle around itself, using a similar method. ...
1
vote
1answer
90 views

Is it ok to use polymorphism as a way of “interfacing” with objects in a scene? [closed]

I'm designing a class that holds values representing a 3D scene. This includes lights, cameras, meshes, materials, etc. The way how I'm setting it up is that each "thing" has a name. A camera has a ...
1
vote
0answers
59 views

C++ - what is the best library that I can use to create GUI if a textview already exists [closed]

I have a 2D char array in the textView.Basically,I need to map each char to a texture and render the whole view. Given a limited time, what is the possible best library that I can use? The header for ...
5
votes
2answers
118 views

How do I save a procedurally-generated map as binary level-data in C++? [closed]

For example, I'd like to do something as simple as a generating an array matrix using Conway's Game of Life and then filling each cell with particular data to be saved to a binary file. ...
0
votes
1answer
60 views

glDrawElements Crash

This is the "init" code of the Renderer class: glGenBuffers(1,&_idVBO); glGenBuffers(1,&_idEBO); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,_idEBO); glBindBuffer(GL_VERTEX_ARRAY,_idVBO); GLint lUV ...
0
votes
1answer
173 views

Terrain shader from heightmap opengl GLSL

I generated a terrain from a heightmap and now I'd like to apply shader on it which can contain different textures, based on height but I can't adapt any online code to my project. This is the ...
2
votes
1answer
59 views

Software polygon rasterization with transparency using raw image data

I have an image with shapes in it (squares and triangles with different colors scattered in the image) and I have an algorithm that matches the image and extracts the geometry vertices from image raw ...
2
votes
1answer
51 views

DX11 Losing Instance Buffer Data

I've got a function that basically creates different instance buffers into an array for me to use in my DrawIndexedInstanced call. But when I pass the vertex buffer and instance buffer through to my ...
1
vote
1answer
107 views

Why does SDL_RenderCopy result in a blank screen?

I'm trying to render a texture(picture), but SDL_RenderCopy keeps the window's background black. Here's the relevant code: SDL_Rect rect; rect.x = 0, rect.y = 0; while(!quit) { ...
4
votes
1answer
110 views

Stored Textures in C++ Projects

I have executed the following command in order to store a texture (PNG) file in a C++ header file: xxd -i Texture.png Texture.h. How would I go about loading this texture into OpenGL? ...
0
votes
0answers
93 views

Setting Up A Visual Studio 2015 Android C++ Project To Utilise The SFML Library And compile On An Android Device

So in Visual Studio I have installed the cross platform tools to set up a C++ project for Android and iOS such as the Android SDK, NDK and the corresponding USB drivers required to debug the program ...
0
votes
0answers
42 views

Cocos2d background sound not playing a second time C++

I'm using cocos2d-x on windows10 UWP project. I use the SimpleAudioEngine to load the music: CocosDenshion::SimpleAudioEngine::getInstance()->playBackgroundMusic("level_music1.wav",true); On the ...
2
votes
1answer
120 views

Making knockback in c++

I want to implement a "knockback" in my 2D game, but I have no idea how to do it. I've found some tutorials on google but nothing help. (My knowledge about math is a little limited when we're talking ...
2
votes
2answers
102 views

“Binding” script functions to C++ functions

I appreciate the answer to this question might be a little too broad for SE, but hopefully someone can point me in the right direction. I'm developing a small scripting language for use in my game ...