Week 1 Day 5: Lab - Continue on the Side-Scrolling Platform Game

Tasks:

  • Apply gravity and make the hero land on the platform
  • Make the hero jump upon a key press
  • Handle item collection
  • Recycle the coin and the "?" box
  • Endless scrolling

How Today's Completed File Works:

LEFT or RIGHT arrow to scroll the platform. Spacebar to jump. The coin disappears when the hero touches it. A spinning coin will pop up when the hero touches the "?" box.

There are some pecularities:

  • When you keep pressing the key to make the hero jump, it will keep going up even it is already in the air.
  • If you press the spacebar to jump while you are pressing LEFT or RIGHT arrow key to scroll, it will stop scrolling.

These pecularities are normal because our platform game did not include code to handle these.

 


Extra Effort:

Extra #1: When you press the spacebar to make the hero jump, it won't jump any higher if it is already in the air.

 

 

Extra #2: When the hero jumps up while it is inside an object, say the boulder, it won't be trapped but jump all the way beyond the boulder.
Hint: It does not even need a statement. This should require no more than adding 20 characters of code. To find a simple solution, you need to analyze the situation.

 

Extra #3: Animated hero.

 

Extra #4: The hero can go up and down with the uneven terrain.

Additional ideas of new features to add to your platform game:

The TA and I have come up with more than 10 possible challenges for this lab. If you finish the basic lab early, pick and choose these features to implement. You are welcome to come up with your own ideas of extra features to implement. Below is a list of the challenges/features that the TA and I have come up.

  1. Create an extra character, say a villain. It hurts the hero when the hero is in contact with it. The hero can destroy the villain by shooting, jumping on its head, dropping bombs, ... etc.
  2. Create an extra character or item that will move on its own, for example, a moving vehicle, a flying bird, a walking villain, a walking zombie, ..., etc. It may interact with the hero in some way.
  3. Prevent the hero from jumping any further upon key presses when it is already in the air. (See Extra #2 above for a demo of how it works)
  4. When the hero jumps up while it is inside an object, say the boulder, it won't be trapped but jump all the way beyond the boulder.
    Hint: It does not even need a statement. This should require no more than adding 20 characters of code. To find a simple solution, you need to analyze the situation. (See Extra #1 above for a demo of how it works)
  5. Keep and display scores, lives, number of coins collected, and number of "?" boxes popped.
  6. Make the pop-up coin collectible.
  7. Prevent the recycled coin and box from overlapping with any part of the platform.
  8. Create an extra background that scrolls but without collision detection with the hero.
  9. Make such non-interacting background scroll slower (to create an illusion of depth; the slower moving background being far away).
  10. Upon a key press or collecting an item, alter the game physics, for example:
    • lower the gravity so the hero can jump higher
    • the platforms can be scrolled faster (to make an illusion that the hero can go faster)
  11. Add a retardant, for example, an oil spill or a puddle of water/mud, that will slow down the scrolling or skid forward uncontrollably.
  12. Add extra platform design and randomize the platform design every time it wraps (i.e. recycle on the other side during endless scrolling). Hint: Think about the hairstyle customization lab.
  13. Add a second player that allow another human player to play against the existing hero player.
  14. Animated hero (See Extra #3 above for a demo of how it works).
  15. Allow the hero to change appearance (say having an armor, shield, totally different character) upon a key press, collection of an item, or touching a poisonous object. Different appearances of the hero have different abilities or characteristics, for example, different speed, different strength in jumping up, immunity to different villains, getting different scores with the spinning coin, ..., etc.
  16. The hero can go up and down with the uneven terrain (See Extra #4 above for a demo of how it works)