Mechanic 7 - Dash
Add two new instance variables to the Player
Add two new instance variables to the Player
is_dashing tells us if the player is dashing or not
is_dashing tells us if the player is dashing or not
dash_speed will control how fast the dash is.
dash_speed will control how fast the dash is.
Add a Timer behaviour to the Player
Add a Timer behaviour to the Player
This will control the duration of the dash
This will control the duration of the dash
Add a New Sprite to use as the players' shadow.
Add a New Sprite to use as the players' shadow.
Use the image to the right.
Use the image to the right.
Add a new Group to the Player event sheet Call it Dash
Add a new Group to the Player event sheet Call it Dash
CODE EXPLANATION
CODE EXPLANATION
If the E key is pressed
If the E key is pressed
Set is_dashing to true
Set is_dashing to true
Start the dash_duration timer
Start the dash_duration timer
The timer runs for 0.4 seconds and only runs once (not continuously)
The timer runs for 0.4 seconds and only runs once (not continuously)
If the player is currently dashing
If the player is currently dashing
Multiply the current max speed by the dash speed
Multiply the current max speed by the dash speed
Increase the acceleration
Increase the acceleration
Make sure the player cannot dash upwards
Make sure the player cannot dash upwards
(Optional) Create a dash shadow trail which follows the player
(Optional) Create a dash shadow trail which follows the player
When the dash_duration timer times out
When the dash_duration timer times out
Toggle is_dashing to false
Toggle is_dashing to false
allow movement up and down
allow movement up and down
return max speed to original value
return max speed to original value
return acceleration to original value
return acceleration to original value