New answers tagged

2

Instead of a static size std::array, which size can't be changed during the execution, you could use a std::list, this will allow you to change the amount of meteor arbitrarily. And for the increased amount, you don't supply much information about how your code currently works, but... If you use a fixed time step, you need to have a frame counter at some ...


0

You could create an empty array of circleshapes which is larger than 10 (size = max number of meteors on the screen, for example 25) and just fill its first 10 indexes, and then, as time passes, add more circleshapes to the array until the maximum size is reached. You may want to keep a variable holding the actual size of the meteors array, but remember to ...


9

I came back to this today and after some more investigation and trial and error I discovered that the culprit was targetTexture. With some more investigation I learned that reading and writing to the same texture in a shader is bad practice (not surprisingly) and will cause undefined behavior on GPUs. The solution was to copy the target texture to a new ...


2

Here's one of my go-to jump functions. It's similar to a Mario jump - fast at first, slowing down until reaching the top. Please excuse the syntax. I haven't used C++ in ages, and never SFML. const float GRAVITY = 9.0f; const float MAX_VELOCITY = -10.0f; const float MAX_AIR_TIME = 1.2f; float timeInAir = 0.0f; float jumpImpulseTime = 0.2f; float ...



Top 50 recent answers are included