I got it! Thanks to more help from Rowena in clearing things up.
To be able to ensure a player only gets a point if the falling sprite reaches the yellow bit at the bottom I had to separate each of the sprites into one for each x-coordinate (aka each note).
For example, all of the falling sprites for B (x = 114) were clones of the same sprite which I called “B”… I’m super creative like that!
You’ll notice that I’ve also deleted all of the “switch costume to ___” which used to look like:
I had this in the original coding because our model game on scratch included this however we only needed the same costume for that sprite every time it created a clone to fall from the top of the screen.
Side Note: I tell the program to create a “clone” of the sprite so that when it passes y-coordinate = -130 and deletes itself, the sprite still exists in order to appear for the next falling sprite for that note (rather than making an individual sprite for every falling sprite).
The original sprite is always hidden and stationary somewhere on the screen as it is told in:
Back to how I figured out the scoring…
Once I had created a falling sprites for each note, I was then able to tell it when and how to change the score:
Explaining from top to bottom:
- When the clone is created,
- Show clone (unlike the original which is always hidden on the screen),
- Set to the x-coordinate stated in the other section of the falling sprite code that you can see at the top of this post,
- Set y coordinate to 180
- Once the clone is created change y coordinate by -2 continuously,
- Meanwhile, if the clone touches any yellow on the screen at the same time as the “i” key is pressed on the computer keyboard (this is triggered when B on the large scale floor piano is touched –> see my earlier post “Remapping the Makey Makey” from November 17th),
- The score is increased by 1,
- Wait 0.5 seconds (this was added to the code because the computer was adding 60+ points for 1 correct note. It turns out that the computer was just so fast that it processed the one note being hit multiple times before it deleted itself at y=-130),
- Also, when the falling sprite clone falls below y coordinate -130,
- Delete clone.
The only difference in the white and black notes is the colour that it should be touching to get a point (black notes use green dots rather than yellow) and the y coordinate that it deletes itself at is y < -76 rather than y < -130.
For “Here Comes the Sun” players can get a maximum score of 48. As I mentioned in my last post, I have created different backgrounds to provide feedback in relation to the final score. Since that last post, I also added an extra background which says “Perfect!” which (as you guessed) pops up if someone gets a perfect score.
I also changed the amount of points required to get “You Rock!” as I feel 32/48 is still a pretty good score.