WDI-SEA / game-project-issues

0 stars 0 forks source link

Linking stars collected to points #15

Closed LindZCoding closed 3 years ago

LindZCoding commented 3 years ago

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)

//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"
    }
}

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?

TaylorDarneille commented 3 years ago

What things have you already tried? Do you have any ideas?

DoireannJane commented 3 years ago

You will need to have Score variable set to zero and add points for each detect hit.

DoireannJane commented 3 years ago

Awesome job! Score counter on it's way!