Skip to content

Instantly share code, notes, and snippets.

@gabrielflorit
Last active October 27, 2019 01:43
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/a0d83e7c39f206cbb576880613d742df to your computer and use it in GitHub Desktop.
Save gabrielflorit/a0d83e7c39f206cbb576880613d742df to your computer and use it in GitHub Desktop.
SCRIPT-8
// title: fade in/out
const fade = n => {
range(7).forEach(i => {
colorSwap(i, clamp(i + n, 0, 7))
})
}
const outlinePrint = (x, y, text, color, outline) => {
range(9).forEach(i => {
print(x + -1 + (i % 3), y + -1 + i / 3, text, outline)
})
print(x, y, text, color)
}
init = state => {
state.fadeLevel = 0
}
update = (state, input) => {
if (input.left || input.down) {
state.fadeLevel = Math.min(state.fadeLevel + 1, 7)
}
if (input.right || input.up) {
state.fadeLevel = Math.max(state.fadeLevel - 1, 0)
}
}
draw = state => {
fade(state.fadeLevel)
clear()
range(8).forEach(i => {
const side = 128 - i * 16
const xy = 64 - side / 2
rectFill(xy, xy, side, side, i)
})
outlinePrint(33, 61, 'press arrow keys', 0, 7)
}
{
"iframeVersion": "0.1.255",
"lines": [
42,
0,
0,
0,
0,
0,
0,
0
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment