Skip to content

Commit

Permalink
deploy: 40c2eea
Browse files Browse the repository at this point in the history
  • Loading branch information
NicholasRamos5 committed Jul 10, 2023
1 parent a73665b commit ffba252
Show file tree
Hide file tree
Showing 4 changed files with 169 additions and 8 deletions.
10 changes: 5 additions & 5 deletions assets/css/style.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion assets/js/search-data.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

"post0": {
"title": "Mario Lesson",
"content": "%%html <style> #canvas { margin: 0; border: 1px solid black; } </style> <canvas id="canvas"></canvas> <script> const canvas = document.getElementById('canvas'); const c = canvas.getContext('2d'); canvas.width = 770; canvas.height = 300; const gravity = 1.5; class Player { constructor() { this.position = { x: 100, y: 100 }; this.velocity = { x: 0, y: 0 }; this.width = 30; this.height = 30; } draw() { c.fillStyle = 'red'; c.fillRect(this.position.x, this.position.y, this.width, this.height); } update() { this.draw(); this.position.y += this.velocity.y; this.position.x += this.velocity.x; if (this.position.y + this.height + this.velocity.y <= canvas.height) this.velocity.y += gravity; else this.velocity.y = 0; } } const player = new Player(); const keys = { right: { pressed: false }, left: { pressed: false } }; function animate() { requestAnimationFrame(animate); c.clearRect(0, 0, canvas.width, canvas.height); player.update(); if (keys.right.pressed) { player.velocity.x = 15; } else if (keys.left.pressed) { player.velocity.x = -15; } else { player.velocity.x = 0; } } animate(); addEventListener('keydown', ({ keyCode }) => { switch (keyCode) { case 65: console.log('left'); keys.left.pressed = true; break; case 83: console.log('down'); break; case 68: console.log('right'); keys.right.pressed = true; break; case 87: console.log('up'); player.velocity.y -= 20; break; } }); addEventListener('keyup', ({ keyCode }) => { switch (keyCode) { case 65: console.log('left'); keys.left.pressed = false; break; case 83: console.log('down'); break; case 68: console.log('right'); keys.right.pressed = false; break; case 87: console.log('up'); player.velocity.y -= 20; break; } }); </script> . %%html <style> #canvas1 { margin: 0; border: 1px solid black; } </style> <canvas id="canvas1"></canvas> <script> const canvas1 = document.getElementById('canvas1'); const c1 = canvas1.getContext('2d'); canvas1.width = 770; canvas1.height = 300; const gravity1 = 1.5; class Player1 { constructor() { this.position = { x: 100, y: 100 }; this.velocity = { x: 0, y: 0 }; this.width = 30; this.height = 30; } draw() { c1.fillStyle = 'red'; c1.fillRect(this.position.x, this.position.y, this.width, this.height); } update() { this.draw(); this.position.y += this.velocity.y; this.position.x += this.velocity.x; if (this.position.y + this.height + this.velocity.y <= canvas1.height) this.velocity.y += gravity1; else this.velocity.y = 0; } } class Platform { constructor(image) { this.position = { x: 0, y: 200 } this.image = image; this.width = 540; this.height = 160; } draw() { c1.drawImage(this.image, this.position.x, this.position.y); } } let image = new Image(); image.onload = function() { const player1 = new Player1(); const platform = new Platform(image); const keys1 = { right: { pressed: false }, left: { pressed: false } }; function animate1() { requestAnimationFrame(animate1); c1.clearRect(0, 0, canvas1.width, canvas1.height); player1.update(); platform.draw(); if (keys1.right.pressed) { player1.velocity.x = 5; } else if (keys1.left.pressed) { player1.velocity.x = -5; } else { player1.velocity.x = 0; } if ( player1.position.y + player1.height <= platform.position.y && player1.position.y + player1.height + player1.velocity.y >= platform.position.y && player1.position.x + player1.width >= platform.position.x && player1.position.x <= platform.position.x + platform.width ) { player1.velocity.y = 0; } } animate1(); addEventListener('keydown', ({ keyCode }) => { switch (keyCode) { case 65: console.log('left'); keys1.left.pressed = true; break; case 83: console.log('down'); break; case 68: console.log('right'); keys1.right.pressed = true; break; case 87: console.log('up'); player1.velocity.y -= 20; break; } }); addEventListener('keyup', ({ keyCode }) => { switch (keyCode) { case 65: console.log('left'); keys1.left.pressed = false; break; case 83: console.log('down'); break; case 68: console.log('right'); keys1.right.pressed = false; break; case 87: console.log('up'); player1.velocity.y -= 20; break; } }); }; image.src = 'https://samayass.github.io/samayaCSA/images/platform.png'; </script> . -a . %%html <style> #canvas1 { margin: 0; border: 1px solid black; } </style> <canvas id="canvas1"></canvas> <script> const canvas1 = document.getElementById('canvas1'); const c1 = canvas1.getContext('2d'); canvas1.width = 770; canvas1.height = 300; const gravity1 = 1.5; class Player1 { constructor() { this.position = { x: 100, y: 100 }; this.velocity = { x: 0, y: 0 }; this.width = 30; this.height = 30; } draw() { c1.fillStyle = 'red'; c1.fillRect(this.position.x, this.position.y, this.width, this.height); } update() { this.draw(); this.position.y += this.velocity.y; this.position.x += this.velocity.x; if (this.position.y + this.height + this.velocity.y <= canvas1.height) this.velocity.y += gravity1; else this.velocity.y = 0; } } class Platform { constructor(image) { this.position = { x: 0, y: 200 } this.image = image; this.width = 540; this.height = 160; } draw() { c1.drawImage(this.image, this.position.x, this.position.y); } } class Tube { constructor( { x, y, image} ) { this.position = { x, y } this.image = image this.width = 175 this.height = 200 this.velocity = { x: 0 } } draw() { c.drawImage(this.image, this.position.x, this.position.y, this.width, this.height) } # update() { # this.position.x += this.velocity.x # this.draw() # } } let image = new Image(); image.onload = function() { const player1 = new Player1(); const platform = new Platform(image); const tube = new Tube( {x: 10, y: 10, image: image} ) const keys1 = { right: { pressed: false }, left: { pressed: false } }; function animate1() { requestAnimationFrame(animate1); c1.clearRect(0, 0, canvas1.width, canvas1.height); player1.update(); platform.draw(); tube.draw(); if (keys1.right.pressed) { player1.velocity.x = 5; } else if (keys1.left.pressed) { player1.velocity.x = -5; } else { player1.velocity.x = 0; } if ( player1.position.y + player1.height <= platform.position.y && player1.position.y + player1.height + player1.velocity.y >= platform.position.y && player1.position.x + player1.width >= platform.position.x && player1.position.x <= platform.position.x + platform.width ) { player1.velocity.y = 0; } } animate1(); addEventListener('keydown', ({ keyCode }) => { switch (keyCode) { case 65: console.log('left'); keys1.left.pressed = true; break; case 83: console.log('down'); break; case 68: console.log('right'); keys1.right.pressed = true; break; case 87: console.log('up'); player1.velocity.y -= 20; break; } }); addEventListener('keyup', ({ keyCode }) => { switch (keyCode) { case 65: console.log('left'); keys1.left.pressed = false; break; case 83: console.log('down'); break; case 68: console.log('right'); keys1.right.pressed = false; break; case 87: console.log('up'); player1.velocity.y -= 20; break; } }); }; image.src = 'https://samayass.github.io/samayaCSA/images/platform.png'; </script> .",
"content": "%%html <style> #canvas { margin: 0; border: 1px solid black; } </style> <canvas id="canvas"></canvas> <script> const canvas = document.getElementById('canvas'); const c = canvas.getContext('2d'); canvas.width = 770; canvas.height = 300; const gravity = 1.5; class Player { constructor() { this.position = { x: 100, y: 100 }; this.velocity = { x: 0, y: 0 }; this.width = 30; this.height = 30; } draw() { c.fillStyle = 'red'; c.fillRect(this.position.x, this.position.y, this.width, this.height); } update() { this.draw(); this.position.y += this.velocity.y; this.position.x += this.velocity.x; if (this.position.y + this.height + this.velocity.y <= canvas.height) this.velocity.y += gravity; else this.velocity.y = 0; } } const player = new Player(); const keys = { right: { pressed: false }, left: { pressed: false } }; function animate() { requestAnimationFrame(animate); c.clearRect(0, 0, canvas.width, canvas.height); player.update(); if (keys.right.pressed) { player.velocity.x = 15; } else if (keys.left.pressed) { player.velocity.x = -15; } else { player.velocity.x = 0; } } animate(); addEventListener('keydown', ({ keyCode }) => { switch (keyCode) { case 65: console.log('left'); keys.left.pressed = true; break; case 83: console.log('down'); break; case 68: console.log('right'); keys.right.pressed = true; break; case 87: console.log('up'); player.velocity.y -= 20; break; } }); addEventListener('keyup', ({ keyCode }) => { switch (keyCode) { case 65: console.log('left'); keys.left.pressed = false; break; case 83: console.log('down'); break; case 68: console.log('right'); keys.right.pressed = false; break; case 87: console.log('up'); player.velocity.y -= 20; break; } }); </script> . %%html <style> #canvas1 { margin: 0; border: 1px solid black; } </style> <canvas id="canvas1"></canvas> <script> const canvas1 = document.getElementById('canvas1'); const c1 = canvas1.getContext('2d'); canvas1.width = 770; canvas1.height = 300; const gravity1 = 1.5; class Player1 { constructor() { this.position = { x: 100, y: 100 }; this.velocity = { x: 0, y: 0 }; this.width = 30; this.height = 30; } draw() { c1.fillStyle = 'red'; c1.fillRect(this.position.x, this.position.y, this.width, this.height); } update() { this.draw(); this.position.y += this.velocity.y; this.position.x += this.velocity.x; if (this.position.y + this.height + this.velocity.y <= canvas1.height) this.velocity.y += gravity1; else this.velocity.y = 0; } } class Platform { constructor(image) { this.position = { x: 0, y: 200 } this.image = image; this.width = 540; this.height = 160; } draw() { c1.drawImage(this.image, this.position.x, this.position.y); } } let image = new Image(); image.onload = function() { const player1 = new Player1(); const platform = new Platform(image); const keys1 = { right: { pressed: false }, left: { pressed: false } }; function animate1() { requestAnimationFrame(animate1); c1.clearRect(0, 0, canvas1.width, canvas1.height); player1.update(); platform.draw(); if (keys1.right.pressed) { player1.velocity.x = 5; } else if (keys1.left.pressed) { player1.velocity.x = -5; } else { player1.velocity.x = 0; } if ( player1.position.y + player1.height <= platform.position.y && player1.position.y + player1.height + player1.velocity.y >= platform.position.y && player1.position.x + player1.width >= platform.position.x && player1.position.x <= platform.position.x + platform.width ) { player1.velocity.y = 0; } } animate1(); addEventListener('keydown', ({ keyCode }) => { switch (keyCode) { case 65: console.log('left'); keys1.left.pressed = true; break; case 83: console.log('down'); break; case 68: console.log('right'); keys1.right.pressed = true; break; case 87: console.log('up'); player1.velocity.y -= 20; break; } }); addEventListener('keyup', ({ keyCode }) => { switch (keyCode) { case 65: console.log('left'); keys1.left.pressed = false; break; case 83: console.log('down'); break; case 68: console.log('right'); keys1.right.pressed = false; break; case 87: console.log('up'); player1.velocity.y -= 20; break; } }); }; image.src = 'https://samayass.github.io/samayaCSA/images/platform.png'; </script> . -a . %%html <style> #canvas1 { margin: 0; border: 1px solid black; } </style> <canvas id="canvas1"></canvas> <script> const canvas1 = document.getElementById('canvas1'); const c1 = canvas1.getContext('2d'); canvas1.width = 770; canvas1.height = 300; const gravity1 = 1.5; class Player1 { constructor() { this.position = { x: 100, y: 100 }; this.velocity = { x: 0, y: 0 }; this.width = 30; this.height = 30; } draw() { c1.fillStyle = 'red'; c1.fillRect(this.position.x, this.position.y, this.width, this.height); } update() { this.draw(); this.position.y += this.velocity.y; this.position.x += this.velocity.x; if (this.position.y + this.height + this.velocity.y <= canvas1.height) this.velocity.y += gravity1; else this.velocity.y = 0; } } class Platform { constructor(image) { this.position = { x: 0, y: 200 } this.image = image; this.width = 540; this.height = 160; } draw() { c1.drawImage(this.image, this.position.x, this.position.y); } } class Tube { constructor( { x, y, image} ) { this.position = { x, y } this.image = image this.width = 175 this.height = 200 this.velocity = { x: 0 } } draw() { c.drawImage(this.image, this.position.x, this.position.y, this.width, this.height) } # update() { # this.position.x += this.velocity.x # this.draw() # } } let image = new Image(); image.onload = function() { const player1 = new Player1(); const platform = new Platform(image); const tube = new Tube( {x: 10, y: 10, image: image} ) const keys1 = { right: { pressed: false }, left: { pressed: false } }; function animate1() { requestAnimationFrame(animate1); c1.clearRect(0, 0, canvas1.width, canvas1.height); player1.update(); platform.draw(); tube.draw(); if (keys1.right.pressed) { player1.velocity.x = 5; } else if (keys1.left.pressed) { player1.velocity.x = -5; } else { player1.velocity.x = 0; } if ( player1.position.y + player1.height <= platform.position.y && player1.position.y + player1.height + player1.velocity.y >= platform.position.y && player1.position.x + player1.width >= platform.position.x && player1.position.x <= platform.position.x + platform.width ) { player1.velocity.y = 0; } } animate1(); addEventListener('keydown', ({ keyCode }) => { switch (keyCode) { case 65: console.log('left'); keys1.left.pressed = true; break; case 83: console.log('down'); break; case 68: console.log('right'); keys1.right.pressed = true; break; case 87: console.log('up'); player1.velocity.y -= 20; break; } }); addEventListener('keyup', ({ keyCode }) => { switch (keyCode) { case 65: console.log('left'); keys1.left.pressed = false; break; case 83: console.log('down'); break; case 68: console.log('right'); keys1.right.pressed = false; break; case 87: console.log('up'); player1.velocity.y -= 20; break; } }); }; image.src = 'https://samayass.github.io/samayaCSA/images/platform.png'; </script> . okay okay okay okay . %%html <style> #canvas1 { margin: 0; border: 1px solid black; } </style> <canvas id="canvas1"></canvas> <script> const canvas1 = document.getElementById('canvas1'); const c1 = canvas1.getContext('2d'); canvas1.width = 770; canvas1.height = 300; const gravity1 = 1.5; class Player1 { constructor() { this.position = { x: 100, y: 100 }; this.velocity = { x: 0, y: 0 }; this.width = 30; this.height = 30; } draw() { c1.fillStyle = 'red'; c1.fillRect(this.position.x, this.position.y, this.width, this.height); } update() { this.draw(); this.position.y += this.velocity.y; this.position.x += this.velocity.x; if (this.position.y + this.height + this.velocity.y <= canvas1.height) this.velocity.y += gravity1; else this.velocity.y = 0; } } class Platform { constructor(image) { this.position = { x: 0, y: 200 } this.image = image; this.width = 540; this.height = 160; } draw() { c1.drawImage(this.image, this.position.x, this.position.y); } } let image = new Image(); image.onload = function() { const player1 = new Player1(); const platform = new Platform(image); const keys1 = { right: { pressed: false }, left: { pressed: false } }; function animate1() { requestAnimationFrame(animate1); c1.clearRect(0, 0, canvas1.width, canvas1.height); player1.update(); platform.draw(); if (keys1.right.pressed) { player1.velocity.x = 5; } else if (keys1.left.pressed) { player1.velocity.x = -5; } else { player1.velocity.x = 0; } if ( player1.position.y + player1.height <= platform.position.y && player1.position.y + player1.height + player1.velocity.y >= platform.position.y && player1.position.x + player1.width >= platform.position.x && player1.position.x <= platform.position.x + platform.width ) { player1.velocity.y = 0; } } animate1(); addEventListener('keydown', ({ keyCode }) => { switch (keyCode) { case 65: console.log('left'); keys1.left.pressed = true; break; case 83: console.log('down'); break; case 68: console.log('right'); keys1.right.pressed = true; break; case 87: console.log('up'); player1.velocity.y -= 20; break; } }); addEventListener('keyup', ({ keyCode }) => { switch (keyCode) { case 65: console.log('left'); keys1.left.pressed = false; break; case 83: console.log('down'); break; case 68: console.log('right'); keys1.right.pressed = false; break; case 87: console.log('up'); player1.velocity.y -= 20; break; } }); }; image.src = 'https://samayass.github.io/samayaCSA/images/platform.png'; </script> .",
"url": "https://nicholasramos5.github.io/VSCodings/college%20board/java/2023/06/13/Mario.html",
"relUrl": "/college%20board/java/2023/06/13/Mario.html",
"date": " • Jun 13, 2023"
Expand Down
Loading

0 comments on commit ffba252

Please sign in to comment.