How do I set a maximum value for an integer?

Get help using Construct 2

Post » Wed Nov 13, 2013 9:28 pm

I'm new to Construct 2. Currently I'm working on a game where you play as a plane and shoot down other planes. It's very simple, obviously. I've added functioning health pick ups to my game. However, I don't want your health value to ever exceed 100. How do I set it so that no matter how much is added to your health, it never exceeds a set maximum value of 100?
B
2
Posts: 2
Reputation: 154

Post » Wed Nov 13, 2013 10:55 pm

add an event: health > 100: set health = 100
Visual Novel 'Engine' in 100 Events
if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review
B
22
S
9
G
1
Posts: 788
Reputation: 3,788

Post » Thu Nov 14, 2013 12:13 am

Thanks so much! I'm not sure why I didn't think of this myself.
B
2
Posts: 2
Reputation: 154

Post » Thu Nov 14, 2013 4:09 am

Or, if you want to save on events, use min() in your calculation.

player picked up health -> set health to min(health + whatevervalue, 100)
Image
B
24
S
8
G
10
Posts: 1,821
Reputation: 8,279


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 5 guests