Bag Of Cows

Basic JS Game - Part 3

In this part, you need to add a player character

  1. Add a variable for the player (gPlayer) similar to the gMonster - make it move at PLAYER_SPEED and have a different colour to the monster
  2. Add code for the player to
    drawGame
    UpdateGame
    startTheGame
  3. Have it constrained to the canvas edges instead of bouncing off (there is a function in utilities.js for this)
  4. in the UpdateGame function, insert code so that if the player and monster collide the game ends (call endGame()) - there is a collision detection funciton in utilities.js

At this stage the project looks like this.

Part 4