At 3/10/09 06:01 PM, StaliN98 wrote:
binary logic instead of a bunch of if/elses; and data types speed things up.
Apparently Ifs and Elses are slightly faster than .. ? .. : ..., but thanks for suggesting.
... ? ... : .... is ternary, and it's very slightly slowwer than ifs and elses. What I meant by binary logic was something like
var b = (Key.isDown(Key.LEFT)-Key.isDown(Key.RIG HT))
instead of a bunch of ifs/elses for it. You can only apply it in certain situations, but I'm pretty sure it speeds it up. But I think AS3 killed that method of doing stuff, so forget I said it.
But ternary slows things down, so you might wanna avoid it.
So should I use an int that can be 0 or 1 instead of booleans?
Nooooo, definatly keep booleans instead of ints, booleans are far smaller memory wise. I just didn't explain myself properly first time lol.