Tag Info

New answers tagged

0

C++ should be very efficient, but it also would make me have to worry about low-level details like manual memory management, and compiling for different platforms. Modern C++ highly discourages manual memory management. You should instead use smart pointers like unique_ptr and allocation functions like make_unique and never manually allocate or ...


0

About c++: You dont really need to worry about memory management. Ofc you handle memory yourself, but its not as hard as in C. In C++ you just allocate your memory by creating a Object (new xyz();) and free this memory by deleting it (delete var;). No more manual malloc() and stuff) About Java: Java supports Call-by-value with primitives and ...


3

There are a variety of ways to run code written in other languages in Unity. Most of these are platform specific. iOS: Since xCode will also compile C++ code, you could add the C++ code to the plugins directory and it will be built when you build the iOS app. You'd then define the function prototypes in C# so they are accessible from Unity. Documentation is ...


0

map<Key, Value> (and it's mates) holds Value, well, by value. If you try to give it an instance of derived class to hold as value, most likely "slicing" will occur. More about slicing: http://stackoverflow.com/q/274626/1125702 std::unique_ptr<Component> seems exactly what you want. It manages lifetime and memory of owned object. By convention, ...


0

DBVH (dynamic bounding volume hierarchy) is a common approach to solving this need. A BVH is just a tree of nodes containing one or more bounding volumes (e.g., circles/spheres) that are grouped together into a large bounding volume encompassing the children. There are several ways to construct a BVH. Some are intended to produce optimal trees from a known ...


6

It might be silly, but you could make a small C++ program around the chess library, that takes a simple text board state or movelist as input and returns the AI's selected move. I don't know .net's system libraries off hand, but you can probably start it as a subprocess, send to its stdin and then poll its stdout for a reply. Local sockets are also a ...


0

I have founded the solution: https://www.youtube.com/watch?v=xf0VD4ba4ns In this video's desc link shows a file that I used to the new code wich is working


2

This is a good question. I was trying to express that instead of holding an array of pointers to game objects, you can hold an array of game objects themselves, as pointed out by API-Beast in the comments of your question. You can implement this swap operation like this, assuming the array holds structs with simple data (structs with ints, floats, etc., no ...


0

Setting the CVar might lag a little, sure, but that's okay - you're already parsing the text input from a command. To optimize it if you must, hashing the name to an int for a quick lookup map is all you need. You could also make a directory structure, EG sv points to the sub-map containing sv_cheats to further minimize lookup comparison count. It's getting ...


2

The solution can be pretty simple - just add a field or flag and dont release until n bullets of your burst have been fired. in weapon: int burst = 0; when hadling event: void onFireButtonPress() { //previously simple fire(); burst = burst > 0 ? BULLETS_PER_BURST : burst; //or some other behavoiur like burst += 3 etc. } in game loop: ...


1

You are talking about string interning. It is widely used in compilers to represent identifiers. Basically, when the string is parsed from the command line or a text file, it is looked up in a global table. If it is already present, then it is assigned a number, and that number is returned. If not, then it is assigned the next available number, which is ...


4

First, avoid premature optimization. As Matthias notes in the comments, keep your implementation simple until you actually experience a performance problem that you can attribute (via profiling) to the configuration variable system. One of the big potential performance issues in an implementation like the one you have described will be the string ...


1

Are you dynamically creating the buffer for the draw call each frame? If the walls never (or rarely) change then a vbo will be a good optimization.


1

It might sound dumb, but make sure V-Sync is not enabled. And yes, reduce the draw calls to gain fps. If you have multipled shaders and textures, make sure you don't make unnecessary switches between them, like first draw all objects which use texture0 and not one object with texture0, then another one with texture1 and then back to texture0 etc. really try ...


2

They are not equivalent. In the GLSL shader you use the same texture coordinate for your diffuse and normal map (gl_TexCoord[0]). In the CG shader you use separate ones (TEXCOORD0 and TEXCOORD1, which is presumably not set).


0

An easy way to do this if your tiles are objects is to set a bool for whether a tile has been visited, which you trigger when the player coords match a "visitable" tile's. Then at render time you can go through your tileList and make any bulk actions to all tiles which have been visited or not.


0

sweepline, you sort the objects by the X or Y coordinate of the center and then check the objects in the range point.x-maxRange, point.x+maxRange


1

If all of your objects have the same range (say r), then the problem is to find all object centers which lie inside a given circle. In other words you can think of your original point (let's call this the target) as a circle of radius r centered at the target and your original circles (let's call them objects) as points, at their centers. In this case you ...


0

I think I got the reason. When I detect jumping time with sensor rectangle, the body at that time sill has velocity towards down. And when I give him impulse towards up direction it decreases its speed towards down (as it turns the impulse was small) and I think that it does not jump. But in case I apply linear velocity, it just starts to move up the the ...


0

The easiest way would be to use the flood fill algorithm. In your specific case you will probably want to fire off two different flood fills, one to the right of Pacman and one to the left. Whichever one is suitable to fill (the smaller one, the one with no obstacles detected, etc.) is filled and the other is discarded.


0

I personally haven't used the method your using. But since you have asked if there is another way to do this... Suppose you have a texture atlas (texture made up of sub-textures) where each sub-texture has the same dimensions: Then if you create a RECT R = {j*64, i*64, (j+1)*64, (i+1)*64}; ->Where int j = currentFrame / 6 //row ->Where int i = ...


1

SFML2 allows arithemic operations on sf::Time, like substracting or comparing timestamps. It will be more reliable and consistent to compare elapsed time with desired delay, rether than counting down, especially integer of milliseconds(?). Things like repeated shots are easier (imo) to implement, if you treat fire delays as locks, i.e. next bullet will not ...


0

Subtract the elapsed time for the current frame from the timer's current value. When the timer value goes zero or negative, you know time's up. Assuming SFML 2.0, you can do: sf::Time elapsed = clock.restart(); timer.value -= elapsed.asMilliseconds(); ...or elapsed.asSeconds(), or .asMicroseconds(), as you like; whatever units your timer uses.


2

The approach by Narrateur du chaos is commonly called the delta-t approach. But there is also another approach, the game-tick approach. In this approach you keep track of how long the game is running in real-time and how much time the game-world has processed. After each graphics frame you check how far the game world lacks behind the real world and do ...


1

I'm not an experienced developer, but your question seems straightforward enough. Your main() must look like this: int main(args) { // Code, declarations, whatever MainClass game(arg1, arg2...); try { while (game.continue()) { float ticks = timeSinceThatFunctionWasLastCalled(); ...


0

Given the option between "warping the cursor back to the middle of the screen every frame" or "constraining the mouse inside the game window", you always want to constrain the mouse within the window. With the "teleport the mouse to the middle of the screen each frame" approach, the mouse is actually not being constrained within the window; it's just ...


1

Your package name doesn't need to match the package where you put your classes. When you write your AndroidManifest.xml you specify both the package for the game and the path to your activity. So use something like com.company.engine for your activity and your C++ and just create a new package name for the game.


1

If you are only building for x64 native, this code is perfectly fine since it is always 16-byte aligned. class A { public: XMVECTOR vect; }; void fun(void) { A* a = new A; XMVECTOR localVect = a.vect; } To make it portable to x86 or ARM (32-bit), you have one of three choices: Create an overloaded new for the class A that uses ...


1

A high-powered family of algorithms you may need to look into are all "clustering" algorithms. These algorithms find groups of data points which could be Cartesian points or any other property (color, weight, etc.). See K-means Clustering for one such algorithm. It's not a terrible algorithm to run in real-time, depending on how many entities you need to ...


1

The other's have suggested kd tree's but I think that a more appropriate data structure for you would be using an R-Tree which is specifically for retrieving collections of near objects. You can find out more here: http://en.wikipedia.org/wiki/R-tree


1

A kd-tree or AABB tree is a great data structure, if the objects are going to be static, or mostly static, as they are not cheap to update. But it seems like those structures would be more useful to find what's around a certain point, rather than to figure out the largest cluster of objects. For that, I'd use a simple grid. Have each object register itself ...


1

There is nothing wrong with moving multiple pixels per frame. In fact, that's typical of most games. Even 2D games often store the character's position using floats, typically in a different space (world space), and then translate that to view space and then to pixels before rendering. The main problem you might run into is that is the character moves ...


0

There's no "better" solution here. You describe 2 different techniques, choosing between them is a design decision that depends entirely on the context and the intended effect. Locking the mouse with instant camera moves comes from FPSes, but I'm sure it has been used for other genres. It gives a very responsive and precise camera movement, but the down ...


2

Play some game with your system. Check FPS you are getting. Analyze what is on the screen of the game and compare to yours. If your one cube is rendering slower than game screen, you are obviously doing something wrong. I would expect one cube with all the normal stuff applied running atleast 500-1000fps on my computer. I can run games like Battlefield 4 ...


1

int limit = 0.333; is the same as int limit = 0; because int has no decimal places. So you ether work in fixed point where the number is divided by a fixed amount, or floating point. so for example if doing fixed point hundredths, you would use, const int FIXED = 100; unsigned long Timer::getElapsed() { if (! running) { start = ...


1

I'm building a cross-platform game engine at the moment. I'm using SDL, which is an excellent (and suitably low level) cross-platform library for building graphics applications, to ease the pain. Beyond this, though, is a lot of "custom code" for each platform. This you just have to get through. I've found it to be a very small fraction of my development ...


5

For a simple 2D engine with sprites, a single-threaded approach is perfectly good. But since you want to learn how to do multithreading, you should learn to do it correctly. Do not Use 2 threads that run more or less lock-step, implementing a single-threaded behavior with several threads. This has the same level of parallelism (zero) but adds overhead ...


1

Contrary to the other two answers (which are rightfully C++-specific), there is another way. Some architectures that come to mind: Port your engine: Modify or write code so that it works across multiple platforms. This is addressed in the answers above. Write something above a cross-platform library: This is the example of libGDX, which runs on Java. Java ...


25

Port your engine to each platform. There's nothing special about it. If you have some code that is Windows-only, then either add some #ifdef logic in the file or add a second file (so you'd have FooWindows.cpp and FooLinux.cpp or whatever) that implements that feature on the other OS(es) you care about. The one-click publish stuff that an engine like Unity ...


13

There's no magic bullet here. If you want your game to run on multiple platforms, you have to write code for multiple platforms (or leverage third-party libraries that already do this for you). The things you are asking for don't align: you say (emphasis mine) what I am looking for is resources to integrate something that will allow me run on ...


3

I am not sure what you want to achieve by limiting the FPS of the Update and Render both to 60. If you limit them to the same value, you could have just put them in the same thread. The goal when separating Update and Render in different threads is to have both "almost" independent of one another, so that the GPU can render 500 FPS and the Update logic ...


0

The short answer is "Poly count is not what Optimize is optimizing". The D3DXMesh Optimize routine performs the following (1) It attribute sorts the mesh, which means ensuring all faces sharing the same attributes are grouped together. Any shared vertices that appear in multiple attribute groups are duplicated. (2) Faces are optimized for the ...


1

For SDL2 (don't use SDL1 anymore): // to configure the window SDL_SetWindowFullscreen(my_window, SDL_WINDOW_FULLSCREEN_DESKTOP); // to unlock the mouse SDL_SetWindowGrab(my_window, false); SDL_SetRelativeMouseMode(false); // to lock the mouse SDL_SetWindowGrab(my_window, true); SDL_SetRelativeMouseMode(true); That first sets the window to the "fake" ...


0

Turns out, the depth values were correct the whole time. I was looking at a bad image for reference, where objects would get darker as they got further away from you. Of course, this is completely incorrect. After seeing how crazy normal depth precision is, I decided to use my own linear depth, which worked much better for shadow mapping.


1

Collision doesn't need to care about tiles at all. If a tile is just a shape of lines, your "tile collision" is really just collision against those specific lines. You can also use collision against arbitrary shapes defined by mathematical functions - like curves - which are represented by tiles. Tile collision in this case means determining which tiles the ...


3

You can see from the source code that glfwCreateWindow returns a null pointer in only a few circumstances (as of this writing). GLFW is not initialized at all (_GLFW_REQUIRE_INIT_OR_RETURN(NULL); on line 137). The width or height you specify for the window is zero or negative. The context configuration (controlled by you via the window hints, checked via ...


0

Before you get too deep into this project I'd like to comment. It looks like you're drawing the whole cube for each block in the world. If I am wrong, then ignore this, but if I'm right you should definitely consider a more efficient approach. You do want one normal per face, which probably means drawing cubes with 24 vertices (4 vertices per face, instead ...


0

If you would do hard normals for these boxes it would eliminate your problem. For that you have to have a normal not per vertex, but per face. You could do this by having four vertices with the same normal for each face of the cube, that is 24 vertices. That way, a whole face will receive an even amount of light. You also mention that you tried to combine ...


0

By default, the Direct3D 10 device interface is 'thread-safe' if you don't use D3D10_CREATE_DEVICE_SINGLETHREADED. This means it should work from multiple threads, but could well have lock contention. Direct3D 11.x splits the device into two parts: a Direct3D 11 device interface which is always 'thread-safe' (again unless you use ...



Top 50 recent answers are included