Phaser Activity
Modify the code & complete the game using the snippets below!

Code Snippets

1. Add Jumping

In order to collect the coins, our character will need to jump!
  • Put this snippet into the update() function
  • Things to try
    - Edit the jump velocity
    - Change the jump key
    - Modify the bounciness of the character

    2. Camera Follow

    Jumping is a lot of fun, but we need to see where we are going. The camera needs to follow us!
  • Put this snippet at the bottom of the create() function
  • Adding this tells the camera to follow the object we gave in the parameters (inside the brackets)
    2.1 Smooth that camera!
    Its awesome the camera follows us... but it looks a little rough. Maybe smoothing it will help?
  • Put this snippet under the last one
  • Things to try
    - Change the values in the paremeters
    Lerp is a term you'll become very familliar with in Game Dev. Also known as linear interpolation, it smooths out the change from one value to another

    3. Coin collisons

    We can now jump and follow our character, but our coins don't do anything!
  • Put this snippet into the create() function
  • This code adds collision detection between the character and all the coins in the coin group. Once detected, it calls the "CollectCoin" function.

    4. More Coins!

    Inside the code are three lines that add three coins, see if you can find them and add more! The game will change the win criteria based on the number of coins.

    5. Play around

    One of the best ways to learn coding is to play and modify existing code. Try changing values and see what happens! You can always refresh the page to start again.