Shield text needs to show maximum value of 100
Zombiebrains
www.zombiebrains.co.ukMember, PRO Posts: 296
Hello all
I have a problem with my bonus system and my shield attribute value
I have a game where if the player destroys all the ships on screen, I would like it to add 20 units to the shield that at 100% is the number 100 (displayed as text as have no good graphic effect to show shields).
If the ships go off screen they bomb the earth and the shield (100 units as shows as text) is depleted by 10 units per ship.
Now, I want it so, when the player successfully destroys all aliens, the game will add 20 units back onto the shield but I would only want to to stop and show 100 (i.e 100%).
I have an attribute called - 'Earth Shield' and it starts each fresh game as 100.
How do i get the earth shield text to only show a maximum of 100 if 20 units are always added to the earth shield?
I have it now say the earth shield is at 90, when the destroy all aliens bonus is add (20 units back) it shows 110? - need it to only show 100.
Oh if anyone has a good graphic effect that can show 100% (shield) then I would love to know.
Thanks everyone
I have a problem with my bonus system and my shield attribute value
I have a game where if the player destroys all the ships on screen, I would like it to add 20 units to the shield that at 100% is the number 100 (displayed as text as have no good graphic effect to show shields).
If the ships go off screen they bomb the earth and the shield (100 units as shows as text) is depleted by 10 units per ship.
Now, I want it so, when the player successfully destroys all aliens, the game will add 20 units back onto the shield but I would only want to to stop and show 100 (i.e 100%).
I have an attribute called - 'Earth Shield' and it starts each fresh game as 100.
How do i get the earth shield text to only show a maximum of 100 if 20 units are always added to the earth shield?
I have it now say the earth shield is at 90, when the destroy all aliens bonus is add (20 units back) it shows 110? - need it to only show 100.
Oh if anyone has a good graphic effect that can show 100% (shield) then I would love to know.
Thanks everyone
It takes a Zombie to know a Zombie!!!
Comments
Thanks Gabfather...
It takes a Zombie to know a Zombie!!!
When condition is valid, change game.shield to min(game.shield+20,100).
(The min Function returns the smaller one of two values)
It takes a Zombie to know a Zombie!!!
How exactly would I enter this in Gamesalad? I've now added 10 - 100 GFX actors for the numbers as the shield goes up in steps of 10.
When the shield goes to over 100 the 100 GFX I have assigned disappears as I have a rule for each of the ten numbers - if earth.shield is NOT 100 ( or 80 for say then 80 shield rule and all the same for the rest) then destroy actor.
Now when I have a shield strength of say 80 and a bonus of 30 is added, the score should go to 100 again but gamesalad added the 30 to the 80...the shield then goes temporarily to 110 but this then of course makes my 100 graphic disappear as there is no GFX actor for anything above 100.
How do I fix it so if 100 is the absolute maximum, gamesalad does calculate anything over 100.
I'm ready to submit to itunes but need to fix this final bug!
Thanks guys
It takes a Zombie to know a Zombie!!!
Rule (assuming you have an Attribute named Strength):
if strength is => 100
change attribute strength to 100
http://jamie-cross.net/posts/ ✮ Udemy: Introduction to Mobile Games Development ✮ Learn Mobile Game Development in One Day Using Gamesalad ✮ My Patreon Page
The min function will return the smaller of two values, so a min(80+30,100) will return 100. min(90+30,100) will return 100, etc
Just implement this function in all your calculations and you won't get a value greater than 100...
First you let the engine add values over a limit, then you let the engine check if this calculation has crossed the limit, and if so the engine has to correct the value to the limit...
If you have lots of actors and lots of rules, this will affect the performance.
So why not implement the limit in the first calculation and get rid of all following calculations?
You can use the max function for a lower limit by the way...
max(attribute-10,100) will return the greater value, so if you subtract from a value and your limit is again 100, no values smaller than 100 will be returned (that makes only sense if the attribute you want to subtract from is greater than the limit of 100)
Both ways will seriously lighten your code...
And that is always good (even in GS)
http://jamie-cross.net/posts/ ✮ Udemy: Introduction to Mobile Games Development ✮ Learn Mobile Game Development in One Day Using Gamesalad ✮ My Patreon Page
Thanks for the reply.
In my game I have an invisible actor on my scene.
This has a set of rules where if the Earth Shield is 100 it will spawn in front of the invisible actor the actor '100'. If the shield is 50 it will spawn the actor '50'.
Now each actor has a rule...example below.
If Earth.shield is not 100 then destroy.
I'm struggling to get my head around the min thing...sorry me being a noob and thick!
How can I get your idea working in my scenario.?
Sorry to pester you over this.
It takes a Zombie to know a Zombie!!!
And if you do that your Earthshield will never be greater than 100...
I presume what your saying is that I need to add this MIN thing to that rule.
Never used MIN so unsure how to enter it in my rules.?
It takes a Zombie to know a Zombie!!!
Replace the 'x' and 'y' values with values or expressions as needed, according to the suggestions made above in this thread.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
All math-functions from that pull-down-menu could be typed in directly.
I prefer this, because it is faster and if you have a more complex expression, the editor becomes a very long window and you have to scroll back every time to implement a new function.
@Zombiebrains you have to modify your earth shield rules
At the point where you add the the values to the earth shield you modify the change attribute behavior:
earthshield to "min(earthield+value,100)" (without the quotes and don't type the earthshiel attribute, you must select it from the drop down menu underneath the arrow button left to the "Insert function")
I've been a pleb! after all that effort, I had forgotten to add the reference back to the Earth.Shield before adding the +20,100.
My expression was
if score = 1000, - min(+20,100) instead of min(Earth.shield+20,100).
Thank for your original comment as I just didn't read it properly.
I've added that to all my points increaser rules and it worked a treat now!
Thanks to you and the other great people in here with helping me with that...
I can now get this submitted to the app store today.
Happy bunny now
It takes a Zombie to know a Zombie!!!
Good luck with your game