Lots of Rules vs. lots of otherwise? performance
Stormtrix
Member Posts: 256
Hey all,
was just updating my Blind Man's Bluff card game and was thinking -
for randomizing one card and then deciding what image to show for the random number, does it matter from a performance view if you chose one way or the other?
For instance -
Change attribute/ game.card to random(0,52)
Rule if game.card = 12
use this card
Rule if game.card = 13
use this card
and so on.....
or just make 1 rule and put 52 otherwises in it.
thank you,
and happy holidays
was just updating my Blind Man's Bluff card game and was thinking -
for randomizing one card and then deciding what image to show for the random number, does it matter from a performance view if you chose one way or the other?
For instance -
Change attribute/ game.card to random(0,52)
Rule if game.card = 12
use this card
Rule if game.card = 13
use this card
and so on.....
or just make 1 rule and put 52 otherwises in it.
thank you,
and happy holidays
Comments
The only problem i can see is with you having 52 the rule box will get pretty small as it shrinks every time you do a new otherwise.
Darren.
If that's the case, you could simply go as BarkBarkCo suggested. You only need two rules!
Otherwise seems better to me using "otherwise" than separate rules in terms of performance.
I went from having 52 rules to just 1 !!
First I made the file name my 52 cards random numbers between 1-52 like.
2Hearts.png is now 24.png, 3Clubs.png is 14.png, KClubs.png is 7.png, etc...
then just did this
Timer - Every .001 sec -
change attribute: game.randomcard To: random(1,52)
Rule - When touch is pressed ( on back of card )
Change Attribute : game.card To: game.randomcard
Change Attribute: self.image To: floor(game.card)..".png"
Done.
Appreciate the help again!
Merry Christmas
Darren.