6
w New Mexico State University Department of Computer Science Box 3000`, MSC CS Cruces, NM 88003 (575)646-4451 / F: (575)646-7024 Creating an Object Avoidance Game in Scratch 1. Log in to Scratch and start a new project. a. 2. Today we’ll be making a game where you control an object with a mouse and try to avoid the projectiles coming down from the sky! The goal of the game is to last as long as possible, and there will be a score that updates every 0.1 seconds to keep track of how long you’ve been playing! 3. Choose a background! I am choosing the “Playing Field” backdrop, but you can pick any one you want! a. 4. Choose a sprite to be the object that you’ll use to avoid the obstacles! This is the object that you’ll control with your mouse.

C r e a ti n g a n O b j e c t A v o i d a n c e G a me i ...cahe.nmsu.edu/4h/techanddesign/documents/avoid... · a . b . I n t h i s e xa mp l e , I ’ m ch o o si n g a b ro o

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

Page 1: C r e a ti n g a n O b j e c t A v o i d a n c e G a me i ...cahe.nmsu.edu/4h/techanddesign/documents/avoid... · a . b . I n t h i s e xa mp l e , I ’ m ch o o si n g a b ro o

w New Mexico State University Department of Computer Science Box 3000`, MSC CS Cruces, NM 88003 (575)646-4451 / F: (575)646-7024

Creating an Object Avoidance Game in Scratch

1. Log in to Scratch and start a new project.

a.

2. Today we’ll be making a game where you control an object with a mouse and try to avoid the projectiles coming down from the sky! The goal of the game is to last as long as possible, and there will be a score that updates every 0.1 seconds to keep track of how long you’ve been playing!

3. Choose a background! I am choosing the “Playing Field” backdrop, but you can pick any one you want!

a.

4. Choose a sprite to be the object that you’ll use to avoid the obstacles! This is the object that you’ll control with your mouse.

Page 2: C r e a ti n g a n O b j e c t A v o i d a n c e G a me i ...cahe.nmsu.edu/4h/techanddesign/documents/avoid... · a . b . I n t h i s e xa mp l e , I ’ m ch o o si n g a b ro o

a.

b. In this example, I’m choosing a broom to make a “Quidditch” game from Harry

Potter, but again you can choose whatever you want!

5. Add the code to make the broom move with your mouse! a. Make sure the sprite that you just created is selected and highlighted in blue, and

enter the following code.

b.

c. When you press the green flag, your object should be following your mouse!

6. Add a Score a. Go to the variable section and press the “Make a Variable” button.

b. Create a “Score” variable and press enter.

Page 3: C r e a ti n g a n O b j e c t A v o i d a n c e G a me i ...cahe.nmsu.edu/4h/techanddesign/documents/avoid... · a . b . I n t h i s e xa mp l e , I ’ m ch o o si n g a b ro o

c.

d. Make sure the “Broom” object is still selected and add the following code.

e.

7. Choose a sprite to be an obstacle. I chose the “Ball” sprite, but again you can choose any sprite you want.

Page 4: C r e a ti n g a n O b j e c t A v o i d a n c e G a me i ...cahe.nmsu.edu/4h/techanddesign/documents/avoid... · a . b . I n t h i s e xa mp l e , I ’ m ch o o si n g a b ro o

a.

8. Add the code to make random objects fall from the top of the screen at random angles. This code is slightly more complex than anything we’ve done, so be sure to read carefully and ask questions!

a. Make sure the ball sprite is selected and highlighted in blue before doing the

following code.

Page 5: C r e a ti n g a n O b j e c t A v o i d a n c e G a me i ...cahe.nmsu.edu/4h/techanddesign/documents/avoid... · a . b . I n t h i s e xa mp l e , I ’ m ch o o si n g a b ro o

b.

Page 6: C r e a ti n g a n O b j e c t A v o i d a n c e G a me i ...cahe.nmsu.edu/4h/techanddesign/documents/avoid... · a . b . I n t h i s e xa mp l e , I ’ m ch o o si n g a b ro o

c.