Skip to content

Instantly share code, notes, and snippets.

@gabrielflorit
Last active January 23, 2020 04:37
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/f4f70d64137be660163affe88ce12981 to your computer and use it in GitHub Desktop.
Save gabrielflorit/f4f70d64137be660163affe88ce12981 to your computer and use it in GitHub Desktop.
SCRIPT-8
{
"0": {
"0": {
"1": 4,
"2": 0
},
"1": {
"1": 5,
"2": 1
},
"2": {
"0": 19,
"1": 6
},
"3": {
"1": 4,
"2": 2
},
"4": {
"1": 5,
"2": 3
},
"5": {
"0": 19,
"1": 6
},
"6": {
"1": 4,
"2": 0
},
"7": {
"1": 5,
"2": 1
},
"8": {
"0": 19,
"1": 6
},
"9": {
"1": 4,
"2": 2
},
"10": {
"1": 5,
"2": 3
},
"11": {
"0": 19,
"1": 6
},
"12": {
"0": 13,
"2": 7,
"3": 16
},
"13": {
"0": 14,
"2": 8,
"3": 17
},
"14": {
"0": 15,
"2": 9,
"3": 18
},
"15": {
"0": 13,
"2": 10,
"3": 16
},
"tempo": "2"
},
"1": {
"0": {
"0": 14,
"2": 11,
"3": 17
},
"1": {
"0": 15,
"2": 12,
"3": 18
},
"tempo": "2"
}
}
// title: metroid theme
init = state => {
playSong(0, true)
}
update = (state, input, elapsed) => {
if (input.startPressed) {
playSong(0, true)
}
if (input.selectPressed) {
stopSong()
}
if (input.aPressed) {
playChain(0, true)
}
if (input.bPressed) {
stopChain()
}
}
draw = state => {
clear()
range(6).forEach(i => {
printAlphabet({
x: 10,
y: 1 + i * 21,
numbers: 'metroid',
color: i,
size: 4,
flip: true
})
})
}
const printAlphabet = ({ x, y, numbers, color, flip, size = 3 }) => {
let digits = numbers.toString().split('')
if (!flip) {
digits.reverse()
}
digits.forEach((digit, digitI) => {
alphabet[digit].forEach((pixel, i) => {
const numberX = i % 3
const numberY = Math.floor(i / 3)
if (pixel) {
rectFill(
(flip ? 1 : -1) * digitI * (size * 4) + x + numberX * size,
y + num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, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0],
p: [1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0],
q: [1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0],
r: [1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0],
s: [1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0],
t: [1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0],
u: [1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0],
v: [1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0],
w: [1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0],
x: [1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0],
y: [1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0],
z: [1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0]
}
{
"iframeVersion": "0.1.274",
"lines": [
35,
24,
53,
0,
0,
0,
0,
0
]
}
{
"0": {
"notes": [
"0c#37",
"1c#37",
"2c#37",
"3c#37",
"4c#37",
"12a37",
"13a37",
"14a37",
"15a37"
],
"tempo": "2",
"synth": 0
},
"1": {
"notes": [
"0a37",
"8e37",
"9e37",
"10e37",
"11e37",
"12e37"
],
"tempo": 0,
"synth": 0
},
"2": {
"notes": [
"0c#37",
"1c#37",
"2c#37",
"3c#37",
"4c#37",
"12b37",
"13b37",
"14b37",
"15b37"
],
"tempo": 0,
"synth": 0
},
"3": {
"notes": [
"0b37",
"8a37",
"9a37",
"10a37",
"11a37",
"12a37"
],
"tempo": 0,
"synth": 0
},
"4": {
"notes": [
"0c#10",
"1c#-17",
"2c#-17",
"3c#-17",
"4c#-17",
"5c#-17",
"6c#-17",
"7c#-17",
"8c#-17",
"9c#-17",
"12c#10",
"13c#-15",
"14c#-17",
"15c#-17"
],
"tempo": 0,
"synth": 0
},
"5": {
"notes": [
"0c#-17",
"1c#-17",
"2c#-17",
"3c#-17",
"4c#-17",
"5c#-17",
"8c#10",
"9c#-17",
"10c#-17",
"11c#-17",
"12c#-17",
"13c#-17",
"14c#-17",
"15c#-17"
],
"tempo": 0,
"synth": 0
},
"6": {
"notes": [
"0c#-17",
"1c#-17",
"4c#10",
"5c#-17",
"6c#-17",
"7c#-17",
"8c#-17",
"9c#-17",
"10c#-17",
"11c#-17",
"12c#-17",
"13c#-17"
],
"tempo": 0,
"synth": 0
},
"7": {
"notes": [
"0c#27",
"1d-17",
"2e-13",
"3e-13",
"4e-13",
"5e-13",
"6e-13",
"7e-13",
"8e-13",
"9e-13",
"10e-17",
"11b-17",
"12b27",
"13e-13",
"14e-13",
"15e-13"
],
"tempo": "2",
"synth": "2"
},
"8": {
"notes": [
"0e-13",
"1e-13",
"2e-13",
"3e-13",
"4e-13",
"5e-13",
"6e-17",
"7e-17",
"8a#27",
"9e-13",
"10e-13",
"11e-13",
"12e-13",
"13e-13",
"14e-13",
"15e-13"
],
"tempo": 0,
"synth": "2"
},
"9": {
"notes": [
"0e-13",
"1e-13",
"2e-17",
"3e-17",
"4a27",
"5e-13",
"6e-13",
"7e-13",
"8e-13",
"9e-13",
"10e-13",
"11e-13",
"12e-13",
"13e-13",
"14e-17",
"15e-17"
],
"tempo": 0,
"synth": "2"
},
"10": {
"notes": [
"0f27",
"1f-17",
"2f-17",
"3f-17",
"4f-17",
"5f-17",
"6f-17",
"7f-17",
"8f-17",
"9f-17",
"10f-17",
"11f-17",
"12b27",
"13g#-17",
"14g#-17",
"15g#-17"
],
"tempo": 0,
"synth": "2"
},
"11": {
"notes": [
"0b-17",
"1b-17",
"2b-17",
"3b-17",
"4b-17",
"5b-17",
"6b-17",
"7b-17",
"8a27",
"9a-17",
"10a-17",
"11a-17",
"12a-17",
"13a-17",
"14a-17",
"15a-17"
],
"tempo": 0,
"synth": "2"
},
"12": {
"notes": [
"0a-17",
"1a-17",
"2a-17",
"3a-17",
"4f#27",
"5f#-17",
"6f#-17",
"7f#-17",
"8f#-17",
"9f#-17",
"10f#-17",
"11f#-17",
"12f#-17",
"13f#-17",
"14f#-17",
"15f#-17"
],
"tempo": "2",
"synth": "2"
},
"13": {
"notes": [
"0g#31",
"1a-17",
"2a-17",
"3g#21",
"4a-17",
"5a-17",
"6f#31",
"7g-17",
"8g-17",
"9f#21",
"10g-17",
"11g-17",
"12f31",
"13f#-17",
"14f#-17",
"15f21"
],
"tempo": "2",
"synth": "2"
},
"14": {
"notes": [
"0f#-17",
"1f#-17",
"2d#31",
"3e-17",
"4e-17",
"5d#21",
"6e-17",
"7e-17",
"8f#31",
"9g-17",
"10g-17",
"11f#21",
"12g-17",
"13g-17",
"14f31",
"15f#-17"
],
"tempo": 0,
"synth": "2"
},
"15": {
"notes": [
"0f#-16",
"1f21",
"2f#-17",
"3f#-17",
"4d#31",
"5e-17",
"6e-17",
"7d#21",
"8d#-17",
"9e-17",
"10c#31",
"11d-17",
"12d-17",
"13c#21",
"14d-17",
"15d-17"
],
"tempo": 0,
"synth": "2"
},
"16": {
"notes": [
"0c31",
"3c31",
"6c31",
"10c31",
"11c31",
"12c31"
],
"tempo": 0,
"synth": "3"
},
"17": {
"notes": [
"5c31",
"6c31",
"8c31",
"11c31",
"14c31"
],
"tempo": 0,
"synth": "3"
},
"18": {
"notes": [
"2c31",
"3c31",
"4c31",
"13c31",
"14c31"
],
"tempo": 0,
"synth": "3"
},
"19": {
"notes": [
"9f10",
"10f-17",
"11f-17",
"12f-17",
"13f-17"
],
"tempo": 0,
"synth": 0
}
}
{
"0": {
"0": 0,
"1": 1,
"tempo": "2"
},
"1": {
"0": 0,
"1": 1,
"tempo": "1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment