New answers tagged

3

Shared pointers make sense when you have unclear ownership and unclear lifespan; otherwise they're just a dead weight you're dragging around. For most games you want to have a defined build-up and tear-down points where you load all your data and dump all your data. For example, at level load and level complete. In this case you can just use a nice, clean, ...


1

You're out of luck. There is nothing wrong in your code, and there's nothing you can do in your code to guarantee any set of arbitrary lines will always meet perfectly by using the technique you are using. For line rasterization, OpenGL uses the diamond exit line rasterization rule (there is a primer of rasterization rules on the Direct3D documentation), ...


1

You should create a folder when you are creating/adding the class, in the dialog message when it asks for the class name you can add a folder to the path. In case that after the restart of UE4 the folder doesn't appear there could be 2 things: 1) UE4 will reflect only UCLASS files and folders - (if the folder doesn't contain any UCLASS it will not show in ...


0

For XACT, there is the doppler pitch scalar variable should be specified, ie relative speed, where 1.0 is the same speed, but < 1.0 is slower and > 1.0 is faster Thank you guys for the code, which I've transferred to this piece of C#, where a sound is calculated between screen position and a cue. Works precisely soundElements.ForEach(e => ...


-1

This is normal behaviour. All the C++ files header files have to be in the same folder so that Unreal can find them (and I presume VS as well) so it prevents you from adding sub-folders.


0

What is a segmentation fault? Core Dump/Segmentation fault is a specific kind of error caused by accessing memory that “does not belong to you.” (Source). Huh? What? Where and how am I doing this?? During the construction of your object (not exactly in the constructor). — Then, nonstatic data members shall be initialized in the order they were ...


0

Your issue is that you are over complicating your requirements. If a hero occupies a cell, then the cell is blocked. Do not allow "hero" objects to occupy the same cell. A* only cares if the cell is blocked or not, so all you need to do is tell it if the cell is walkable. Whenever a hero moves(changes cell), update your grid. Mark it's previous position(...


1

Your crashes is mostly because of improper handling of the object's ownership. When you add something to a collection, you should clearly understand who's owning the object. Is that handler owns the added objects now, and may delete those when time has come? Or is that handler only references the objects, and there's some other subsystem that will destroy ...


0

When in doubt, make sure you read the documentation for the functions you use. There are sometimes hidden gems and very useful tips there. In this case, we can see that there is a function called IMG_GetError() which should be used to retrieve a human readable message of the error you got. Using this, you'll be able to narrow down the possible sources of ...


0

Every time you call RenderScore, you leak an SDL_Texture by not calling SDL_DestroyTexture(Texture) before reallocating it with SDL_CreateTextureFromSurface.


14

Sometimes you might want to store your savegame data somewhere else than on the users hard drive. You might offer a cloud save service, for example. In that case you would use SaveDataToMemory to create a savegame in a memory buffer and then send that memory buffer to a server via network. Another possible use-case could be to always keep the last savegame ...


-2

I think: if you want to create levels using images for your engine, it's still better to have a more lightweight format: maybe just an array of bytes that represent positions and types of tiles. So I suggest to preprocess (bake) your 'any kind' of level image using some script (based on Python or JavaScript, for example) to your 'engine format'. There are ...


0

First, you comment that your position values are in [-1,1] range, so that approximation would be just fine, no? Also, that approximation functions you show are for atan(x) and not for atan2(y,x). See here for atan2(y,x) approximations. Second, you could nudge the compiler even more towards SIMD by supplying your input as structure-of-arrays. void ...


1

If you want to keep things simple, I would pick a format and stick to it. The two most simplest image formats that I know of are: PPM BMP TGA It's not that difficult to implement loading of any of these files. I see PPM files used a lot in ray tracing examples because the file format is so easy to handle. If you're the one generating these images, I'd ...


1

If I'm understanding it correctly, you have a single timer but many buttons that could be pressed. Why not have N timers, where N == Number of Buttons. This may sound daunting and gross; but it's quite easy to manage with a map (which is called a Dictionary in C# or Python.) Then use the keys that you're checking for as the inputs to the map, with the timer ...


1

Recalculating surface normals for a given triangle is simple: Given a triangle is composed of 3 points (p0, p1, p2), The face normal(Nf) can be defined as: Nf = (p1-p0) x (p2-p1) ) + ( (p2-p1) x (p0-p2) ) + ( (p0-p2) x (p1-p0) -------------------------------------------------------------------- | (p1-p0) x (p2-p1) ) + ( (p2-p1) x (p0-p2) ) + ( (...


0

DMGregory's comment of two days ago put me onto the solution by reminding me of something I had read in Learn OpenGL some time ago. In Learn OpenGL, by Joey de Vries, Learn OpenGL - Introduction, and specifically his page on blending, Blending, he discusses the combining of two images each with 4-channels of RGBA color data. The formula, shows how to ...


1

I think this is more an opinion-based question but here are my thought (I'm not a C++ expert): Create a base class Tile that will handle generic stuff like rendering, animations if any, behavior of the tile... For each of your special tiles, create a new class that inherits from your base class Tile and override the behavior if your new tile has a custom ...


1

Error C2653, the first one, says that EDrawDebugTrace isn't a class or namespace name, which is another way of saying (in this context) that the compiler has not yet seen a definition for EDrawDebugTrace. That's the root of your problem. Error C2923 is telling you that you cannot use EDrawDebugTrace::Type as a parameter for the template TEnumAsByte<>. ...


0

Is main.cpp the only cpp file in your program? It's better practice to have a main_menu.hpp and main_menu.cpp in your program instead of putting everything in the main.cpp. That being said I'm not sure what issue you are facing exactly. The general way to access all the 'variable's in your header is to #include it on top of your cpp file: #include "...


1

In your code, the choppiness is coming from the fact that you are jumping every time there is a syncing frame. Jumping to the halfway point is a good idea, but if the displayed playhead is consistently moving away from the actual playhead (or vice versa), then it will constantly be jumping back slightly (or, alternatively, forward). One way to smooth this ...


0

After trying all manner of things, deleting the .vs, Binaries, Intermediate, Saved and .sln, rebuilding the VS Files and building the project from there turned out to solve this problem.


-1

To handle multiple events, you need to cache them, so they can be dealt with once per frame. You need an abstraction of a controller, such as a keyboard: class Keyboard { private: bool pressedBuffer[256]; bool heldBuffer[256]; public: void handleEvent(SDL_Event const& e) { if (e.type == SDL_KEYDOWN) { ...


0

I fixed the problem by editing my model and with 3dsmax and change it's position.


Top 50 recent answers are included