How do I increase speed with a "Power Up" item?

Get help using Construct 2

Post » Wed Jul 31, 2013 2:03 pm

How do I increase or decrease a players movment with a "power up" item?

So in my game coding, I realize if I set the max speed to 3000 in the left window under beaviors: 8Direction: I can create a power a sprite that when on colision can make the character go 3000.

However, I don't want the player to acclerate to 3000 at the strat of the layer. I want the power up to give them that ability.

Also, how do I set a timer, so that the power-up will stop working?
B
16
S
6
G
2
Posts: 165
Reputation: 3,209

Post » Wed Jul 31, 2013 2:49 pm

Create an instance variable on the player sprite like "speedCD"
On collision with the power up set maxspeed to 3000 and add 3 to "speedCD".

If speedCD > 0
subtract dt to speedCD

If speedCD <= 0
set maxspeed to default.

It's an idea, you have multiple way to do that.
B
39
S
15
G
5
Posts: 295
Reputation: 6,089

Post » Wed Jul 31, 2013 4:22 pm

Thanks that worked perfectly, now just to figure how to time out the power up.
B
16
S
6
G
2
Posts: 165
Reputation: 3,209

Post » Thu Aug 20, 2015 1:30 am

I would like my sprite to move automatically (ie without me pressing on the direction keys) at an increased speed, at a set angle, for a set amount of time upon contact with a "power up" item; does the above solution apply?

Also, I'm lost at the "subtract dt" part - where do I find that?
B
6
Posts: 2
Reputation: 263

Post » Thu Aug 20, 2015 8:02 pm

Have a look at basic physics equations involving s, u, a, v and t - especially velocity and acceleration.
My tutorial through development blog is at http://myconstruct2dev.blogspot.co.uk/
B
12
S
3
Posts: 221
Reputation: 1,328


Return to How do I....?

Who is online

Users browsing this forum: dop2000 and 57 guests