Skip to content

Instantly share code, notes, and snippets.

@hugs
Created June 21, 2019 01:30
Show Gist options
  • Save hugs/02f3d49b9aaad6abde88a365b11556d5 to your computer and use it in GitHub Desktop.
Save hugs/02f3d49b9aaad6abde88a365b11556d5 to your computer and use it in GitHub Desktop.
Tapster Sidekick Demo - Hedwig's Theme - Garage Band app
notes = {
'C': [54,130],
'D': [44,130],
'E': [34,130],
'F': [24,130],
'G': [16,130],
'A': [6,130],
'B': [-3,130],
'c': [-13,130],
'd': [-23,130],
'e': [-32,130],
}
scale = ['c', 'B', 'A', 'G', 'F', 'E', 'D', 'C', 'D', 'E', 'F', 'G', 'A', 'B', 'c']
potter = ['E', 'A', 'c', 'B', 'A', 'e', 'd', 'B']
sleep = function(length) {
child_process.execSync('sleep ' + length)
}
play = function(tune) {
var x, y
for (var note in tune) {
loc = notes[tune[note]]
console.log(loc)
setTimeout( function(x, y) {
console.log(x, y);
let newLoc = t0.position.calcOffset(x, y)
t0.position._go(newLoc[0],newLoc[1])
}, note * 300, loc[0], loc[1] )
setTimeout( function() {
t0.e.tap()
}, note * 300 + 200)
}
var firstNote = notes[tune[0]]
setTimeout( function(x, y) {
console.log(x, y);
let newLoc = t0.position.calcOffset(x, y)
t0.position._go(newLoc[0],newLoc[1])
}, (tune.length + 1) * 300, firstNote[0], firstNote[1] )
}
init = function() {
t0.z.down(90)
t0.position.go(-13,130);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment