Switch backdrop to (level 1 v)//begin with the first level Then add the following script to any sprite: In the example above, when the sprite checks if it's touching a color, it's checking a condition.
Merging the scripts reduces the amount of conditions being checked at once and can possibly make the project more uniform and orderly, meaning the "Player" makes each movement and then checks for the conditions instead of the conditions possibly being checked during the sprite's movement.Ī condition is a statement that is checked for a true/false response. The scripts within the "forever" loop can be merged with the larger physics script shown farther above. Switch backdrop to (next backdrop v)// next level Go to x:(-180) y:(-47) // relocate to the start If then//if in contact with the color red When the levels are finished, add the following script to the "Player" sprite: The following image displays an example of some organic shapes being used: There can be curvature to the various colors and platforms, which can be used to create diverse, numerous levels. The shapes do not need to be geometric, but can be organic, meaning an unordinary, inconsistent structure. Backgrounds are used as levels instead of sprites.Yellow is the color which must be reached to move on to the next level.Red is the color that sends one back to the beginning of the level they are on.Black is the color of the platform, or ground and walls, in which the character cannot pass through.The character sprite performing the physics is named "Player".If > then // sprite falls till touching groundĬolors 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. Set to // no arrow keys means no movement If then // using "else" saves processing later ifs unnecessary
"Gravity" need not be set as a local variable a realistic game would subject all its characters to the same gravitational force. In this example it is set as a negative number because moving a sprite downwards requires making the value of its Y position smaller.