Last active
March 17, 2020 21:46
SCRIPT-8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// title: replay setup | |
// This demonstrates how to setup a cassette so you can see | |
// your actors past and present. | |
// All you need to do: create an actors array in state, | |
// and give each actor a unique string id. | |
// That's it. Now when you hit PAUSE, you'll see the actors | |
// under the timeline. Click the actor button to see the | |
// past and future. | |
init = state => { | |
state.actors = [ | |
{ | |
id: 'ball', | |
x: 10, | |
y: 64, | |
dx: 1, | |
dy: 1, | |
sprite: 0 | |
} | |
] | |
} | |
update = (state, input, elapsed) => { | |
const ball = state.actors.find(actor => actor.id === 'ball') | |
// Adjust velocity | |
if (input.downPressed) ball.dy += 0.5 | |
if (input.upPressed) ball.dy -= 0.5 | |
if (input.leftPressed) ball.dx -= 0.5 | |
if (input.rightPressed) ball.dx += 0.5 | |
// Bounce off edges | |
if (ball.x <= 0 || ball.x >= 120) { | |
ball.dx *= -1 | |
} | |
if (ball.y <= 0 || ball.y >= 120) { | |
ball.dy *= -1 | |
} | |
// Move ball | |
ball.x += ball.dx | |
ball.y += ball.dy | |
} | |
draw = state => { | |
clear() | |
drawActors(state) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"iframeVersion": "0.1.273", | |
"lines": [ | |
50, | |
0, | |
0, | |
0, | |
0, | |
0, | |
0, | |
0 | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"0": [ | |
" 000000 ", | |
"00000000", | |
"00000000", | |
"00000000", | |
"00000300", | |
"00000300", | |
"00033300", | |
" 000000 " | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment