Home Power Hero

Moving House

There are a few different ways to show walking in a game. One is to have the sprite move around the scene; another is to have the scene move around the sprite. This second option is called “parallax scrolling” and is what we’re going to use in this game.

  • Open the starter project at bit.ly/powerhero
  • First, we need to set up the Background so that it moves while Avery stays still, simulating motion.
  • Add this code to your House Sprite.
  • Next, we’ll add code in this forever loop that will move the House Sprite.
  • The variable ‘scrollx’ keeps track of how far Avery moves in the x axis (left to right).
  • By moving the background in the opposite direction to Avery’s movement, it will make it look like she is moving relative to the background.
  • Every time we play the game, we need to reset our scrollx variable so that the House Sprite goes back to the start.
  • Add this code.
  • (It won’t do anything yet, don’t worry!)