How to make Fortnite in Scratch ep.3

How to make Fortnite in Scratch ep.3
ok-scratch
Let's build stairs and walls so you can freely roam and navigate the field to your heart's content!
Starter
Projects
Starter Project
Sample
none
Difficulty
Tags

Make sure to jot down the URL of your Scratch project in progress. It’s a lifesaver when you’re ready to dive back in.

LOADING...

This record is saved on the computer you’re currently using. So, if you switch to a different computer, you won’t see it there.

Now that we've got stage scrolling set up, players can freely move around in the game, which really lays the groundwork for some fun game development. This time, we're tackling one of the most enjoyable aspects of Fortnite—building! We plan to implement the ability to construct stairs and walls. These structures will not only be climbable by players but will also serve as protection from enemy attacks we'll introduce later on. Let's dive into building!

Today's Goal

ok-scratch ok-scratch

Woohoo! Let’s get pumped and aim to implement stairs that let us take a walk in the air! Dive into making this fun feature happen!

Sprite 'Stairs'

Let's code a mechanism so that when you press the 'S' key, stairs appear. Let's get to programming this cool feature!

Open the 'Stairs' sprite.

When the green flag is clicked, hide the sprite and set up a loop.

Check if the 'S' key is pressed.

Then, wait until the user releases the 'S' key. This prevents multiple stairs from appearing continuously.

Create a clone of itself.

Clone

Switch to coding the clone.

Set the X to the Hitbox's x position plus 60, and set the Y to the same value as Hitbox's y position.

Just like below.

Switch costume and show.

Preview

ok-scratch ok-scratch

Good, now stairs appear every time the 'S' key is pressed. However, it's unnatural that these stairs don't move with the background scroll. Let's adjust that too.

Block Definition 'Scroll'

Place an forever loop right below.

Create a new block definition named 'Scroll'.

Place this block inside.

In this definition, first check if the right arrow key is pressed.

Additionally, add another 'if' block.

In this 'if' block, check if the x position of the Hitbox is -50.

ok-scratch ok-scratch

Remember, -50 is the x position where the player gets fixed.

Change x by -5.

Preview

ok-scratch ok-scratch

Great, now the stairs scroll naturally too! Ah, but wait—looks like they're getting stuck at the edge of the screen. We should also implement a way to make them disappear when they move off-screen. Let's tackle that next!

Block Definition 'Off Screen'

Create a new block definition named 'Off Screen'.

Place this block inside of the forever loop.

In this definition, check if x position is less than -240, which means out of the view.

Then, delete this clone.

Preview

ok-scratch ok-scratch

Cool! Now the stairs are gone away!

Since we want to implement almost the same functionality for the Wall sprite, let's duplicate all the blocks by dragging and dropping them!

Sprite 'Wall'

Open the 'Wall' sprite.

Adjust so that walls appear when the 'W' key is pressed, instead of the 'S' key.

For the stairs, we placed them 60 coordinates away, but let's set the walls to appear 90 coordinates away instead.

Also, let's make a slight adjustment to the off-screen detection.

Preview

ok-scratch ok-scratch

Yay! We've successfully made the walls appear and ensured they disappear off-screen properly. Easy peasy!

Hold on a second. We can place stairs and walls in mid-air, too.

That's not quite right. Let's make sure to add a mechanism for them to fall down properly.

Block Definition 'Fall'

Create a new block definition named 'Fall'.

Add this block to the forever loop.

In this definition, place 'if' block as shown below.

Check if the sprite does not touch the ground, specifically if it does not touch pure black.

Inside this if block, create a loop that repeats until the sprite touches the black color.

Repeat changing y by -10 until the sprite touches the ground.

Preview

ok-scratch ok-scratch

Okey-dokey! Now we've made it so you can't build in mid-air. This makes things look much more natural, right?

Drag and drop this 'Fall' definition into the 'Stairs' sprite and place it inside the forever loop as well.

Sprite 'Hitbox'

Alright, we've got walls and stairs set up nicely, but actually, we can't climb the stairs smoothly yet. While it's okay if we can't climb the walls, we definitely want to be able to climb the stairs. So, let's tweak the Hitbox a bit and add some coding to make climbing stairs possible.

Open the 'Hitbox' sprite.

Remove 'OR' conditional block from the 'if' block as shown below.

Then add another 'if' block right below.

Check if the sprite touches the 'Stairs' sprite.

If true, set 'SPEED Y' to 3, and 'JUMPING?' to 1.

Then move -10 steps, which means moving backwards a bit.

Preview

ok-scratch ok-scratch

Yes! Now we can smoothly climb the stairs. This gives players even more control over the game. Now we're ready to add elements beyond just the player. Next time, let's introduce some adversaries to challenge the player's progress. I can't wait to get coding!

Thank you for reading! Thank you for reading!
Bookmark and share this article, if you like.

Scratch Games

    • You can find popular scratch projects with reviews.