SWL+Lesson+10+Game+Programming+Part+I

=Scratch Lesson 10: Game Programming Part 1 – Movement =

In lesson 7, we took a look at an existing sample game, The Pong Game, and we also had made changes to this game to make it more interesting. In lesson 10 through 14, I will cover what you need to learn to make a mini Super Mario game.  We will cover the following: Designing a Game (Lesson 10) Creating Game sprites (Lesson 11) Adding Game Rules to Game Sprite (Lesson 12) Changing Background when Mario Moves (Lesson 13) Managing Score and Levels (Lesson 14) After following these classes, you should feel very comfortable creating your own game. Let’s start! Here is a basic table that we need to fill in: Let’s expand each item to its own table: You may download the PDF form of above table HERE. Let’s fill in each table for this game: Action ||  ||< -Walk1 <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">-Walk2 <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">-Jump Up <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">-Jump Down ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">-Jump <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">-Die <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">-Enter <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">-Score <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">-Grow <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">-Shrink ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">-Walk <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">-Jump <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">-Die <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">-Grow <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">-Shrink || <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;"> ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">-Surprised <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">-Happy ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">-Happy tune ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">-Jump up and down for joy || <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;"> ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">-Regular <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">-Cracked ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">-Crushed ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">-Crushed || <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;"> ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">-Fly1 <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">-Fly2 ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">-Wing flap ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">-Fly || <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;"> ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">-Spin1 <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">-Spin2 <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">-Spin3 ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">-Bling-bling ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">-Spin || <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;"> ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">Walk1 <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">Walk2 ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">-None ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">-Walk || <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;"> ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">Brick <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;"> ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">If Mario hand hits Brick, then Brick would crack. || <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;"> ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">Coin <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;"> ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">If Mario touches Coin, Coin would disappear and Mario would score 1 point. || <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;"> ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">Crab <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;"> ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">If Mario touches Crab, he would die. || <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;"> ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">Coin <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;"> ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">When Brick cracks, Coin would show spinning above Brick || <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;"> ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">Stage <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;"> ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">When Mario hits the bottom of the stage, he would die. || <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;"> ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">Solid ground, several bricks (to be added from sprites), crabs as enemies || <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;"> ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">Holes in ground, several bricks, crabs as enemies || <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;"> ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">Fruit platter || <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;"> ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">Solid ground, several bricks, bats as enemies || <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;"> ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">Holes in ground, several bricks, bats as enemies || <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;"> ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">Princess || <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">Whew!! We are done for the design stage. This may seem a lot of work but it’s always a good idea to lay out the design in as much detail as possible for your masterpiece, whether it is an animation or a game. Once you take the time to design your game, the building part should be straight forward. <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">In Lesson 11, we will work together to create the sprites for our Mini Mario game.
 * < <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">Game Name ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">Mini Mario ||
 * < <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">Sprites ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">List of sprites: name, costumes, sounds, movements ||
 * < <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">Sprite Interaction ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">How sprites interact in this game ||
 * < <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">Backgrounds ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">The list of background doodles here ||
 * < <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">Scores and Levels ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">The score counter rule and level advancement rule here ||
 * < <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">GAME NAME ||<  ||
 * < <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">SPRITES ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">Name ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">Look ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">Sound ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">Movement ||
 * < <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">SPRITE INTERACTION ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">Sprite1 ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">Sprite2 ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">Interaction ||
 * < <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">BACKGROUNDS ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">Name ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">Look ||
 * < <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">SCORE AND LEVELS ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">How ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">How many points ||
 * < <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">LEVELS ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">Level ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">Requirement ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">Starting Background ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">Ending Background ||
 * < <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">GAME NAME ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">Mini Mario ||
 * < <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">SPRITES ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">Name ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">Look ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">Sound ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">Movement/
 * <  ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">Mario
 * <  ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">Fruit Platter[[image:https://lh3.googleusercontent.com/VoxQxAgM7Lolkkw9K15z_t3hTocDp6lF2vs-rcBIWbHwWJJAODbxmdVCrSskM71U7p6KJSSQF4NKKagGr0kbxa2pw0UagBalm5jkV_tB46y-MAF1Hnc width="98" height="71"]] ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">-Delicious ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">None ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">None ||
 * <  ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">Princess
 * <  ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">Brick
 * <  ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">Bat
 * <  ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">Coin
 * <  ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">Crab
 * < <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">SPRITE INTERACTION ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">Sprite1 ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">Sprite2 ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">Interaction ||
 * <  ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">Mario
 * <  ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">Mario
 * <  ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">Mario
 * <  ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">Brick
 * <  ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">Mario
 * < <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">BACKGROUNDS ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">Name ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">Description ||
 * <  ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">Level1_1
 * <  ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">Level1_2
 * <  ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">Level1_Passed
 * <  ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">Level2_1
 * <  ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">Level2_2
 * <  ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">Level2_Passed
 * < <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">LEVELS ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">Level ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">Requirement for this Level ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">Starting Background ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">Ending Background ||
 * <  ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">1 ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">When the game is started ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">Level1_1 ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">Level1_2 ||
 * <  ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">2 ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">When Mario grabs the Fruit Platter in Level 1 ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">Level2_1 ||< <span style="font-family: "Helvetica Neue",Helvetica,Helvetica,Arial,sans-serif; font-size: 14px;">Level2_2 ||