-
-
Save AndersonFirmino/4760dc3414b0815af2d4493b8c1e97c6 to your computer and use it in GitHub Desktop.
Revisions
-
AndersonFirmino revised this gist
Oct 7, 2021 . 5 changed files with 58 additions and 30 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1 +1 @@ This is a [SCRIPT-8](https://script-8.github.io) cassette. Click [here](https://script-8.github.io/?id=4760dc3414b0815af2d4493b8c1e97c6) to boot it. 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 charactersOriginal file line number Diff line number Diff line change @@ -79,7 +79,8 @@ "0": 7, "1": 16, "2": 26 }, "tempo": "2" }, "1": { "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 charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,5 @@ { "iframeVersion": "0.1.280", "lines": [ 574, 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 charactersOriginal file line number Diff line number Diff line change @@ -9,7 +9,8 @@ "8g27", "12g17" ], "tempo": "2", "synth": 0 }, "1": { "notes": [ @@ -21,7 +22,8 @@ "13a#17", "14a17" ], "tempo": 0, "synth": 0 }, "2": { "notes": [ @@ -36,7 +38,8 @@ "12d27", "13b17" ], "tempo": 0, "synth": 0 }, "3": { "notes": [ @@ -51,7 +54,8 @@ "12d27", "13b17" ], "tempo": 0, "synth": 0 }, "4": { "notes": [ @@ -67,7 +71,8 @@ "14c27", "15d27" ], "tempo": 0, "synth": 0 }, "5": { "notes": [ @@ -80,15 +85,17 @@ "11c37", "12c37" ], "tempo": 0, "synth": 0 }, "6": { "notes": [ "2d#27", "5d27", "8c27" ], "tempo": 0, "synth": 0 }, "7": { "notes": [ @@ -103,7 +110,8 @@ "12g17", "15g10" ], "tempo": 0, "synth": 0 }, "8": { "notes": [ @@ -114,7 +122,8 @@ "6d27", "7e27" ], "tempo": 0, "synth": 0 }, "10": { "notes": [ @@ -125,7 +134,8 @@ "6f#17", "8b17" ], "tempo": 0, "synth": 0 }, "11": { "notes": [ @@ -137,7 +147,8 @@ "13c#17", "14c17" ], "tempo": 0, "synth": 0 }, "12": { "notes": [ @@ -152,7 +163,8 @@ "12f17", "13d17" ], "tempo": 0, "synth": 0 }, "13": { "notes": [ @@ -168,7 +180,8 @@ "14e17", "15f17" ], "tempo": 0, "synth": 0 }, "14": { "notes": [ @@ -181,15 +194,17 @@ "11g27", "12g27" ], "tempo": 0, "synth": 0 }, "15": { "notes": [ "2g#17", "5f17", "8e17" ], "tempo": 0, "synth": 0 }, "16": { "notes": [ @@ -203,7 +218,8 @@ "11e17", "12c17" ], "tempo": 0, "synth": 0 }, "17": { "notes": [ @@ -214,7 +230,8 @@ "6a#17", "7g17" ], "tempo": 0, "synth": 0 }, "20": { "notes": [ @@ -226,7 +243,8 @@ "8g17", "12g07" ], "tempo": 0, "synth": 0 }, "21": { "notes": [ @@ -238,7 +256,8 @@ "13f#07", "14f07" ], "tempo": 0, "synth": 0 }, "22": { "notes": [ @@ -253,7 +272,8 @@ "12b07", "13g07" ], "tempo": 0, "synth": 0 }, "23": { "notes": [ @@ -265,7 +285,8 @@ "12c17", "14f07" ], "tempo": 0, "synth": 0 }, "24": { "notes": [ @@ -275,7 +296,8 @@ "7c17", "14g07" ], "tempo": 0, "synth": 0 }, "25": { "notes": [ @@ -287,7 +309,8 @@ "12g07", "14c07" ], "tempo": 0, "synth": 0 }, "26": { "notes": [ @@ -298,7 +321,8 @@ "11c07", "14g#07" ], "tempo": 0, "synth": 0 }, "60": { "notes": [ @@ -311,12 +335,14 @@ "6b07", "7d07" ], "tempo": 0, "synth": 0 }, "61": { "notes": [ "0b31" ], "tempo": 0, "synth": 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 charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,7 @@ { "0": { "0": 0, "tempo": "2" }, "1": { "0": 1 -
gabrielflorit revised this gist
Oct 27, 2019 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -148,8 +148,8 @@ const scanTileV = ({ x, y, dy, up }) => { const tileX = floor(x / 8) const tileY = i / 8 const blockingTiles = (x % 8 === 0 ? [getTile(tileX, tileY)] : [getTile(tileX, tileY), getTile(tileX + 1, tileY)] ).filter(d => d && d[8] === 1) if (blockingTiles.length) { return { tile: blockingTiles[0], y: i } @@ -170,8 +170,8 @@ const scanTileH = ({ x, dx, y, left }) => { const tileX = i / 8 const tileY = floor(y / 8) const blockingTiles = (y % 8 === 0 ? [getTile(tileX, tileY)] : [getTile(tileX, tileY), getTile(tileX, tileY + 1)] ).filter(d => d && d[8] === 1) if (blockingTiles.length) { return { tile: blockingTiles[0], x: i } -
gabrielflorit revised this gist
Oct 27, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -472,7 +472,7 @@ drawActors = (state, fade) => { .forEach(d => { drawActor({ ...d, id: actor.id }) }) } else { -
gabrielflorit revised this gist
Oct 27, 2019 . 2 changed files with 27 additions and 27 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -84,7 +84,7 @@ const fsm = new StateMachine({ const initialActors = [ { id: 'smallcloud', x: 20, y: 32, dx: -1/32, @@ -93,7 +93,7 @@ const initialActors = [ flip: false }, { id: 'mario', counter: 0, x: 20, y: 104, @@ -104,7 +104,7 @@ const initialActors = [ isOnGround: true }, { id: 'goomba', enemy: true, instances: [ { @@ -129,15 +129,15 @@ const initialActors = [ } ] init = state => { state.mode = 'title' state.checks = [] state.counter = 0 state.score = 0 state.lives = 0 state.coins = 0 state.elapsed = 0 state.actors = [...initialActors] } const scanTileV = ({ x, y, dy, up }) => { @@ -181,7 +181,7 @@ const scanTileH = ({ x, dx, y, left }) => { } const moveMarioHorizontally = ({ state, input }) => { const mario = state.actors.find(d => d.id === 'mario') let { x, dx, y } = mario const { maxDx, ddx } = e.mario @@ -219,7 +219,7 @@ const moveMarioHorizontally = ({ state, input }) => { const moveEnemies = state => { const enemies = state.actors.filter(d => d.enemy) const mario = state.actors.find(d => d.id === 'mario') enemies.forEach(actor => { actor.instances.forEach(d => { if (d.x <= -8) { @@ -243,16 +243,16 @@ const isOnGround = ({ x, y }) => { const tiles = (x % 8 === 0 ? [getTile(floor(x / 8), floor(y / 8) + 1)] : [ getTile(floor(x / 8), floor(y / 8) + 1), getTile(floor(x / 8) + 1, floor(y / 8) + 1) ] ).filter(d => d && d[8] === 1) return tiles.length } } const collideWithEnemies = ({ state }) => { const mario = state.actors.find(d => d.id === 'mario') const enemies = state.actors.filter(d => d.enemy) // Check if we're colliding with an enemy. @@ -290,8 +290,8 @@ const collideWithEnemies = ({ state }) => { } const moveClouds = state => { const cloud = state.actors.find(d => d.id === 'smallcloud') const mario = state.actors.find(d => d.id === 'mario') cloud.x += cloud.dx if (cloud.x < -15) { @@ -301,7 +301,7 @@ const moveClouds = state => { } const moveMario = ({ state, input }) => { const mario = state.actors.find(d => d.id === 'mario') if (fsm.state === 'idle') { // Move horizontally. @@ -482,7 +482,7 @@ drawActors = (state, fade) => { } const drawActor = actor => { const cycle = sprites[actor.id][actor.mode] const step = cycle[actor.counter % cycle.length] if (Array.isArray(step)) { // Here, step is a grid. Let's go over each entry. @@ -510,7 +510,7 @@ const drawTopBar = state => { } const drawLivesScreen = state => { const mario = state.actors.find(d => d.id === 'mario') camera(0) clear() print(52, 52, `world ${ceil(mario.y / 128)}`, 0) @@ -519,15 +519,15 @@ const drawLivesScreen = state => { } draw = state => { const mario = state.actors.find(d => d.id === 'mario') const cloud = state.actors.find(d => d.id === 'smallcloud') if (state.mode === 'play' || state.mode === 'death') { drawTopBar(state) camera() rectFill(0, 8, 128, 120, 6) drawActors({ actors: state.actors.filter(d => d.id === 'smallcloud') }) const cameraX = floor((mario.x + 4) / 128) * 128 @@ -540,7 +540,7 @@ draw = state => { print(5 + 8 * 3, 43 + 9 * 3, 'to make a game.', 0) } drawActors({ actors: state.actors.filter(d => d.id !== 'smallcloud') }) } if (state.mode === 'preplay') { 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 charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,5 @@ { "iframeVersion": "0.1.270", "lines": [ 574, 0, -
gabrielflorit revised this gist
Oct 27, 2019 . 3 changed files with 334 additions and 243 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -241,7 +241,7 @@ const isOnGround = ({ x, y }) => { return false } else { const tiles = (x % 8 === 0 ? [getTile(floor(x / 8), floor(y / 8) + 1)] : [ tile(floor(x / 8), floor(y / 8) + 1), tile(floor(x / 8) + 1, floor(y / 8) + 1) 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,13 @@ { "iframeVersion": "0.1.247", "lines": [ 574, 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 charactersOriginal file line number Diff line number Diff line change @@ -1,244 +1,322 @@ { "0": { "notes": [ "0e27", "1e27", "3e27", "5c27", "6e27", "8g27", "12g17" ], "tempo": 0 }, "1": { "notes": [ "0c27", "3g17", "6e17", "9a17", "11b17", "13a#17", "14a17" ], "tempo": 0 }, "2": { "notes": [ "0g17", "2e27", "3g27", "4a27", "6f27", "7g27", "9e27", "11c27", "12d27", "13b17" ], "tempo": 0 }, "3": { "notes": [ "0g17", "2e27", "3g27", "4a27", "6f27", "7g27", "9e27", "11c27", "12d27", "13b17" ], "tempo": 0 }, "4": { "notes": [ "2g27", "3f#27", "4f27", "5d#27", "7e27", "9g#17", "10a17", "11c27", "13a17", "14c27", "15d27" ], "tempo": 0 }, "5": { "notes": [ "2g27", "3f#27", "4f27", "5d#27", "7e27", "9c37", "11c37", "12c37" ], "tempo": 0 }, "6": { "notes": [ "2d#27", "5d27", "8c27" ], "tempo": 0 }, "7": { "notes": [ "0c27", "1c27", "3c27", "5c27", "6d27", "8e27", "9c27", "11a17", "12g17", "15g10" ], "tempo": 0 }, "8": { "notes": [ "0c27", "1c27", "3c27", "5c27", "6d27", "7e27" ], "tempo": 0 }, "10": { "notes": [ "0f#17", "1f#17", "3f#17", "5f#17", "6f#17", "8b17" ], "tempo": 0 }, "11": { "notes": [ "0e17", "3c17", "6g07", "9c17", "11d17", "13c#17", "14c17" ], "tempo": 0 }, "12": { "notes": [ "0c17", "2g17", "3b17", "4c27", "6a17", "7b17", "9a17", "11e17", "12f17", "13d17" ], "tempo": 0 }, "13": { "notes": [ "2e27", "3e27", "4d27", "5b17", "7c27", "9e17", "10f17", "11g17", "13c17", "14e17", "15f17" ], "tempo": 0 }, "14": { "notes": [ "2e27", "3e27", "4d27", "5b17", "7c27", "9g27", "11g27", "12g27" ], "tempo": 0 }, "15": { "notes": [ "2g#17", "5f17", "8e17" ], "tempo": 0 }, "16": { "notes": [ "0g#17", "1g#17", "3g#17", "5g#17", "6a#17", "8g17", "9e17", "11e17", "12c17" ], "tempo": 0 }, "17": { "notes": [ "0g#17", "1g#17", "3g#17", "5g#17", "6a#17", "7g17" ], "tempo": 0 }, "20": { "notes": [ "0d07", "1d07", "3d07", "5d07", "6d07", "8g17", "12g07" ], "tempo": 0 }, "21": { "notes": [ "0g07", "3e07", "6c07", "9f07", "11g07", "13f#07", "14f07" ], "tempo": 0 }, "22": { "notes": [ "0e07", "2c17", "3e17", "4f17", "6d17", "7e17", "9c17", "11a07", "12b07", "13g07" ], "tempo": 0 }, "23": { "notes": [ "0c07", "3g07", "6c17", "8f07", "11c17", "12c17", "14f07" ], "tempo": 0 }, "24": { "notes": [ "0c07", "3e07", "6g07", "7c17", "14g07" ], "tempo": 0 }, "25": { "notes": [ "0c07", "2g#07", "5a#07", "8c17", "11g07", "12g07", "14c07" ], "tempo": 0 }, "26": { "notes": [ "0g#07", "3d#07", "6g#07", "8g07", "11c07", "14g#07" ], "tempo": 0 }, "60": { "notes": [ "0b37", "1d37", "2b27", "3d27", "4b17", "5d17", "6b07", "7d07" ], "tempo": 0 }, "61": { "notes": [ "0b31" ], "tempo": 0 } } -
gabrielflorit revised this gist
Feb 8, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -446,7 +446,7 @@ update = (state, input, elapsed) => { } else if (state.mode === 'preplay') { if (state.counter++ > 60 * 2) { state.mode = 'play' playSong(0, true) } } else if (state.mode === 'gameover') { if (state.counter++ > 60 * 3) { -
gabrielflorit revised this gist
Feb 8, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -446,7 +446,7 @@ update = (state, input, elapsed) => { } else if (state.mode === 'preplay') { if (state.counter++ > 60 * 2) { state.mode = 'play' // playSong(0, true) } } else if (state.mode === 'gameover') { if (state.counter++ > 60 * 3) { -
gabrielflorit revised this gist
Feb 8, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -239,6 +239,6 @@ "7d07" ], "61": [ "0b31" ] } -
gabrielflorit revised this gist
Jan 30, 2019 . 1 changed file with 4 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,9 @@ // title: los hermanos bros. // TODO // re-enable music, it doesn't work right now // maybe don't put clouds in actors, why do we need that const { PI, atan2, ceil, floor, min, max, sign, abs, round } = Math const rad2Deg = ø => (ø * 180) / PI -
gabrielflorit revised this gist
Jan 30, 2019 . 2 changed files with 146 additions and 140 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -529,6 +529,12 @@ draw = state => { const cameraX = floor((mario.x + 4) / 128) * 128 camera(cameraX) map() if (mario.x > 128 * 3) { print(5 + 8 * 0, 43, 'This is all there is.', 0) print(5 + 8 * 1, 43 + 9, "There is no more.", 0) print(5 + 8 * 2, 43 + 9 * 2, 'Now it is your turn', 0) print(5 + 8 * 3, 43 + 9 * 3, 'to make a game.', 0) } drawActors({ actors: state.actors.filter(d => d.name !== 'smallcloud') }) 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 charactersOriginal file line number Diff line number Diff line change @@ -323,7 +323,7 @@ null, null, null, 48, null, null, null, @@ -453,7 +453,7 @@ null, null, null, 34, null, null, null, @@ -583,7 +583,7 @@ null, null, null, 34, null, null, null, @@ -713,7 +713,7 @@ null, null, null, 34, null, null, null, @@ -843,7 +843,7 @@ null, null, null, 34, null, null, null, @@ -973,7 +973,7 @@ null, null, null, 34, null, null, null, @@ -1103,7 +1103,7 @@ null, null, null, 34, null, null, null, @@ -1233,7 +1233,7 @@ null, null, null, 34, null, null, null, @@ -1363,7 +1363,7 @@ null, null, null, 34, null, null, null, @@ -1493,7 +1493,7 @@ null, null, null, 34, null, null, null, @@ -1623,7 +1623,7 @@ null, null, null, 34, null, null, null, @@ -1753,7 +1753,7 @@ null, null, null, 34, null, null, null, @@ -1884,70 +1884,70 @@ 32, 32, 32, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null ], [ 32, @@ -2014,70 +2014,70 @@ 32, 32, 32, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null ], [ null, -
gabrielflorit revised this gist
Jan 22, 2019 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -520,15 +520,15 @@ draw = state => { if (state.mode === 'play' || state.mode === 'death') { drawTopBar(state) camera() rectFill(0, 8, 128, 120, 6) drawActors({ actors: state.actors.filter(d => d.name === 'smallcloud') }) const cameraX = floor((mario.x + 4) / 128) * 128 camera(cameraX) map() drawActors({ actors: state.actors.filter(d => d.name !== 'smallcloud') }) @@ -538,7 +538,7 @@ draw = state => { drawTopBar(state) } if (state.mode === 'gameover') { camera() clear() print(48, 62, 'game over', 0) drawTopBar(state) @@ -548,7 +548,7 @@ draw = state => { const cameraX = floor((mario.x + 4) / 128) * 128 camera(cameraX) rectFill(cameraX, 8, 128, 120, 6) map() drawActors(state) rectFill(29, 34, 70, 25, 1) -
gabrielflorit revised this gist
Jan 15, 2019 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -125,7 +125,7 @@ const initialActors = [ } ] initialState = { mode: 'title', checks: [], counter: 0, @@ -426,7 +426,7 @@ const moveMario = ({ state, input }) => { mario.mode = fsm.state } update = (state, input, elapsed) => { state.checks = [] if (state.mode === 'play') { state.elapsed += elapsed @@ -460,7 +460,7 @@ _update = (state, input, elapsed) => { } } drawActors = (state, fade) => { state.actors.forEach(actor => { if (actor.instances) { actor.instances @@ -514,7 +514,7 @@ const drawLivesScreen = state => { print(63, 67, `x ${state.lives.toString().padStart(2, '0')}`, 0) } draw = state => { const mario = state.actors.find(d => d.name === 'mario') const cloud = state.actors.find(d => d.name === 'smallcloud') if (state.mode === 'play' || state.mode === 'death') { -
gabrielflorit revised this gist
Jan 15, 2019 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -125,7 +125,7 @@ const initialActors = [ } ] _initialState = { mode: 'title', checks: [], counter: 0, @@ -426,7 +426,7 @@ const moveMario = ({ state, input }) => { mario.mode = fsm.state } _update = (state, input, elapsed) => { state.checks = [] if (state.mode === 'play') { state.elapsed += elapsed @@ -460,7 +460,7 @@ update = (state, input, elapsed) => { } } _drawActors = (state, fade) => { state.actors.forEach(actor => { if (actor.instances) { actor.instances @@ -514,7 +514,7 @@ const drawLivesScreen = state => { print(63, 67, `x ${state.lives.toString().padStart(2, '0')}`, 0) } _draw = state => { const mario = state.actors.find(d => d.name === 'mario') const cloud = state.actors.find(d => d.name === 'smallcloud') if (state.mode === 'play' || state.mode === 'death') { -
gabrielflorit revised this gist
Jan 12, 2019 . 1 changed file with 16 additions and 16 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -168,11 +168,11 @@ null, null, null, null, null, null, null, null, null, null, null, @@ -289,20 +289,20 @@ null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, @@ -419,9 +419,9 @@ null, null, null, null, null, null, null, null, null, -
gabrielflorit revised this gist
Jan 12, 2019 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -83,7 +83,7 @@ const initialActors = [ name: 'smallcloud', x: 20, y: 32, dx: -1/32, mode: 'drift', counter: 0, flip: false @@ -292,6 +292,7 @@ const moveClouds = state => { cloud.x += cloud.dx if (cloud.x < -15) { cloud.x = 127 cloud.y = random(6, 54) } } -
gabrielflorit revised this gist
Jan 12, 2019 . 1 changed file with 10 additions and 20 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -289,26 +289,10 @@ const moveClouds = state => { const cloud = state.actors.find(d => d.name === 'smallcloud') const mario = state.actors.find(d => d.name === 'mario') cloud.x += cloud.dx if (cloud.x < -15) { cloud.x = 127 } } const moveMario = ({ state, input }) => { @@ -534,13 +518,19 @@ draw = state => { const cloud = state.actors.find(d => d.name === 'smallcloud') if (state.mode === 'play' || state.mode === 'death') { drawTopBar(state) camera(0) rectFill(0, 8, 128, 120, 6) drawActors({ actors: state.actors.filter(d => d.name === 'smallcloud') }) const cameraX = floor((mario.x + 4) / 128) * 128 camera(cameraX) map(floor(cameraX / 8), 0) drawActors({ actors: state.actors.filter(d => d.name !== 'smallcloud') }) } if (state.mode === 'preplay') { drawLivesScreen(state) -
gabrielflorit revised this gist
Jan 11, 2019 . 1 changed file with 7 additions and 4 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -291,19 +291,22 @@ const moveClouds = state => { const cameraX = floor((mario.x + 4) / 128) * 128 cloud.x = cloud.x % 128 log(`after modulus: ${cloud.x}`) cloud.x += cloud.dx log(`after move: ${cloud.x}`) if (cloud.x < -15) { cloud.x = 127 } else { } // log({ cloudX: cloud.x, cameraX }) cloud.x += cameraX log(`after cameraX: ${cloud.x}`) // cloud.y = random(6, 54) // cloud.x += cameraX } @@ -537,7 +540,7 @@ draw = state => { map(floor(cameraX / 8), 0) drawActors(state) log(`when drawn: ${cloud.x}`) } if (state.mode === 'preplay') { drawLivesScreen(state) -
gabrielflorit revised this gist
Jan 11, 2019 . 1 changed file with 7 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -83,7 +83,7 @@ const initialActors = [ name: 'smallcloud', x: 20, y: 32, dx: -1, mode: 'drift', counter: 0, flip: false @@ -291,14 +291,16 @@ const moveClouds = state => { const cameraX = floor((mario.x + 4) / 128) * 128 cloud.x = cloud.x % 128 cloud.x += cloud.dx if (cloud.x < -32) { cloud.x = 127 } else { } // log({ cloudX: cloud.x, cameraX }) cloud.x += cameraX @@ -526,13 +528,16 @@ const drawLivesScreen = state => { draw = state => { const mario = state.actors.find(d => d.name === 'mario') const cloud = state.actors.find(d => d.name === 'smallcloud') if (state.mode === 'play' || state.mode === 'death') { drawTopBar(state) const cameraX = floor((mario.x + 4) / 128) * 128 camera(cameraX) rectFill(cameraX, 8, 128, 120, 6) map(floor(cameraX / 8), 0) drawActors(state) log(`cloud.x when drawn: ${cloud.x}`) } if (state.mode === 'preplay') { drawLivesScreen(state) -
gabrielflorit revised this gist
Jan 11, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -291,7 +291,7 @@ const moveClouds = state => { const cameraX = floor((mario.x + 4) / 128) * 128 log({ cloudX: cloud.x, cameraX }) cloud.x = cloud.x % 128 cloud.x += cloud.dx -
gabrielflorit revised this gist
Jan 11, 2019 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -291,6 +291,8 @@ const moveClouds = state => { const cameraX = floor((mario.x + 4) / 128) * 128 // log({ cloudX: cloud.x, cameraX }) cloud.x = cloud.x % 128 cloud.x += cloud.dx if (cloud.x < -32) { -
gabrielflorit revised this gist
Jan 11, 2019 . 1 changed file with 6 additions and 7 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -291,17 +291,16 @@ const moveClouds = state => { const cameraX = floor((mario.x + 4) / 128) * 128 cloud.x = cloud.x % 128 cloud.x += cloud.dx if (cloud.x < -32) { cloud.x = 127 } else { } cloud.x += cameraX // cloud.y = random(6, 54) // cloud.x += cameraX } -
gabrielflorit revised this gist
Jan 11, 2019 . 1 changed file with 20 additions and 9 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -286,12 +286,23 @@ const collideWithEnemies = ({ state }) => { } const moveClouds = state => { const cloud = state.actors.find(d => d.name === 'smallcloud') const mario = state.actors.find(d => d.name === 'mario') const cameraX = floor((mario.x + 4) / 128) * 128 // First, normalize. // log({ x: cloud.x, cameraX }) cloud.x = cloud.x % 128 cloud.x += cameraX // cloud.x += cloud.dx // if (cloud.x < -32) { // cloud.x = 128 // cloud.y = random(6, 54) // } // cloud.x += cameraX } const moveMario = ({ state, input }) => { @@ -429,14 +440,14 @@ update = (state, input, elapsed) => { if (state.mode === 'play') { state.elapsed += elapsed state.counter++ moveEnemies(state) moveMario({ state, input }) collideWithEnemies({ state }) moveClouds(state) } else if (state.mode === 'death') { state.counter++ moveMario({ state, input }) moveClouds(state) } else if (state.mode === 'preplay') { if (state.counter++ > 60 * 2) { state.mode = 'play' @@ -448,8 +459,8 @@ update = (state, input, elapsed) => { } } else if (state.mode === 'title') { state.counter++ moveMario({ state, input: {} }) moveClouds(state) if (input.left || input.right || input.a) { state.counter = 0 state.lives = 3 -
gabrielflorit revised this gist
Jan 11, 2019 . 1 changed file with 0 additions and 3 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -78,9 +78,6 @@ const fsm = new StateMachine({ ] }) const initialActors = [ { name: 'smallcloud', -
gabrielflorit revised this gist
Jan 11, 2019 . 1 changed file with 6 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -85,8 +85,8 @@ const initialActors = [ { name: 'smallcloud', x: 20, y: 32, dx: -1/4, mode: 'drift', counter: 0, flip: false @@ -291,6 +291,10 @@ const collideWithEnemies = ({ state }) => { const moveClouds = state => { const smallcloud = state.actors.find(d => d.name === 'smallcloud') smallcloud.x += smallcloud.dx if (smallcloud.x < -32) { smallcloud.x = 128 smallcloud.y = random(6, 54) } } const moveMario = ({ state, input }) => { -
gabrielflorit revised this gist
Jan 11, 2019 . 1 changed file with 8 additions and 8 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -148,8 +148,8 @@ null, null, null, null, null, null, null, null, @@ -269,17 +269,17 @@ null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, @@ -399,8 +399,8 @@ null, null, null, null, null, null, null, null, -
gabrielflorit revised this gist
Jan 11, 2019 . 1 changed file with 46 additions and 44 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ // title: los hermanos bros. const { PI, atan2, ceil, floor, min, max, sign, abs, round } = Math const rad2Deg = ø => (ø * 180) / PI const spriteSprite = (a, b) => { const r1RightEdgePastR2Left = a.x + 8 >= b.x @@ -55,7 +55,7 @@ const sprites = { }, smallcloud: { drift: [[[39, 41], [55, 57]]] } } const fsm = new StateMachine({ @@ -81,13 +81,12 @@ const fsm = new StateMachine({ // const cycle = sprites[actor.name][actor.mode] // sprite(actor.x, actor.y, cycle[actor.counter % cycle.length], 0, actor.flip) const initialActors = [ { name: 'smallcloud', x: 20, y: 20, dx: -1/30, mode: 'drift', counter: 0, flip: false @@ -257,37 +256,43 @@ const collideWithEnemies = ({ state }) => { // Check if we're colliding with an enemy. enemies.forEach(d => { d.instances .filter(d => !d.remove) .forEach(actor => { const collision = spriteSprite(mario, actor) if (collision) { if (collision === 'top') { state.score += 100 actor.remove = true if (fsm.can('bounce')) { playPhrase(61) fsm.bounce() mario.dy -= e.mario.bounceBonus / 100 } } else { // Handle touching an enemy, which at the moment means: // setting game mode to death, // decreasing lives, // and launching mario in the air. if (fsm.can('touchEnemy')) { fsm.touchEnemy() state.mode = 'death' --state.lives mario.dy = -e.mario.maxDy playSong(1) } } } }) }) } const moveClouds = state => { const smallcloud = state.actors.find(d => d.name === 'smallcloud') smallcloud.x += smallcloud.dx } const moveMario = ({ state, input }) => { const mario = state.actors.find(d => d.name === 'mario') @@ -423,23 +428,26 @@ update = (state, input, elapsed) => { if (state.mode === 'play') { state.elapsed += elapsed state.counter++ moveClouds(state) moveEnemies(state) moveMario({ state, input }) collideWithEnemies({ state }) } else if (state.mode === 'death') { state.counter++ moveClouds(state) moveMario({ state, input }) } else if (state.mode === 'preplay') { if (state.counter++ > 60 * 2) { state.mode = 'play' playSong(0, true) } } else if (state.mode === 'gameover') { if (state.counter++ > 60 * 3) { state.mode = 'title' } } else if (state.mode === 'title') { state.counter++ moveClouds(state) moveMario({ state, input: {} }) if (input.left || input.right || input.a) { state.counter = 0 @@ -452,12 +460,14 @@ update = (state, input, elapsed) => { drawActors = (state, fade) => { state.actors.forEach(actor => { if (actor.instances) { actor.instances .filter(d => !d.remove) .forEach(d => { drawActor({ ...d, name: actor.name }) }) } else { drawActor(actor) } @@ -467,14 +477,6 @@ drawActors = (state, fade) => { const drawActor = actor => { const cycle = sprites[actor.name][actor.mode] const step = cycle[actor.counter % cycle.length] if (Array.isArray(step)) { // Here, step is a grid. Let's go over each entry. step.forEach((row, rowIndex) => { -
gabrielflorit revised this gist
Jan 11, 2019 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -54,7 +54,7 @@ const sprites = { walk: [13, 14] }, smallcloud: { drift: [[[39, 41], [55, 57]]] }, } @@ -87,6 +87,7 @@ const initialActors = [ name: 'smallcloud', x: 20, y: 20, dx: 1, mode: 'drift', counter: 0, flip: false -
gabrielflorit revised this gist
Jan 11, 2019 . 1 changed file with 19 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -54,7 +54,7 @@ const sprites = { walk: [13, 14] }, smallcloud: { drift: [[[40, 41]]] }, } @@ -466,7 +466,24 @@ drawActors = (state, fade) => { const drawActor = actor => { const cycle = sprites[actor.name][actor.mode] const step = cycle[actor.counter % cycle.length] // [ // [ a, b ], // [ c, d ] // ] // drift: // [ // [40, 41] // ] if (Array.isArray(step)) { // Here, step is a grid. Let's go over each entry. step.forEach((row, rowIndex) => { row.forEach((cell, col) => { sprite(actor.x + 8 * col, actor.y + 8 * rowIndex, cell, 0, actor.flip) }) }) } else { sprite(actor.x, actor.y, step, 0, actor.flip) } } const drawTopBar = state => { -
gabrielflorit revised this gist
Jan 11, 2019 . 1 changed file with 2 additions and 5 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -87,7 +87,6 @@ const initialActors = [ name: 'smallcloud', x: 20, y: 20, mode: 'drift', counter: 0, flip: false @@ -99,7 +98,6 @@ const initialActors = [ y: 104, dx: 0, dy: 0, mode: 'idle', flip: false, isOnGround: true @@ -113,7 +111,6 @@ const initialActors = [ y: 104, dx: 0, marioX: 120, counter: 0, mode: 'walk', flip: true @@ -123,7 +120,6 @@ const initialActors = [ y: 104, dx: 0, marioX: 256, counter: 0, mode: 'walk', flip: true @@ -469,7 +465,8 @@ drawActors = (state, fade) => { const drawActor = actor => { const cycle = sprites[actor.name][actor.mode] const step = cycle[actor.counter % cycle.length] sprite(actor.x, actor.y, step, 0, actor.flip) } const drawTopBar = state => { -
gabrielflorit revised this gist
Jan 11, 2019 . 1 changed file with 15 additions and 5 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -52,7 +52,10 @@ const sprites = { goomba: { idle: [...range(21).map(d => 11), 12], walk: [13, 14] }, smallcloud: { drift: [40] }, } const fsm = new StateMachine({ @@ -75,12 +78,19 @@ const fsm = new StateMachine({ ] }) // const cycle = sprites[actor.name][actor.mode] // sprite(actor.x, actor.y, cycle[actor.counter % cycle.length], 0, actor.flip) const initialActors = [ { name: 'smallcloud', x: 20, y: 20, // sprite: 0, mode: 'drift', counter: 0, flip: false }, { name: 'mario', @@ -89,7 +99,7 @@ const initialActors = [ y: 104, dx: 0, dy: 0, // sprite: 0, mode: 'idle', flip: false, isOnGround: true @@ -103,7 +113,7 @@ const initialActors = [ y: 104, dx: 0, marioX: 120, // sprite: 0, counter: 0, mode: 'walk', flip: true @@ -113,7 +123,7 @@ const initialActors = [ y: 104, dx: 0, marioX: 256, // sprite: 0, counter: 0, mode: 'walk', flip: true
NewerOlder