Set up Scoring

(Step 7/9) Set up a scoring system.

1. Go to the room.js file and put a setupCharacters function in the onInit function.



2. In the game.js file we need to put an addCharacters function in the init function.



3. In game.js, Add a getCharacters function in the create function.



4. Go into our room.js file in the onInit function and use a createACharacter function to create our team character.


g.createACharacter('team',  'team',  { x:  10000, y:  10000, name:  'Level', score:  1  });

5. In the room.js file in the onInit function in the third createALocation function that we wrote, we’ll tell the score to up, and the difficulty to increase.


let team = g.getACharacter('team',  'team')
team.score +=  1
g.getAllCharacters('enemy', enemy =>  { g.deleteACharacter('enemy',  })
for  (i =  0; i < team.score +  15; i++)  { g.createACharacter('enemy', g.nextCharacterId('enemy'),  { x: Math.floor((Math.random()  *  500)  +  1), y: Math.floor((Math.random()  *  1900)  +  1), right:  true  })  }

Download your zip, and upload it to, and you should be able to complete levels for score!

Set up Name Tags
Set up Co-op play

Need Help?

Proofread your code, check with your team and classmates, and if you’re still stuck!

Click Here for Help