Why is attempting to rotate both ways going to be bad?

Hi there. The bonus challenge was to decide why attempting to rotate both ways would be bad, but without explaining why.

I’m not sure how the thrust and rotation are actually going to be implemented, but handling both key presses seems objectively better than adding the ‘else’ and sticking yourself into this situation where this arbitrary “prefer left” system is present.

There was quite a bit of hard nudging suggesting that holding both keys would be bad, but I don’t understand why.

Hi Dave,

Welcome to our community! :slight_smile:

I’m not exactly sure to which piece of code you are referring but holding both keys is not bad per se. However, if both keys access the same things in the code, e.g. the rotation property, only one line of code will determine how far the rocket is going to rotate this frame: the last code which got called.

This means that we would execute code that won’t affect our game, which is a waste of resources. For this reason, we use “else” so certain parts of our code won’t get executed.

Did this make sense?

See also:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms