Skip to content

Instantly share code, notes, and snippets.

@gabrielflorit
Last active February 9, 2019 05:09
Show Gist options
  • Save gabrielflorit/226a8e31334c230d6c3543a95505f1ed to your computer and use it in GitHub Desktop.
Save gabrielflorit/226a8e31334c230d6c3543a95505f1ed to your computer and use it in GitHub Desktop.
SCRIPT-8
{
"0": {
"0": {
"0": 10
},
"1": {
"0": 10
},
"2": {
"0": 10
},
"3": {
"0": 10
},
"4": {
"0": 10
},
"5": {
"0": 10
},
"6": {
"0": 10
},
"7": {
"0": 10
},
"8": {
"0": 10
},
"9": {
"0": 10
},
"10": {
"0": 10
},
"11": {
"0": 10
},
"12": {
"0": 10
},
"13": {
"0": 10
},
"14": {
"0": 10
},
"15": {
"0": 10
}
},
"1": {
"0": {
"0": 0
},
"1": {
"0": 0
},
"2": {
"0": 0
},
"3": {
"0": 0
},
"4": {
"0": 0
},
"5": {
"0": 0
},
"6": {
"0": 0
},
"7": {
"0": 0
},
"8": {
"0": 0
},
"9": {
"0": 0
},
"10": {
"0": 0
},
"11": {
"0": 0
},
"12": {
"0": 0
},
"13": {
"0": 0
},
"14": {
"0": 0
},
"15": {
"0": 0
}
}
}
initialState = {
isPlaying: false,
song: 0
}
update = (state, input) => {
if (input.up) {
state.song = 1
if (state.isPlaying) {
playSong(state.song)
}
}
if (input.down) {
state.song = 0
if (state.isPlaying) {
playSong(state.song)
}
}
if (input.start) {
state.isPlaying = !state.isPlaying
if (state.isPlaying) {
playSong(state.song)
} else {
stopSong()
}
}
}
draw = (state) => {
clear(6)
print(8 * 5, 8 * 6, 'play', state.isPlaying ? 0 : 3)
print(8 * 9, 8 * 6, 'stop', state.isPlaying ? 3 : 0)
print(8 * 5, 8 * 8, 'low', state.song === 0 ? 0 : 3)
print(8 * 9, 8 * 8, 'high', state.song === 1 ? 0 : 3)
}
{
"0": [
"0a17",
"1e27",
"2a17",
"3f27",
"4a17",
"5a17",
"6g27",
"7a17",
"8e27",
"9a17",
"10f27",
"11a17",
"12a17",
"13a27",
"14a17",
"15a17"
],
"1": [
"0g27",
"1a17",
"2a17",
"3e27",
"4a17",
"5f27"
],
"10": [
"0a07",
"1e17",
"2a07",
"3f17",
"4a07",
"5a07",
"6g17",
"7a07",
"8e17",
"9a07",
"10f17",
"11a07",
"12a07",
"13a17",
"14a07",
"15a07"
]
}
{
"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
},
"1": {
"0": 1,
"1": 1,
"2": 1,
"3": 1,
"4": 1,
"5": 1,
"6": 1,
"7": 1,
"8": 1,
"9": 1,
"10": 1,
"11": 1,
"12": 1,
"13": 1,
"14": 1,
"15": 1
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment