How do I make a temporary power-up?

Get help using Construct 2

Post » Thu May 18, 2017 8:06 pm

Hello, I'm having an issue sorting out the logic with making a power-up for my game. Basically, when the player collects the power-up, a bar is filled that slowly empties. What I want to have happen is, while the bar is not empty (i.e. has a width greater than zero), the player has 1 point added to one of their stats. I'd like to do it this way so that the bonus does not stack if they collect the same power-up multiple times, therefore it only applies once while true.

This seems like it would be pretty simple but it's turning out to be kind of hard to wrap my head around, namely because I don't know how to do truly temporary additions to variables- as in, not using two different events to add the bonus stat point and then subtract it again when the bonus runs out. If that's the only reasonable way, feel free to let me know how to do that, but I'd like if there were a more elegant solution that only took one event.
B
18
S
9
Posts: 103
Reputation: 1,817

Post » Thu May 18, 2017 8:20 pm

You can keep your player stats in an array, when you pick up the power up, increment the array cell value corresponding with the picked up, power up, after the duration is over just decrement the array call back the default value. Just don't forget to set the array values into the player instance variables ( or where ever you keep your player stats) on layout load out, and when you pick up the power up.

Using array is the best choice I think because you can easily modify the values whenever you like especially if you have an ingame shop, also array can be saved as Json so you can save the variable modifications even after the game is closed.
Like my work? Fallow me on social media, and see my games on the arcade.
B
7
S
5
G
9
Posts: 298
Reputation: 5,367

Post » Fri May 19, 2017 8:51 am

That does sound like a good idea since the player will be able to save the game etc, but what do you mean by incrementing and decrementing the cell values? Do you just mean making an event that sets it to "(whatever it's at)+1" upon picking up the power-up and then another for "(whatever it's at)-1" when it wears off?
B
18
S
9
Posts: 103
Reputation: 1,817

Post » Fri May 19, 2017 9:54 am

Yeah, like that, but you can add any value (does not need to be explicitly 1) depending on how you structured the player stats and how strong the power up is, just don't forget to reset the same value back to normal when the power up ends.
Like my work? Fallow me on social media, and see my games on the arcade.
B
7
S
5
G
9
Posts: 298
Reputation: 5,367

Post » Fri May 19, 2017 6:11 pm

Got it, thank you. Would you happen to have any organization tips? Because this

Image

is kind of a mess and hard to keep track of. Also, how do I make these values initialize to these only once, ever, instead of every time the player visits the layout?
B
18
S
9
Posts: 103
Reputation: 1,817

Post » Sat May 20, 2017 1:39 am

Have a sprite appear, wait x seconds, destroy it. You can have it on a timer (variable if it works or every x second) it appears.
B
20
S
7
G
3
Posts: 302
Reputation: 3,634

Post » Sat May 20, 2017 6:51 pm

You will have to initialize the stats At least once to the player when the game loads. You can call it every time on start of layout, or call it only once on a specific layer (main menu as an example).

There is no way to organize the array in construct 2, they will always look like a mess in the events, you will have to remember what each cell does. I usually open a word or exel document and I write my array there, and set a short description to what each cell does so I don't forget.
Like my work? Fallow me on social media, and see my games on the arcade.
B
7
S
5
G
9
Posts: 298
Reputation: 5,367

Post » Sat May 20, 2017 9:10 pm

Ahh, that's a bummer, but oh well. Thank you very much for the help, it proved super useful. :)
B
18
S
9
Posts: 103
Reputation: 1,817

Post » Sat May 20, 2017 11:33 pm

You are welcome

Good luck with your game.
Like my work? Fallow me on social media, and see my games on the arcade.
B
7
S
5
G
9
Posts: 298
Reputation: 5,367

Post » Sun May 21, 2017 4:23 am

You can make a temporary power up. Have it created, when the player collides with it something happens, an effect that's temporary.

On Collision with Power Up.
Destroy Power Up
Effect starts
Wait x seconds
Effect ends.
B
20
S
7
G
3
Posts: 302
Reputation: 3,634


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 16 guests