Skip to content

Instantly share code, notes, and snippets.

@gabrielflorit
Last active January 20, 2020 20:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gabrielflorit/c97f3877cda67de31a9594310594d224 to your computer and use it in GitHub Desktop.
Save gabrielflorit/c97f3877cda67de31a9594310594d224 to your computer and use it in GitHub Desktop.
SCRIPT-8
{
"0": {
"0": {
"0": 0,
"1": 0,
"2": 0,
"3": 0
},
"1": {
"0": 0
},
"2": {
"0": 2,
"1": 0
},
"3": {
"0": 2,
"1": 2,
"2": 1,
"3": 0
},
"4": {
"1": 2,
"2": 1,
"3": 0
},
"5": {
"1": 2,
"2": 1,
"3": 0
},
"6": {
"1": 2,
"2": 1,
"3": 0
},
"tempo": "1"
},
"1": {
"0": {
"1": 0
},
"tempo": "0"
}
}
// title: music test
init = state => {
state.chainIndex = 0
state.songIndex = 0
state.playingChain = false
state.playingSong = false
}
update = (state, input, elapsed) => {
if (input.leftPressed) state.chainIndex--
if (input.rightPressed) state.chainIndex++
if (input.upPressed) state.songIndex++
if (input.downPressed) state.songIndex--
if (input.aPressed) {
state.playingChain = true
playChain(state.chainIndex)
}
if (input.bPressed) {
state.playingSong = true
playSong(state.songIndex)
}
if (input.selectPressed) {
state.playingChain = false
state.playingSong = false
stopChain()
stopSong()
}
}
draw = state => {
clear()
print(0, 0, `chain: ${state.chainIndex}`, 0)
print(0, 8 * 1, `song: ${state.songIndex}`, 0)
state.playingChain && print(0, 8 * 5, 'playing chain', 0)
state.playingSong && print(0, 8 * 6, 'playing song', 0)
}
{
"iframeVersion": "0.1.273",
"lines": [
41,
0,
0,
0,
0,
0,
0,
0
]
}
{
"0": {
"notes": [
"0c37",
"1c#37",
"2d37",
"3d#37",
"4e37",
"5f37",
"6f#37",
"7g37",
"8g#37",
"9a37",
"10a#37",
"11b37",
"12a#37",
"13a37",
"14g#37",
"15g37"
],
"tempo": 0
},
"1": {
"notes": [
"0d37",
"1d#37",
"2e37",
"3f37",
"4f#37",
"5g37",
"6g#37",
"7a37",
"8a#37",
"9b37",
"10a#37",
"11b37",
"12a#37",
"13b37",
"14a#37",
"15b37"
],
"tempo": 0
},
"2": {
"notes": [
"0g#37",
"1d#37",
"2g37",
"3d37",
"4f#37",
"5c#37",
"6f37",
"7c37",
"8e37",
"9b27",
"10d#37",
"11a#27",
"12d37",
"13a27",
"14c#37",
"15g#27"
],
"tempo": 0
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment