Tag Info

New answers tagged

1

One way you could achieve what you need is to add a "priority" attribute to your GameObjectComponent; then add a mComponentsInOrder vector to your GameOjbect and keep ordered references in order, and sort it when you add new components. class GameObjectComponent { public: virtual ~GameObjectComponent(); virtual void Update(GameObject* obj, const ...


0

I believe it is as simple as accelerating until you are a square root closer and then decelerating to 0. This is because the final distance is equal to the square of the number you begin to decelerate at. If you begin to slow right after 3 pixels, you will end up at 9 pixels from your starting point. If you stop after 20 pixels, the final result will be 400. ...


2

There's no general way to do this, especially not cross-platform. Do you really have to pack your ressources into the executable file? I'd consider deploying a small setup program instead, which would unpack the ressources next to the executable file, which is essentially what you have when running from your IDE/when debugging. Just because you've added ...


1

OOP is your friend here! Many skills will have similar traits and you can categorize them so you don't have to recode every aspect of every skill. For example, skills will all be attachable to a character. An abstract class can be used for this. This class can also include several features that all skills have, like a call to simulate the skill or the tier ...


0

There are a number of ways to color objects in OpenGL. You can specify colors as vertex attributes. You can apply textures to objects by supplying texture coordinates and the actual textures. You can write fragment shaders to determine the color programatically. Or you can use a combination of those 3 things (and possibly others). Does your "3ds" file ...


0

Your problem is most likely the fact that you create copies of your blocks when adding them to your vector. That way once the original copy/block is destroyed, the texture won't be valid anymore (since there's a shallow copy happening, so even the new copies still point to the old texture, despite having their own copy). As a potential fix, change your ...


0

I am the guy who asked this question. When I asked this question I didn't knew much about sprites and textures, but then I learned quite a lot from the internet and sfml tutorials. Actually what I was doing in the program was not correct. I was storing the texture in a local scope which was getting destroyed at the end of the scope. Textures should be stored ...


0

The simplest solution is to keep textures in World class, like this: class World { public: World(); void draw(sf::RenderWindow *window); vector<Block> blocks; private: int level[12][16]; int wd; int hi; sf::Texture Texture; }; And definition: World::World() { if ...


1

D3D9 doesn't support constant buffers but all uniforms are placed into one global "constant buffer". You can set multiple float4 constants at once with IDirect3DDevice9::SetPixelShaderConstantF() by passing the number of constants as the last argument.


0

You could try doing things in reverse. Start with an empty grid and place the boundary walls on the play field. Then define a bunch of wall patterns that you can choose from. ... ie a straight section, an L shape, a C shape etc. Randomly place these on the map testing to make sure you still have a valid map. ie One that is not completely closed off by ...


0

What you can do is store boolean values for if the key was down or released and create some simple getters, a setter, and a "resetter" like so: struct Key { bool down; bool released; bool pressed; }; bool KeyInput::IsKeyDown(uint32 keyCode) { return s_keys[keyCode].down; } bool KeyInput::WasKeyPressed(uint32 keyCode) { return ...


0

I'm not sure if you're speaking of inability to keep up with FPS or UPS (Updates Per Seconds), but if machine has lower frames per second than expected you shouldn't change rate at which you're logic is being updated (UPS). Content of window is drawn depending on machine's capabilities but logic (and physics) run at constant and independent rate. In this ...


1

As an answer to this question and to most of the comments. Try making some other games first. Since you are a beginner, creating a multiplayer tic-tac-toe (as Shiro suggested) will be hard enough. Even if you can manage to create that creating an MMO is a massive task that most of us, and definitely the beginners, will underestimate. For example: how will ...


1

While a non-capturing lambda function can be converted into a free function pointer, a capturing one can not, which you've discovered. The generic approach to using member functions as callbacks is a common problem and is typically resolved via thunking or trampolines. In short, you make a static/free function which compatible with the mandated interface, ...


0

A quick test, just grab the logo image from the SFML site and paste it into the working directory of your project (or just somewhere simple and explicitly state that in code i.e. "C:\test\img.png") #include <vector> #include <iostream> #include <SFML/Graphics.hpp> int main() { sf::Texture texture; if ...


1

The question is, what pattern you want to achieve, and how to randomize the given pattern. You could place fix walls in a grid shape, then fill the rest with walls, and when you place the players, clear enough space for them to start. Then you could start randomizing things: Player starting position. Don't forget to check if the players aren't too close. ...


3

The near plane parameter shall be strictly larger than zero. The smaller it is the more precision you burn close to the camera, and with zero, the projection matrix degenerates into unusability. If your geometry isn't where you want it to be when you use a conformant projection matrix, address that problem instead.


0

my friend helped me to solve the problem, honestly, i still dont know what the problem was in the previous one, but i changed function as void keypress(unsigned char key, int x, int y) { Matrix R; HomVector a; switch(key) { ... case 'i': cam.rotation.x -=1.0f; break; case 'I': cam.rotation.x += 1.0f; break; case 'j': cam.rotation.y -= ...


0

You appear to be correctly storing a texture and then setting that texture to a sprite, so I don't think the White Square problem they're referring to in the documentation applies to you in this situation as you don't have the texture being created in a local function scope etc. std::vector<T>::push_back() creates a copy of the argument and stores it ...


0

With open gl you can't just bind a texture before creating it. Instead of keeping a counter called num_textures. Each time you want to create a new texture, retrieve a handle from OpenGL's glGenTextures function. int id; glGenTextures(1, &id); So you would get rid of num_texture and all its usages. And instead of this: glBindTexture(GL_TEXTURE_2D, ...


0

I can't post comments yet, but.. You said that you're moving the object, but from your code it seems that you're moving the camera (not the object). I see nothing wrong with the key presses though, the only thing that comes to mind is that if your camera happens to be centered on, say, a Cube, with no lights, rotating 90 degrees won't change the image so you ...


0

See https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/Components/UPrimitiveComponent/index.html It has all kinds of functions (Similar to unity). One being AddForce. Also, some physics is handle by Nvidia's Physx but I don't know how much of that you would interact with


2

btTriangleMeshShape cannot be used as a dynamic objects as stated in the API documentation. The btBvhTriangleMeshShape is a static-triangle mesh shape, it can only be used for fixed/non-moving objects. So your alternative is to represent the mesh using Collision Primitives or a collection of them. Single Primative Using a singluar primitve is the ...


1

I have a couple of suggestions Avoid Allocations and Copies A lot of your code has unnecessary allocations and copies. Instead of filling a vector with push_back, try pre-allocating the vector and setting the data there. You have a fixed maximum number of intersection points, so pre-allocate a vector of that size. Do a Simple Broadphase Before you do ...


1

Your density calculation is correct. Either the weight of the human is too much, or you have got to make the human bigger. In real life your human would have more volume or less mass. Which one to select is entirely up to you. And since this is top-down, you can expect to get the wrong density of the human with that formula. If it was a side view game, it ...


2

Intel released an crowd collision avoidance algorithm and sample code a few years ago that's designed to solve this problem. It's parallelizable, and you may be able to adapt the algorithm to work with your entities.


1

Basically, you need to know how GUI libraries work. In fact, you could even have a look on some of them to see how they get these things done (for example, you may have a look at GTK+ docs, or Qt docs to see the interface) However, assuming that you're not building the whole GUI library, but rather some basic ...



Top 50 recent answers are included