Skip to content

Instantly share code, notes, and snippets.

@gabrielflorit
Last active January 20, 2020 20:15
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/3c6f88e8281fccf8b7ea0f16d3002503 to your computer and use it in GitHub Desktop.
Save gabrielflorit/3c6f88e8281fccf8b7ea0f16d3002503 to your computer and use it in GitHub Desktop.
SCRIPT-8
{
"0": {
"0": {
"0": 3
},
"1": {
"0": 3,
"1": 3
},
"2": {
"0": 3,
"1": 3,
"2": 3
},
"3": {
"0": 3,
"1": 3,
"2": 3,
"3": 3
},
"4": {
"0": 3,
"1": 3,
"2": 1,
"3": 3
},
"5": {
"0": 3,
"1": 3,
"2": 2,
"3": 3
},
"6": {
"0": 3,
"1": 3,
"2": 0,
"3": 3
},
"7": {
"0": 3,
"1": 3,
"2": 1,
"3": 3
},
"8": {
"0": 3,
"1": 3,
"2": 2,
"3": 3
},
"9": {
"0": 3,
"1": 3,
"2": 1,
"3": 3
},
"10": {
"0": 3,
"1": 3,
"2": 0,
"3": 3
},
"11": {
"0": 3,
"1": 3,
"2": 1,
"3": 3
},
"12": {
"0": 3,
"1": 3,
"2": 3,
"3": 3
},
"13": {
"0": 3,
"1": 3,
"2": 3
},
"14": {
"0": 3,
"1": 3
},
"15": {
"0": 3
},
"tempo": "7"
}
}
// 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": [
"0b33",
"1a33",
"2g33",
"3f33",
"4d#33",
"5c#33",
"6b23",
"7a23",
"8g23",
"9f23",
"10d#23",
"11c#23",
"12b13",
"13a13",
"14g13",
"15f13"
],
"tempo": 0
},
"1": {
"notes": [
"0c04",
"1d#04",
"2f#04",
"3a04",
"4c14",
"5d#14",
"6f#14",
"7a14",
"8c24",
"9d#24",
"10f#24",
"11a24",
"12c34",
"13d#34",
"14f#34",
"15a34"
],
"tempo": 0
},
"2": {
"notes": [
"0g34",
"1b34",
"2f#34",
"3a#34",
"4f34",
"5a34",
"6e34",
"7g#34",
"8d#34",
"9g34",
"10d34",
"11f#34",
"12c#34",
"13f34",
"14c34",
"15e34"
],
"tempo": 0
},
"3": {
"notes": [
"0c17",
"1f17",
"2d#17",
"3g17",
"4c#17",
"5f#17",
"6e17",
"7g#17",
"8d17",
"9g17",
"10f17",
"11a17",
"12d#17",
"13g#17",
"14f#17",
"15a#17"
],
"tempo": "2"
}
}
{
"0": {
"0": 0,
"1": 0,
"2": 0,
"3": 0,
"4": 0,
"5": 0,
"6": 0,
"7": 0,
"8": 0,
"9": 0,
"10": 0,
"11": 0,
"12": 0,
"13": 0,
"14": 0,
"15": 0,
"tempo": "7"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment