Closed LindZCoding closed 3 years ago
When the player collects a "star", how to make a point counter
//detection if player touches any part of the stars const detectStarHit = () => { for (i=0; i < stars.length; i++) if ( player.x < stars[i].x + stars[i].width && player.x + player.width > stars[i].x && player.y < stars[i].y + stars[i].height && player.y + player.height > stars[i].y ) { player.alive = true document.querySelector("#btm-left > h2").innerText = "stars" } }
Need some sort of code for a counter...
What things have you already tried? Do you have any ideas?
You will need to have Score variable set to zero and add points for each detect hit.
Awesome job! Score counter on it's way!
What's the problem you're trying to solve?
When the player collects a "star", how to make a point counter
Post any code you think might be relevant (one fenced block per file)
If you see an error message, post it here. If you don't, what unexpected behavior are you seeing?
What is your best guess as to the source of the problem?
Need some sort of code for a counter...
What things have you already tried to solve the problem?