Lab 05 Program a Side-scrolling Platform Game

Objectives:

  • From the Pre-lab, you should already have this: (see how the pre-lab is supposed to work)
    • code to handle mouse down event, so that the character flies up upon mouse down
    • code to handle key down event, so that pressing LEFT or RIGHT arrow keys moves the platforms, the spinning coin, and the "?" box
    • code to handle frame event, so that some statements will be executed constantly at frame rate
  • Moving onto Part 1: (see how the Part 1 is supposed to work)
    • Write code to model gravity effect on the character
    • Write code for collision detection between the hero and the platform using hitTestPoint()
    • Write code to do continuous scrolling of the platforms
  • Moving onto Part 2:
    • Use of a Boolean variable to keep track of a status
    • Write code for collision detection between the hero and the items (spinning coin and "?" box) using hitTestObject()
    • Write code to recycle the items (spinning coin and "?" box)
    • Organize code using functions
    • Use of functions that take parameters

 

How the Completed File Works:

Mouse down to make the character jump up. LEFT and RIGHT arrow keys to move the platforms, the spinning coin, and the "?" box. The coin disappears when the character touches it. A spinning coin pops up when the character touches the "?" box. The platforms can be continuously scrolled. The spinning coin and "?" box reappear at random horizontal location after they are collected or scrolled off the stage for a certain distance.

Students, Don't forget to do the last step of the lab, which is to organize the code using functions. These are not something different you can see on screen (the game plays the same with or without organizing the code using functions) but points will be taken off if you miss that part of the lab.