Increase Gravity at Set Intervals
Greetings GS Forum!
I am currently trying to add a rule that:
-On achieving 20 Points
-Gravity Increases +50
-On going below 20 points
-Gravity Decreases -50
This is simple enough. However, I want it to be in multiples of 20. So:
-On achieving 40, 60, 80, 100 Points (etc).
-Gravity increases +50 at these intervals
-On going below 40, 60, 80, 100 Points (etc).
-Gravity Decreases -50 at these intervals.
Any suggestions?
-Thanks
-Blackmill
I am currently trying to add a rule that:
-On achieving 20 Points
-Gravity Increases +50
-On going below 20 points
-Gravity Decreases -50
This is simple enough. However, I want it to be in multiples of 20. So:
-On achieving 40, 60, 80, 100 Points (etc).
-Gravity increases +50 at these intervals
-On going below 40, 60, 80, 100 Points (etc).
-Gravity Decreases -50 at these intervals.
Any suggestions?
-Thanks
-Blackmill
Best Answer
-
GreekSalad Posts: 36
You'll want to create some attributes to reflect all of these updates
And it should look a little something like this:
game.NextLevel = 20 (This is going to be a representation of the Goal you're aiming for. You can set this to be any number you want)
game.CurrentPoints = 0 (This is the amount of points that your player has gained so far)
game.Interval = 20 (This is the interval you want to change between points that adjust the gravity. You can set this to be any number you want)
When game.CurrentPoints ≥ game.NextLevel
Change Attribute:
Increment game.NextLevel+game.Interval
game.Gravity +50
So then, what will happen is, you'll find that your game.NextLevel will be 40,60,80.. etc. - This is kind of a general look at using intervals and adjusting other attributes accordingly.
Hope this is of some help to ya.
Answers
otherwise
if NewPoints-OldPoints=-20 the Gravity=Gravity-50
I think? Not quite ... thinking some more .......
You would need two game attributes, something like game.nextscore and game.currentscore. Just before you change (increase or decrease) the score, change attribute game.nextscore to game.currentscore plus or minus the amount.
Then, have a rule that checks to see if floor(game.nextscore/20) is greater than floor(game.currentscore/20). If so, you've passed a 20 point marker while increasing your score. Also check to see if floor(game.nextscore/20) is less than floor(game.currentscore/20). If so, you've passed a 20 point marker while decreasing your score.
The difference between those two "floor" values could be used to determine the new gravity as follows: change attribute game.gravity (or however you are doing gravity) to game.gravity+(floor(game.nextscore/20)-floor(game.currentscore/20))*50.
This is all off of the top of my head... let me know if it works!
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
It's a tricky one.
-Blackmill
-Blackmill
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Hmm... works great with a score increment of 3, but not with higher numbers. Well, it's a start!
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User