This is a SCRIPT-8 cassette.
Created
July 22, 2020 21:28
-
-
Save thykka/117d5ff23f36bdb9f58001242aa20575 to your computer and use it in GitHub Desktop.
SCRIPT-8
This file contains hidden or 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 hidden or 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
| const SP_TOPS = [0, 1, 2]; | |
| const SP_BOTTOMS = [16, 17, 18]; | |
| init = S => { | |
| S.player = { | |
| x: 32, | |
| y: 32, | |
| topSprite: 1, | |
| bottomSprite: 2, | |
| shade: 0, | |
| flip: false | |
| } | |
| } | |
| update = (S, input, elapsed) => { | |
| if(input.aPressed) S.isEditing = !S.isEditing; | |
| if(S.isEditing) { | |
| if(input.bPressed) S.focusBottom = !S.focusBottom; | |
| if(input.rightPressed) { | |
| if(S.focusBottom) { | |
| S.player.bottomSprite = (S.player.bottomSprite + 1) % SP_BOTTOMS.length; | |
| } else { | |
| S.player.topSprite = (S.player.topSprite + 1) % SP_TOPS.length; | |
| } | |
| } | |
| else if(input.leftPressed) { | |
| if(S.focusBottom) { | |
| S.player.bottomSprite = (S.player.bottomSprite + SP_BOTTOMS.length - 1) % SP_BOTTOMS.length; | |
| } else { | |
| S.player.topSprite = (S.player.topSprite + SP_TOPS.length - 1) % SP_TOPS.length; | |
| } | |
| } | |
| log('editing') | |
| } | |
| } | |
| draw = S => { | |
| clear(); | |
| drawPlayer(S.player) | |
| if(S.isEditing) drawEditHints(S); | |
| } | |
| function drawEditHints(S) { | |
| const x = S.player.x - 5; | |
| const y = S.player.y + (S.focusBottom ? 4 : -4) | |
| print(x, y, '<', 4) | |
| print(x + 14, y, '>', 4) | |
| } | |
| function drawPlayer({ x, y, topSprite, bottomSprite, shade = 0, flip = false }) { | |
| const spriteTop = SP_TOPS[topSprite]; | |
| const spriteBottom = SP_BOTTOMS[bottomSprite]; | |
| sprite(x, y - 4, spriteTop, -shade, flip, false); | |
| sprite(x, y + 4, spriteBottom, -shade, flip, false); | |
| } |
This file contains hidden or 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 hidden or 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.280", | |
| "lines": [ | |
| 56, | |
| 0, | |
| 0, | |
| 0, | |
| 0, | |
| 0, | |
| 0, | |
| 0 | |
| ] | |
| } |
This file contains hidden or 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 hidden or 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 hidden or 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": [ | |
| " 222 ", | |
| " 222 ", | |
| " 222 ", | |
| " 222 ", | |
| " 12221 ", | |
| "2122112 ", | |
| "2111112 ", | |
| "2111112 " | |
| ], | |
| "1": [ | |
| " 222 ", | |
| " 222 ", | |
| " 222 ", | |
| " 222 ", | |
| " 12221 ", | |
| "1112111 ", | |
| "1111111 ", | |
| "1111111 " | |
| ], | |
| "2": [ | |
| " 222 ", | |
| " 222 ", | |
| " 222 ", | |
| " 222 ", | |
| " 12221 ", | |
| "2122212 ", | |
| "2112112 ", | |
| "2111112 " | |
| ], | |
| "16": [ | |
| "2111112 ", | |
| "2111112 ", | |
| "2555552 ", | |
| " 55555 ", | |
| " 55 55 ", | |
| " 55 55 ", | |
| "666 666 ", | |
| " " | |
| ], | |
| "17": [ | |
| "2111112 ", | |
| "2111112 ", | |
| "2111112 ", | |
| " 55555 ", | |
| " 55 55 ", | |
| " 55 55 ", | |
| "666 666 ", | |
| " " | |
| ], | |
| "18": [ | |
| "2222222 ", | |
| "2555552 ", | |
| "2 555 2 ", | |
| " 2 2 ", | |
| " 2 2 ", | |
| " 2 2 ", | |
| " 66 66 ", | |
| " " | |
| ] | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment