New answers tagged

1

This problem of "I found a collision/overlap, now what do I do about it?" is called collision-resolution. There are lots of different ways that games handle this, roughly in order of increasing complexity: Undo (as you described) Store the position before this movement integration step. If an overlap occurs, revert to this previous-good position. This is ...


1

Update Object in place. *cache["foo"] = Object(stuff); Or add a method that will reload the entire object. cache["foo"]->reload(stuff);


0

How to make sure that the reset for the smart pointer is not made, and the updated object was copied to the same address that it stores? I have not done this before, but you could allocate a chunk of memory yourself with malloc, and call the constructor yourself with an address that you now own (in the chunk allocated with malloc). That could work if your ...


0

Start with a 2d array of tile. If they are all displayed on screen, there should not be too many tiles. Each of your tile hold lot of data? Split data by concern and create one 2d array per concern. For example with a sim city like game path finding array will hold data about terrain surface, electricity availability could be another array... It all depends ...


1

There are several options. For example: An std::map which maps coordinate pairs to tiles An adjacency graph (each tile has pointers to its neighbors - pretty useful for pathfinding or other applications where you need to navigate from tile to tile) A two-dimensional tree (allows you to quickly obtain a rectangular area of your map - useful for rendering or ...


0

After following a few suggestions from Josh here on Stack and doing a bunch of research, here's what my working code looks like: #include "stdafx.h" #include "Keyboard.h"; #include "Photon.h" #include "Player2D.h" #include <windows.h> #define MAX_LOADSTRING 100 // Global Variables: HINSTANCE hInst; // current ...


4

GetMessage blocks until a message matching the filter is available. Generally you want to use PeekMessage instead to implement a real-time game loop, in a fashion that looks roughly like: while (!done) { if (PeekMessage(&message, window, 0, 0, PM_REMOVE)){ TranslateMessage(&message); DispatchMessage(&message); } else { ...


1

To do this in Unreal and C++, you'll need to set a pointer to the class and then cast to it. Casting is expensive in terms of overhead so if it's something you'll be doing often, it's best to get it sorted in Begin Play and call the variable in Tick or whenever you want to call it. In the .h file: class ACharacter; In whatever section (public, private or ...


2

Use GetOwner() in the component


2

I'll take a stab at it. Some people are much more knowledgeable about c++ and how all that stuff work, so please feel free to comment and vote accordingly. Both examples that you give are roughly equivalent in terms of efficiency. In both cases, the values for each element is contiguous. You're practicing 'struct-of-arrays' instead of 'arrays-of-structs' in ...


0

When going left/right, you use the whole left/right border (aka collider/detector) to check if player collides. If going up/down, you should use the whole top/bottom border of the player to check the collision. This means you have to check for all blocks that detector overlaps. This will complicate your collision detection, but doing it right will spare you ...


1

I ended up solving the problem (thanks to DMGregory's hints) by generating meta files for each asset. The meta files contain the path to the preview image used in the asset explorer window, and import settings. Only when the asset is 'inspected' I fully load it into memory. That way the engine start's niceley without having to wait for files to load ...


0

If I understand correctly, you have a game engine with a GUI, and you want to display to the programmer the assets that the current project is using? A lot of GUI programs (I believe unity too) create small thumbnails for images, which are a lot smaller in size than the original assets, so they can be displaying without issue. How big or small those should ...


1

Regardless of the use of Allegro, a mutex and threading is a set of agreements made between yourself, and the rest of your code to enforce "MUTual EXclusion" of the use of shared data. Simply locking a mutex doesn't ensure the data will not be touched. It's not the data itself that's locked, it's the thread the mutex is running on. What is necessary with ...


1

I think the IsKeyPressed check is checking if the key is pressed continuously. Therefor both conditions are met. Look for a IsKeyDown or IsKeyUp implementation. This should met your requirements.


1

What troubles me is you're not using quaternions for an Arcball camera. My answer comes from some of my DirectX code so if you see some strange behavior, I probably messed it up for OpenGL ;) it is far more simple to use quaternions, even if that sounds barbarian to you, it is easier to wrap ones mind around quaternions than matrices (of course in the ...


0

Sprites If I decide to go with the rendering system, what would be the best way to store and send sprites? I suppose that I need to make a sprite resource manager. If so, how is the best way to send them to the render system without coupling things too much? Or perhaps the sprite resource manager should reside in the render system itself? I faced this ...


Top 50 recent answers are included