Tag Info

Hot answers tagged

3

When you run your while loop in each of your HandleInput functions, you're burning through the entire event queue up to that moment in time. So yes, whichever event handler you call first will eat all of the events. There are a few ways to handle this problem, but obviously, paramount to every possible solution, is the removal of your destructive ...


3

This problem is called Forward Kinematics. To solve this problem in general, I recommend creating what is called a Kinematic Chain, or Kinematic Tree. To do this, you will need knowledge of a 2D rotation matrix, or transformation matrix. A 2D 3x3 transformation matrix is defined as: H = [xx, xy, tx; yx, yy, ty; 0, 0, 1]; In this case, [xx, ...


2

Another (albeit a little more complicated) thing you could do is have your components register for specific event types: class EventHandler { public: using EventCallback = std::function<void(SDL_Event const&)>; void register(SDL_EventType type, EventCallback callback) { _registeredCallbacks[type].push_back(callback); } void ...


2

SFML 2.0+ makes it even easier to load a texture; sf::Texture texLid; std::string image2="images/top.jpg"; if (!texLid.loadFromFile(image2)) { std::cout << "Could not load" << image2; char c; std::cin>>c; return false; } glEnable(GL_TEXTURE_2D);//tell OpenGL to use textures when drawing ...


1

You need to move each part to 0,0 then rotate them, then move them back. Without doing this they just rotate around 20 units fron your character


1

I'd probably use a 1 bit texture (more if you want to store more states) and then draw it using a shader (or a second texture you only modify once some pixel is hit). So yes, this would essentially mean you're working with a pixel perfect collision detection, but you wouldn't necessarily use a full bitmap/texture (1 bit per pixel vs. 32 bits per pixel). Of ...


1

You need to put your thinking level one step backward, and try to imagine that there is a different way than the quadratic solve. You can use iterative solving. This will not give you a perfect solution in all cases, but when many entities moves relative to each other with 2 or 3 contact points in average, this is the fastest and gives very good results. All ...


1

You are polling all the events the first time you handle them and not using all cases at that time. That will leave some untouched. Instead of having multiple event polls, have it all processed in one function. (Preferably in your main class or somewhere able to access all things needed to be updated by events)


1

The problem was inside present parameters - i forgot to set backbuffer's width and height. dx_PresParams.Windowed = TRUE; dx_PresParams.SwapEffect = D3DSWAPEFFECT_DISCARD; dx_PresParams.BackBufferFormat = D3DFMT_UNKNOWN; dx_PresParams.BackBufferWidth = 1024;//Width dx_PresParams.BackBufferHeight = 1024;//Height dx_PresParams.EnableAutoDepthStencil = TRUE; ...


1

You need to store some c (c++) properties for the enemy to support this. You have to ask yourself: Do you want each enemy to shoot in sync? Or off sync? Do you want shooting to be at a set interval or the timing to be somewhat random? Do you want each enemy to have shooting triggered by some other event so that shooting can be turned on or ...



Only top voted, non community-wiki answers of a minimum length are eligible