- ep.1 Player Controls
- ep.2 Bone Attacks ( Here Now )
- ep.3 Gaster Blaster
- ep.4 Another Bone Attack
Alright, let’s keep building the Undertale Sans battle! So far, we’ve set up two types of player movement: the red Soul that moves without gravity and the blue Soul with gravity. Now, it’s time to add Sans’s iconic bone attack! Let’s create an exciting gameplay experience where you’ll dodge those incoming bones like a pro. Let’s do this!
Sprite 'Admin'
In an Undertale battle, different attacks are timed to run in sequence, so let’s code a system to manage those attack timings.
Open 'Admin' sprite.
Place the green flag block and wait for 1 second.
Message 'Attack 1'
Create a new message named 'Attack 1' and place its broadcast block.
Sprite 'Attack 1'
First of all, let's hide when the green flag is clicked.
When I receive 'Attack 1', set 'GRAVITY' to 1.
And set 'SPEED Y' to -10.
Wati for 0.3 seconds.
Set 'GRAVITY' to 0.
Then wait for 1 second.
Block Definition '_Attack'
Create a new block definition named '_Attack' that runs without screen refresh.
To make it clear at a glance that this is a no-redraw block definition, we’ll add an underscore at the beginning of its name.
Place this block right below.
Variable 'bones'
Create a new variable named 'bones' for this sprite only.
Set this variable to 0.
Place the repeat block.
Create clone of myself inside.
Change 'bones' by 1.
Clone
Let’s code the clones for the bones.
Set X to 0 and Y to -300.
Create the expression for the x position.
This calculation positions the bones in a row, spacing them out evenly.
Insert this expression into the x value.
Go to back layer and show.
Place the repeat block.
Wait for 1 second.
Place the repeat block again and change y by -10 inside.
Finally, delete this clone.
Preview
Woohoo! The bones are perfectly lined up—it’s so satisfying!
Sprite 'Admin'
Next, let’s implement an attack where the bones scroll in a wave from the side. It’s a bit more complex than the horizontal alignment, so let’s carefully build it together!
Open 'Admin'.
Place the wait block right after the "Attack 1" event block.
Message 'Attack 2'
Place this block right below.
Sprite 'Attack 2'
Open 'Attack 2' sprite.
When the green flag is clicked, hide.
Block Definition '_Attack'
Create a new block definition named '_Attack' that runs without screen refresh.
When I receive 'Attack 2', then use '_Attack' block.
Variables 'bone X', 'bone Y', and 'bones'
Create 3 variables all for this sprite only.
Set these variables as shown below.
Place the repeat block.
Create clone of myself.
Change 'bones' by 1.
Change 'bone X' by -25.
Place the set block for 'bone Y'.
It’s a bit of a complex calculation, but use the screenshot below as a reference to create it.
The screenshot below shows the final result.
Insert this expression into the 'bone Y' value.
Clone
Let's code the clones of the bones.
Place the forever block.
Move
Set X to 'bone X' and Y to 'bone Y'.
Go to back layer and show.
Change 'bone X' by 12.
Delete
Place the 'if' block and insert the expression 'bone X > 240' into the condition.
Then delete this clone.
Preview
Waving! Fantastic! The relentless bone attack is now striking the player! We’ve built an amazing foundation for an epic battle!
- ep.1 Player Controls
- ep.2 Bone Attacks ( Here Now )
- ep.3 Gaster Blaster
- ep.4 Another Bone Attack