Creating a score in a Scratch Game

I’ve been struggling quite a bit trying to perfect the coding for the score. So far, I have it resetting to zero whenever the start button is pressed.

I’m really struggling with the variables in the “if” section of the coding. I don’t know what exactly to make trigger a point. I want the player to get a point when they press the RIGHT keyboard key that corresponds with the RIGHT note at the RIGHT time. However the only way for Scratch to determine if a note was pressed at the right time is if the sprite is touching the right colour or at the right coordinates.

So far I have at least figured out that the first piece of the coding is “when __ key pressed” and now I need to fill in the other few blanks.

Creating a Piano Tutorial Style Scratch Project

Using the original template we already had, I edited the pre-existing sprite costumes to look like the following:

Using the original template we already had, I edited the pre-existing sprite costumes to look like the following:

I later renamed each costume according to one of the notes in the song “Here Comes the Sun” (B, A, G, F#, E, D, C).

To make the falling sprites align with the piano keys, I changed the x coordinates in the code.

To portray the rhythm through the distance between each falling sprite. I told the sprites how long to wait before the next sprite fell. A quaver = 0.5 seconds, a crotchet = 1 second, a minum = 2 sec, semibreve = 4 sec. I even had a dotted quaver (0.75 sec) and a semiquaver (0.25).

Notation of ‘Here Comes the Sun’
Coding Musical Notation

I edited each of the sprites for the piano keys so that it would be clear when the key should be pressed when the falling sprites align with a circle.

In the pre-existing project that I began with, there was already coding to make the clones disappear once they reached the bottom of the screen. I edited the y coordinate in this code so that the falling sprites would disappear as soon as they aligned with the circles on the piano keys : y = -130.

After doing this I realised that the F# would prove to be a problem as the circles for the black notes were higher, therefore needed to be deleted at a higher y coordinate. I decided to create an entirely new sprite rather than create a costume for the F#. This way I could easily program that sprite to delete itself once it reached the appropriate y coordinate.

To emphasise when the falling sprites would align with a black key, I decided to change the colour of the falling sprites and the circles on the keys so that they matched. Yellow for white keys and green for black.

Since I created a new sprite for F#, I had to compensate for that in the coding which portrayed the rhythm. When an F# was played, the other sprites were told to “wait” the length in the notated rhythm + the length of the following F#. Likewise, the F# had to “wait” the length of all of the notes preceding it. You can see the waiting time between each F# in the screenshot below:

My Friends’s Composition Based on Ed Sheeran’s “Shape of You”

I’m loving my friend Rachel’s awesome composition! Super catchy 😁

You can also follow her on Twitter.

Digital Project – Using Scratch

In order to play audio when the keys on our piano are touched, we needed to code a game using Scratch which, when certain keys were pressed, would play assigned pitches.

We were able to find a pre-existing Scratch project which gave us a starting point for our coding:

https://scratch.mit.edu/projects/342680848/editor

Our MVP (Minimum Viable Product) that we want to achieve is to change the graphics as well as the keys that need to be pressed to play the notes.

If we have time we want to create an interactive piano tutorial in which we have sprites come down from the top of the screen and reach the keys when they should be pressed.

If we STILL have time we would love to make it into a ‘guitar hero’ style game where they get a score depending on how accurately they play the song in the tutorial.

Returning to A

I wanted to have a ternary type structure to mimic my model piece however I wanted to also have a similar build so that there was a dramatically different texture to the first section even though there was inherently the same material.

To achieve this I brought in brass instruments (French horn, trumpets x2, trombone, tuba) to join the clarinet and the flute with the melody and countermelody. I gave the melody to the first trumpet and the trombone. The other brass instruments play the countermelody with the flute.

With the strings maintaining the sustained chords and the harp playing the arpeggiated chords, the texture easily fills out to a dramatic climax.

Strings or Voices?

I originally had strings playing the sustained chords in this composition however I then decided to change them to voices (Soprano, Alto, Tenor, Baritone, Bass) to make it sound more like my model piece. This however was problematic since I didn’t think about the fact that singers actully have to breath…

To achieve the truly legato and sustained sound I was wanting, I had to change it back to strings.

Teaching Music Outside the Box

Projects that can be used in the classroom to keep music alive!

Melody's Music Tech Blog

3rd year music education student (piano major) at Sydney Con | Piano teacher and accompanist in south Sydney

Technology in Music Education

A reflective blog on technology's role in 21st Century music education

LJS Music Education

Music: A Creative Process

Technology in Music Education

Tech, Music and Education combined into one.

Rachel Hennessy's Blog

notes and projects of an aspiring musician, composer and teacher

Having nothing to say and saying it: my blog.

What James Humberstone is thinking about composition, music education and music technology.

Broma Bakery

Just another WordPress.com site

Music Teaching 101

Creative Music Teaching at Sydney Conservatorium of Music

Discover

A daily selection of the best content published on WordPress, collected for you by humans who love to read.

The Atavist Magazine

Creative Music Teaching at Sydney Conservatorium of Music

Longreads

The best longform stories on the web

Create your website at WordPress.com
Get started