Boolean VS Number

Discussion and feedback on Construct 2

Post » Mon Nov 12, 2012 3:42 pm

I agree that boolean would be easier to debug, but for me, I have to use a bunch of state checks. I have one for isattacking that will not only let you know if an attack animation is playing but also the power of the attack to see who's attack will win if two players attacks both collide. (0 is not attacking, 1 or more means is attacking, a higher is attacking will win). I also have some for sidecharge, upcharge, downcharge, isblocking, isrunning, is jumping and a few more to come. This will be replicated for up to four players on screen at once.   But maybe using one string as a player state indicator would be beneficial...    either way thanks so much for all the help everyone!! :)
B
32
S
4
Posts: 406
Reputation: 3,221

Post » Mon Nov 12, 2012 5:00 pm

Well, I use strings for finite state machine, booleans for dual states (on/off and toggles) and numbers for mathy stuff as well as enumeration.

I would be ecstatic with an array as a variable (for example ["PowerAttack",2,true]), but well, I guess that's still far fetched right now!
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155

Post » Mon Nov 12, 2012 5:02 pm

This thread on Stack Overflow sums it up nicely. Note that it took over a hundred million operations per second for any performance hit to appear, and even then we are talking nano-seconds of a difference.
B
24
S
4
G
1
Posts: 244
Reputation: 3,462

Post » Mon Nov 12, 2012 6:14 pm

Very interesting read! I think you guys have cured me of my worries!
B
32
S
4
Posts: 406
Reputation: 3,221

Post » Mon Nov 12, 2012 9:01 pm

That is an excellent blog post. Everyone should read it.
Personally, I like to use boolean for where it makes sense. But overall, its up to personal preference and whatever speaks to you.
B
16
S
6
G
5
Posts: 90
Reputation: 4,324

Previous

Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 15 guests