New answers tagged

0

I've been proposed for using awesome Clipper library. It is exactly the thing I need. "For constructing the union of 2D polygons you can use Clipper library."


0

They way I've gone about calculating the delta time has been via SDL_GetTicks(): struct Clock { uint32_t last_tick_time = 0; uint32_t delta = 0; void tick() { uint32_t tick_time = SDL_GetTicks(); delta = tick_time - last_tick_time; last_tick_time = tick_time; } }; Then I simply tick a Clock instance in the main ...


1

Another strategical rule of Tetris you didn't mention is that it is crucial to avoid closing up holes. || Bad move! \/ ## ## ### ##### # ### ###### # ### ####### # <-Creates a closed up hole on this row. ########### # Place it somewhere on top instead! When there is no way around it, it's better to create the hole in a row ...


0

Depending on the library or technology you are working with - things can get easier. But it is almost always good to understand the maths behind this stuff. Have a look at the line through plane equations on Wikipedia.


1

You are generating a random number incorrectly. int change = ((rand()%1) * 5 - 1) * displacement; Change will always be (-1 * displacement), because anything modulus 1 is always zero. Try this for a range of [-5, 5]: //rand() % 11 returns range [0, 10], subtract 5 makes range [-5, 5] int change = ((rand() % 11) - 5) * displacement; I also recommend ...


0

I ended up doing what DMGregory suggested and it works well. Here's some relevant code (though not standalone) that can be used for computing the two styles of tangents. I'm sure this code isn't efficient, and it's probably not even correct in all situations, but it's working for me so far: bool Circle::outer_tangent_to(const Circle & c2, ...


3

As far as I can tell the purpose of your code is to always round to 45° increments. So you can use the function Mathf.Round. It always rounds to the nearest integer. When you want to round to the nearest multiply of 45, you need to divide the angle by 45, apply the rounding and then multiply it again: float newAngle = Mathf.Round(yRotation / 45.0f) * 45.0f; ...



Top 50 recent answers are included