How do I manage variables

Just started using Construct 2? Post your questions here

Post » Sat Jun 28, 2014 5:15 pm

Hello everyone,

I started a game on Construct yesterday, so I'm pretty much a beginner. That's why I will have many questions.

My project is a shoot em up and the concept is when the player shoot he will use some of his life. So when he doesn't shoot his life come back with some time.
Player (P): 100PV
P: shoot 10 times >>>100PV-10PV=90PV
P: wait and dont shoot 5sec
P: regen 10PV >>> 90PV+10PV=100PV

But even if P wait 10 more second his life will still stay at 100PV because it's his normal MAX PV.


It was easy to do that, but the other point is when the player kill an ennemi, he will receive a part of the ennemi life.

Player (P): 100PV
P: shoot 2 times >>> 100PV-2PV=98PV
P: kill MOB so P receive 10PV in bonus
P: 108PV

But after that :
P: 108PV
P: shoot 15 times >>> 108PV-15PV= 93PV
P: wait 20 sec
P: Regen to 100PV (and not 108PV !! the player loose his 8PV bonus points )

And I'm pretty lost with this last part unfortunately. But like I said I'm a beginner with Construct 2, so if somebody could help me with that it will be amazing.

Thank you very much
B
3
Posts: 4
Reputation: 183

Post » Sat Jun 28, 2014 7:45 pm

Change Max HP to a variable if it's not already (PV means private variable?), if player is still alive and gets a health bonus, add that bonus to Max HP. When player dies if you want their Max HP to reset to 100 then just have it set to another variable like DefaultMaxHP.

Hope that helps!
"Construct 4 lets YOU make advanced games! (but not play them)" Construct Classic - Examples Kit Dropbox is a pile of trash and if you need my old files PM me! :)
B
116
S
41
G
17
Posts: 2,204
Reputation: 19,545

Post » Sun Jun 29, 2014 4:46 pm

I believe PV means HitPoints. He's probably portuguese or spanish speaker. :)

Like Jayjay said, Shoy, you should create a Global or Instance Variable (which in fact would be a Constant), called MAX_PV, and set it to 100.

When you're adding PVs because of time, add a condition, before adding, which checks if PV <= MAX_PV and only add PVs if current value is lower than MAX_PV.

When receiving the bonus for killing do not compare against MAX_PV, so you can add beyond that value.
Bruno

I like to eat, but I'm no cook. Why liking to play games would make you a game designer?
B
16
S
4
G
1
Posts: 428
Reputation: 2,337

Post » Sun Jun 29, 2014 4:51 pm

@brunopalermo ahh okay, also I was suggesting he instead adds to MAX_PV, as it sounds like he wants players to get a health bonus that auto-regenerating can go back to, but they lose that bonus on death. Either way works though :)
"Construct 4 lets YOU make advanced games! (but not play them)" Construct Classic - Examples Kit Dropbox is a pile of trash and if you need my old files PM me! :)
B
116
S
41
G
17
Posts: 2,204
Reputation: 19,545

Post » Sun Jun 29, 2014 4:57 pm

As far as I got it he wants the regeneration by time to be limited to the MAX, which goes unchanged forever. When you get the bonus for killing an enemy, you would go beyond that MAX, but, once you're down to below MAX, regeneration would only take you back to the original MAX value...
Bruno

I like to eat, but I'm no cook. Why liking to play games would make you a game designer?
B
16
S
4
G
1
Posts: 428
Reputation: 2,337

Post » Sun Jun 29, 2014 5:18 pm

@brunopalermo Ahh, I can see that reading of it now looking back at his request. I was thinking he was reporting what currently happens rather than what he'd like to happen. Thanks!
"Construct 4 lets YOU make advanced games! (but not play them)" Construct Classic - Examples Kit Dropbox is a pile of trash and if you need my old files PM me! :)
B
116
S
41
G
17
Posts: 2,204
Reputation: 19,545

Post » Sun Jun 29, 2014 11:08 pm

brunopalermo wrote:As far as I got it he wants the regeneration by time to be limited to the MAX, which goes unchanged forever. When you get the bonus for killing an enemy, you would go beyond that MAX, but, once you're down to below MAX, regeneration would only take you back to the original MAX value...


Hey Yes Bruno you understood my question.

PV means for me : "Point de Vie", it's french and means Life Point. :lol:

I will try something tomorrow and tell you if it works.
B
3
Posts: 4
Reputation: 183

Post » Wed Jul 02, 2014 8:50 pm

Good to know it's PV in French too. These latin languages... ;)
Bruno

I like to eat, but I'm no cook. Why liking to play games would make you a game designer?
B
16
S
4
G
1
Posts: 428
Reputation: 2,337


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 2 guests