Use Scratch 3.0 to Make Scrolling Platformer Game – Part 4, Convert to Static Platformer Game

In my previous posts, I explained some key issues when developing a scrolling platformer game by following YouTube tutorial video clips. So how about designing a static platformer game? Static and scrolling platformer game have different characteristics, however, if you have developed a scrolling platformer game, it is pretty easy to convert the code of Player to be used in static platformer game, with just minor adjustment.

Please note the code adjustment occurring in this post is all based on a demo scrolling platformer game. If you would like to start from that project, you could access it via this address: https://scratch.mit.edu/projects/487534917/

Let’s begin our code conversion right now.

Simple Solution

If you would like to make the minimum adjustment to ensure the code run properly on static platformer game, the following steps are enough.

1. “game on” Block

As you know, the difference between scrolling and static platformer game lies on scrolling. In static platformer game, “scroll X” and “scroll Y” variables are not needed, so we could just remove the setting of the two variables in “game on” block.

2. “position” Block

In “position” block, since “scroll X” and “scroll Y” variables are removed, the code segment just makes Player move to the position specified by “x” and “y” variables. After adjustment, this block “position” looks a bit redundancy, but in simple solution, we will just keep as it is.

3. “tick” Block

“tick” block is responsible for adjusting the movement and position of Player sprite. Most of the code within this segment does not need to change because most of the code is handling the change of “sx” and “sy” variables, which are still needed in static platformer game. At the end of the code segment, those code blocks setting “scroll X” and “scroll Y” could be removed completely.

Note: since “tick” block is long, only part of the code needing change is shown below as comparison.

4. “when I receive play game” Block

In this block of “when I receive play game”, almost all the code keeps intact. The only place of change is to remove “broadcast tick and wait” block. For static platformer game, Player sprite does not need to inform other sprites to update their positions.

If you have done the above steps, congratulations! the Player sprite could move as flexibly as it does in scrolling platformer game. However, if you would like to remove more redundancy code, the following section provides useful tips.

Further Adjustment

“position” Block

As I mentioned above, this “position” block is just to wrap one programming block “go to x: y:”. In static platformer game, we could remove this block “position”.

“game on” Block

Besides removing the above “position” block, the two variables “x” and “y” could also be removed from the project.

“change player x by sx” Block

In scrolling platformer game, we call “change x by sx” or “change y by sy” blocks to adjust the map position of Player sprite. In static platformer game, without needing to consider scroll X and scroll Y, we could use “go to x: y:” blocks in Motion tab to adjust Player’s position directly. The code comparison is shown below.

The left side is the scrolling platformer game. It uses “change x by sx” and “change y by sy” to change variable “x” and “y”, and after that, it uses “position” block to reflect “x” and “y” values in Player’s position. The right side is the static platformer game. The program calls block “change x by sx” or “change y by sy” in Motion tab to update Player position directly.

“change player y by sy” Block

“change player y by sy” block will do the same adjustment as that in the above “change player x by sx” block.

“climb the ladder” Block

If your Player sprite gets other features, such as climbing the ladder or dangling on the rope, just do not forget to check the code and do the same change for “x”, “y”, “scroll X” and “scroll Y”.

“dangle on the rope” Block

Same as the “climb the ladder” block, “dangle on the rope” block removes setting variable “x” and “scroll X”, and calls “change x by -2” from Motion tab.

That is all for the code adjustment of Player sprite for static platformer game. You still need to create and design other sprites such as platformer, danger, obstacle, coins sprites, etc. Nevertheless, the above judgement could reduce your workload on static platformer game dramatically. I hope this post is helpful to you and do not forget to enjoy the coding and have fun!

Note: All the analysis articles are copyright products of http://www.thecodingfun.com. Anyone re-posting them should credit author and original source. Anyone using them for commercial purposes or translating them into other languages should notify TheCodingFun and get confirmation first. All Rights Reserved.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.