Milestone triggers
Doguz
Member Posts: 500
Hi, I'm not good at the math so I'm asking the question here. I have a game that has a score. The score grows and grows every time you play. It just continues on. i.e does not reset. The aim to my game is to ultimately reach 1,000,000points. I'd like to trigger an event every time the score clocks up another 1,000.
Now the this needs to happen at the end of the game (not when it hits 1,000 exactly) and the score might just be 4,234, but because the score passed 4,000 it needs to trigger. The next game might end on a score of 4,945, So no trigger. The next game we'll reach 5,345. So we need a trigger after the game ends.
Does anybody know of how I could calculate this?
The trigger I need is to simply bring on another actor to the screen to congratulate the player. So I'm guessing the rule could 'live' inside this actor.
Now the this needs to happen at the end of the game (not when it hits 1,000 exactly) and the score might just be 4,234, but because the score passed 4,000 it needs to trigger. The next game might end on a score of 4,945, So no trigger. The next game we'll reach 5,345. So we need a trigger after the game ends.
Does anybody know of how I could calculate this?
The trigger I need is to simply bring on another actor to the screen to congratulate the player. So I'm guessing the rule could 'live' inside this actor.
Best Answers
-
tatiang Posts: 11,949Haven't tested it but how 'bout this:
When game.score >= game.HighestThousand*1000
.....Change Attribute game.HighestThousand to ceil(game.score/1000)
It fails when the score is exactly a multiple of 1000, though.New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
-
tatiang Posts: 11,949Guess I'm not that lazy. Here's a better version:
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
-
tatiang Posts: 11,949Floor takes a number and rounds it down. So floor(.9)=0 and floor(1.4)=1.
Ceil [ceiling] takes a number and rounds it up. So ceil(.9)=1 and ceil(1.4)=2.
Prec [precision] rounds as you would expect but uses decimal places. You can test it with various values such as prec(5.5,0); prec(5.5,1); etc.New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Answers
Just throwing out ideas.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Whats the difference between the two commands?
For example:
prec(5.51,9) should return 5.510000000 but in fact returns 5.510000229, I don't suppose it really matters in the real world as the discrepancies are so small, I just thought it was odd for a mathematical calculation on a computer to be off by even a tiny amount ?
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
if score <=1000 do (something)
Else if score <=2000 do (Something)
Else If score <=3000 do (something)
This effect is created by dragging a rule into the else section of a rule. And if you copy it into itself can grow exponentially (in design time). ty and yw