Mechanic 7 - Dash

Add two new instance variables to the Player

is_dashing tells us if the player is dashing or not

dash_speed will control how fast the dash is.

Add a Timer behaviour to the Player

This will control the duration of the dash

Add a New Sprite to use as the players' shadow.

Use the image to the right.

Add a new Group to the Player event sheet Call it Dash

CODE EXPLANATION

If the E key is pressed

Set is_dashing to true

Start the dash_duration timer

The timer runs for 0.4 seconds and only runs once (not continuously)


If the player is currently dashing

Multiply the current max speed by the dash speed

Increase the acceleration

Make sure the player cannot dash upwards

(Optional) Create a dash shadow trail which follows the player

When the dash_duration timer times out

Toggle is_dashing to false

allow movement up and down

return max speed to original value

return acceleration to original value