The Power Of Integers!

Hi Guys,

This is for the few that might not be optimising their code, I'm sure a lot of you do use the power of integers! I remember when I started using gamesalad 3 years ago, I used to love Booleans, just the fact that you can switch things on and off has a great use! However since my knowledge of GS has grown, I replaced the need for Booleans with Integers and I'll tell you why. With a Boolean you only have 2 options, which are True or False, say for example I wanted to do the following,

3 boolean attributes,
play
settings
info

Rules,
if play is true & settings is false & info is false
change scene to level 1

if setting is true & play is false & info is false
change scene to settings

if info is true & play is false & settings is false
change scene to info

These rules allow me to do each respective tasks only if the others are false. If we had used an Integer instead we could do the following,

1 Integer attribute,
menuoption

if menuoption = 1
change scene to level 1

if menuoption = 2
change scene to settings

if menuoption = 3
change scene to info

This has allowed us to simply both the rule and also reduce the number of attributes! This has applications in so many places, check your code to see where you can simplify it!

Comments

Sign In or Register to comment.