Reducing Conditionals

I have noticed a lot of defold code usually has complex nested conditionals to perform game logic. This is especially true for handling input

I just wanted to ask if you folks have any refactoring tips to make these a little more readable.

The engine is really cool and I hope to keep learning. Thanks.

I’ve found that if my code is turning into in impenetrable mass of nested conditionals, then it might be worth seeing if the overall logic can be expressed as a state machine (in general it’s a big topic, but I’m sure there are plenty of easy practical tutorials in case you’re not familiar).

2 Likes