m (Creating the platformer sprite: Updated a link.)
(Trying to fix up.)
Line 24: Line 24:
  
 
==Making Levels==
 
==Making Levels==
===Simple===
+
Colors can be used in a platform for detection of the end of a level or an object which sends one back to the beginning of the level. For this tutorial, assume the following:
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.
+
*the character sprite performing the physics is named "Player"
 +
*black is the color of the platform, or ground and walls, in which the character cannot pass through
 +
*red is the color that sends one back to the beginning of the level he or she is on
 +
*yellow is the color which must be reached to move on to the next level
 +
*backgrounds are used as levels instead of sprites
 +
*[[Scrolling|scrolling]] is not incorporated
  
 
[[File:Level.gif]]
 
[[File:Level.gif]]
  
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.
+
The shapes do not need to be geometric, but can be organic, meaning an unordinary, inconsistent structure. There can be curvature to the various colors and platforms, which can be used to create diverse, numerous levels. The following image displays an example of some organic shapes being used:
  
 
[[File:Alt Level.gif]]
 
[[File:Alt Level.gif]]
  
Levels can look like this! That's what makes platformers popular on [[Scratch]].
+
When you finish designing the levels as [[Backdrops|backdrops]] in the [[Stage]], add the following script to the "Player" sprite:
 
 
 
 
 
 
When you're done making all your levels, add the following script to the Player sprite:
 
<scratchblocks>
 
when gf clicked
 
forever
 
  if <touching color [#FF0000]?> then
 
    go to x:(-180) y:(-47)
 
  end
 
  if <touching color [#FFFF00]?> then
 
    broadcast [New level v]
 
    go to x:(-180) y:(-47)
 
  end
 
</scratchblocks>
 
 
 
And add the following scripts to the Levels sprite/background:
 
<scratchblocks>
 
when gf clicked
 
switch to costume [Level 1 v]
 
</scratchblocks>
 
<scratchblocks>
 
when I receive [New level v]
 
next costume
 
</scratchblocks>
 
 
 
Finally, add this script to the Player sprite:
 
<scratchblocks>
 
when gf clicked
 
forever
 
  if <([costume # v] of [Levels v]) = [insert number of levels here]> then
 
    hide
 
  end
 
</scratchblocks>
 
 
 
===Advanced===
 
When playing platformers, variables can often be present. These varaibles can range from "Lives Left" to "Fails", or "Seconds Survived" to "Coins Collected". The basic name commonly used in simple platformers for a variable is "Score". To incorporate variables into your platformer, you can use the following script:
 
 
<scratchblocks>
 
<scratchblocks>
 
when gf clicked
 
when gf clicked
 
forever
 
forever
  if <touching color [#FF0000]?> then
+
if <touching color [#FF0000]?> then //if in contact with the color red
    go to x:(-180) y:(-47)
+
go to x:(-180) y:(-47) //relocate to the start
    change [Deaths v] by (1)
+
end
  end
+
if <touching color [#FFFF00]?> then //if at the end of a level
  if <touching color [#FFFF00]?> then
+
go to x:(-180) y:(-47) //relocate to the start
    broadcast [New level v]
+
switch backdrop to [next backdrop v] //next level
    go to x:(-180) y:(-47)
+
end
  end
 
 
</scratchblocks>
 
</scratchblocks>
  
And for the broadcast received:
+
Then add the following script to any sprite:
 
<scratchblocks>
 
<scratchblocks>
 
when gf clicked
 
when gf clicked
switch to costume [Level 1 v]
+
switch backdrop to [Level 1 v] //begin with the first level
set [Level v] to [1]
 
 
 
when I receive [New level v]
 
next costume
 
change [Level v] by (1)
 
 
</scratchblocks>
 
</scratchblocks>
 
+
Lastly, add the following script to the "Player" sprite:
or if you want to incorporate Lives
 
 
 
 
<scratchblocks>
 
<scratchblocks>
 
when gf clicked
 
when gf clicked
forever
+
show
  if <touching color [#FF0000]?> then
+
wait until <([backdrop # v] of [Stage v]) = (amount of backdrops)> //wait until the last level is reached
    go to x:(-180) y:(-47)
+
end
    change [Lives v] by (-1)
 
  end
 
  if <touching color [#FFFF00]?> then
 
    broadcast [New level v]
 
    go to x:(-180) y:(-47)
 
  end
 
 
</scratchblocks>
 
</scratchblocks>
 
for the [[sprite]]'s [[script]].
 
  
 
==Making The Win Background==
 
==Making The Win Background==

Revision as of 16:15, 7 October 2013

Warning.png This article or section is currently undergoing major changes by Turkey3 (talk | contribs). Please avoid largely modifying this page's contents until this template has been removed. (Date?)

A platformer is a simulation of actual physics that take place in real life. Objects fall, move, slide, jump, and bounce, and a platformer associates those properties into a game in which one controls a character to typically move toward some form of a goal.

Creating the platformer sprite

To start off, it helps to create the platformer sprite: the sprite that one controls and plays as in the game. The appearance of the sprite can affect the gameplay slightly, depending on the angles and size of it. Implementing an animating sprite which switches among costumes of different dimensions can prove difficulties within the project. After designing the artwork for the sprite, create two new variables called "x velocity" and "gravity"; select the option "for this sprite only" in the creation menu. That setting makes the variable only changeable by the sprite it is created within, and is used often in a physics situation because they represent personal properties of an individual sprite. Once the variables are created, 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?> then
    set [XVel v] to [-4]
  end
  if <key [right arrow v] pressed?> then
    set [XVel v] to [4]
  end
  if <<not <key [left arrow v] pressed?>> and <not <key [right arrow v] pressed?>>> then
    set [XVel v] to [0]
  end
  if <not <touching [ground sprite v]>> then
    change y by (Gravity)
  end
  change x by (XVel)

Making Levels

Colors can be used in a platform for detection of the end of a level or an object which sends one back to the beginning of the level. For this tutorial, assume the following:

  • the character sprite performing the physics is named "Player"
  • black is the color of the platform, or ground and walls, in which the character cannot pass through
  • red is the color that sends one back to the beginning of the level he or she is on
  • yellow is the color which must be reached to move on to the next level
  • backgrounds are used as levels instead of sprites
  • scrolling is not incorporated

File:Level.gif

The shapes do not need to be geometric, but can be organic, meaning an unordinary, inconsistent structure. There can be curvature to the various colors and platforms, which can be used to create diverse, numerous levels. The following image displays an example of some organic shapes being used:

File:Alt Level.gif

When you finish designing the levels as backdrops in the Stage, add the following script to the "Player" sprite:

when gf clicked
forever
if <touching color [#FF0000]?> then //if in contact with the color red
go to x:(-180) y:(-47) //relocate to the start
end
if <touching color [#FFFF00]?> then //if at the end of a level
go to x:(-180) y:(-47) //relocate to the start
switch backdrop to [next backdrop v] //next level
end

Then add the following script to any sprite:

when gf clicked
switch backdrop to [Level 1 v] //begin with the first level

Lastly, add the following script to the "Player" sprite:

when gf clicked
show
wait until <([backdrop # v] of [Stage v]) = (amount of backdrops)> //wait until the last level is reached
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.

External Links

Tutorial