![]() |
This article or section may not have content matching Scratch Wiki editing standards. Please improve it according to Scratch Wiki:Guidelines and Scratch Wiki:Editing Conventions. (Date?) |
Making the platformer sprite
To start off, make the platformer sprite, the sprite that you control and play as in the game. You could try making a black dot or something like some platformers do. You could try to do a person walk cycle for the platformer, but that may be harder. Along with that, make two variables called "XVel" and "Gravity" and set them to "for this sprite only", and add the following script to the sprite:
when gf clicked set [Gravity v] to [insert strength of gravity here] forever if <key [left arrow v] pressed?> set [XVel v] to [-4] end if <key [right arrow v] pressed?> set [XVel v] to [4] end if <<not <key [left arrow v] pressed?>> and <not <key [right arrow v] pressed?>>> set [XVel v] to [0] end if <not <touching [ground sprite v]>> change y by (Gravity) end change x by (XVel)
Making Levels
Simple
Colors would be involved at this part. Lets say that black is the main color the sprite stands on, red makes the sprite go back to the beginning of the level when it touches it, and touching yellow will bring the sprite to the next level.
However, yellow doesn't have to always be square, and red doesn't always have to be a basic line. They can be any kind of strange shape like yellow (Level goal) can be some line and red (Obstacle) could be something like a circle or square.
Levels can look like this! That's what makes platformers popular on Scratch.
When you're done making all your levels, add the following script to the Player sprite:
when gf clicked forever if <touching color [#FF0000]?> go to x:(-180) y:(-47) end if <touching color [#FFFF00]?> broadcast [New level v] go to x:(-180) y:(-47) end
And add the following scripts to the Levels sprite/background:
when gf clicked switch to costume [Level 1 v]
when I receive [New level v] next costume
Finally, add this script to the Player sprite:
when gf clicked forever if <([costume # v] of [Levels v]) = [insert number of levels here]> hide end
Advanced
When doing platformers, variables are usually present. These varaibles can range from Lives Left to Deaths or Seconds Survived to Coins Collected. The basic name used in simple platformers for variables is Score. To incorporate variables into your platformer, you can use the following script:
when gf clicked forever if <touching color [#FF0000]?> go to x:(-180) y:(-47) change [Deaths v] by (1) end if <touching color [#FFFF00]?> broadcast [New level v] go to x:(-180) y:(-47) end
And for the broadcast received:
when gf clicked switch to costume [Level 1 v] set [Level v] to [1] when I receive [New level v] next costume change [Level v] by (1)
or if you want to incorporate Lives
when gf clicked forever if <touching color [#FF0000]?> go to x:(-180) y:(-47) change [Lives v] by (-1) end if <touching color [#FFFF00]?> broadcast [New level v] go to x:(-180) y:(-47) end
Making The Win Background
Last of all, comes the win background. After finishing all the levels in the platformer, something would come up that says something like "You Win!". Put it as the last costume in the sprite/background. It can be some text in a basic white background saying "You win" or the art can be complex.
- Simple You Win.gif
A basic You Win background with just some black text and a white background.