Hot answers tagged

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; ...


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 ...


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 ...



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