1 / 9

Module 11

Module 11. Jumping Game. Interaction with Objects. The interaction between objects is called Object Collision You have to tell the sprites how they will react if they are colliding with another object. You will have to use Newton's Laws

dallon
Télécharger la présentation

Module 11

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Module 11 Jumping Game

  2. Interaction with Objects • The interaction between objects is called Object Collision • You have to tell the sprites how they will react if they are colliding with another object. • You will have to use Newton's Laws • 1st Law: a sprite will not move until you tell it to move • 2nd Law: Jumping games need Gravity and objects/sprites colliding need Force • 3rdLaw: Every action an Object/Sprite does has an equal but opposite reaction. If an object hits another object the user needs to know it, by making a sound and/or changing the way the object looks, or change the movement

  3. Sprite Collisions • Sprites can detect each other two ways 1) Pixel by pixel detection: this is good for irregular shapes but is very slow. • We can use this by color detection • Or to see if a sprite is touching another sprite • Easy to set up 2) Rectangles Intersection: this is fast • This works really well with advanced gaming engines • It can be very complex • It is not good for games that need precise reactions with irregular shapes

  4. Stage and Sprite 2 • Upload this sprite image into your program • Fill in your Stage background with one solid color

  5. Draw Sprite 1 Costumes • Make sure sprite costumes take up 480X360 • Draw 7 Costumes or more for your levels. • Only pick one color for your Sprite 1 costumes Pick one color to be your goal This black is my Stage color Pick one or two colors for dangerous items

  6. Sprite 2: The Jumping Sprite Gravity Variable: this causes the sprite to move up by 7 pixels on the Y-Axis. We create a gravity effect by subtracting 0.25 from it until the sprite starts to fall downward. The collision is detected when red is touching green. This stops the falling. Right blue arm touching green: this stops the sprite from moving to the right Left orange arm touching green: this stops the sprite from moving to the left We touch this blue color it triggers the level change We touch this gray color it triggers a death of the sprite and resets it location to these coordinates

  7. Sprite 1: Levels The level variable controls the level switches. “level” increase by one every time it switches the costume for Sprite 1. But the level switch IF statements check for increments of two. That is because we also change level by 1 on Sprite 2 whenever it touches the goal color. This helps us control the level switching and placement of Sprite 2 You must draw your level sprite in only one color The Goal at the end of the stage must be one color and must stay the same

  8. Extensions • Figure out what code you can remove from the Sprite 1 • Set up your dangerous items to be three or more colors • Create two more stages • Program pick up items • Create a moving dangerous items • Create a moving platform • Allow the user to select a flying character or a jumping character

  9. Bibliography • NOTE: this project was based upon Hamstercake11’s RED project • http://scratch.mit.edu/projects/hamstercake11/2565479

More Related