Sie sind auf Seite 1von 6

Fiore

Edu696D

Scratch Programming Scrolling Game


Do Now:
Visit the following web page and read:
http://wiki.scratch.mit.edu/wiki/Scroller
The Goal(s)
By the end of this lesson students will make a scrolling video game
make use of variables to:
keep track of score/health
control the movement on the x-axis,
Students will also make use of clones.
Objective(s)
The students will be able to:
identify that the Scratch environment is two-dimensional
manipulate a sprite on either the x or y axis
generate graphics from sprite sheets online select, crop, etc
http://www.retrogamezone.co.uk/images/sprites/nes/smbsheet1.gif
use the correct mathematic formula to keep a sprite scrolling along the xaxis
create variables for score and more blocks and to control the movement
on the x-axis
initialize blocks to control the placement of sprites to add a random
element (it really is not random)
This tutorial is not an easy or intermediate level tutorial. If a student is not
familiar with:
manipulation of sprites
X,Y coordinates
variables, more blocks
broadcasting
cloning
if &OR if/else control blocks
Student(s) may want to visit those concepts in the intermediate series of these
tutorials.
Assessment and Evaluation:
Formative assessment:
Students will give and get feedback to/from peers and teacher
throughout each assignment
Teacher will give feedback about skills student should work on through
observation
1

Fiore

Edu696D
Summative assessment:
Students will create a final scratch project to showcase what they have
learned
Teacher will use a rubric to assess the final project

Recall the XY-Grid in Scratch.


Why is this important to review before creating a scrolling-game in
Scratch?

How do you create a scrolling game in Scratch?


The idea here is to have a sprite move across the x-axis, extending the physical
space of the x-axis (480 pixels) at a predetermined location within the stage area.
Unlike platform games, where the background/backdrop is fixed in the
background for the game, a scrolling game must extend the x-axis across an
unlimited length of space across the stage while having no gaps between
sprites.
Think of these scrolling sprites as a treadmill. When one portion of the tread is
visible, there is another portion on the under part of the mill, thus circling over
and over again providing an unlimited amount of tread in a fixed place appear to
extend outward to infinite.

Fiore

Edu696D

This is a method for infinite scrolling. So, in the example I provide as a video, the
two sprites labeled mario-background1 and mario-background2 just keep
repeating themselves infinitely along with the movement of the sprite until the
game ends.
The stage area for Scratch is 480 pixels wide by 360 pixels tall. So for the x-axis,
the maximum visible width of pixels is 480. The mario-background sprite is 480
pixels wide.

For the mario-background1 sprite, you are going to create a variable called
scrollX for all sprites. This will allow you to use the same variable for all sprites
and you will need this variable for the not only mario-background2 but also a
few others, too. So after creating the variable scrollX means to scroll on the xaxis, and in the code blocks as follows.

forever set x to -1 * scrollX mod 480


Setting scrollX to 0 prevents the sprite from displaying somewhere unexpected or
overlapping another sprite.
So, this code for the mario-background1 sprite, the following code blocks help
regenerate the sprite(s)
Then, have a second sprite with another script which is

Fiore

Edu696D

Forever set x to -1 * scrollX mod 480 - 480


Have your main character move within the scrolling environment as well as
change costumes and pointing in the direction so that the sprite is animated.
Mainly, the illusion of having the sprite move along with the scrolling sprite
backgrounds can add an intense sense of movement, so you will need to take
advantage of

Fiore

Edu696D

Fiore

Edu696D

This code set makes the background appear to move as the sprite is moving
taking advantage of the scrollX variable and moving along the x-axis.

Add visuals accordingly (see clouds and enemies)


One thing to focus on in the next lesson, how to spawn objects to collect as well
as pitfalls and or enemies

Sources:
http://wiki.scratch.mit.edu/wiki/Scrolling_(sprites)
http://wiki.scratch.mit.edu/wiki/Scrolling_Platformer_Tutorial
http://wiki.scratch.mit.edu/wiki/Scroller