How I resolved these issues:
- Library finding issue
I just copy the code from https://github.com/branchwelder/example-game/blob/main/index.html
- "npm run deploy" is not working
I delete the whole js.file and start to clone the new repository. Following the step from instructor to figure the issue.
- code from p5.editor to js file not working
I using the
window.draw = () =>
to replace the "function"
- canvas is little small
The code from https://workshops.hackclub.com/platformer/ is too small, so I use the windowWidth and windowHeight to create canvas.
- mario's Animation is not working
I upload 3 mario images to generate the animation and use:
window.preload = () => {
mario_running = loadAnimation("Capture1.png","Capture3.png","Capture4.png");
}
- "if (groundSprites.overlap(player))" not working
I create another function called "over":
function over(mario, groundSprites) {
mario.velocity.y = 0;
mario.position.y = height - 90;
}
and use "over" function in the overlap like:
mario.overlap(groundSprites, over)
- keyDown function not working
Instead of keydown, I start to use if statement like:
if (key == 'w') {
- obstacle occurs too often
Reading the https://workshops.hackclub.com/platformer/, use the if statement to set up:
if (random() > 0.98)
- Want obstacleSprites and groundSprites move from right to left when camera position moving
Using the for loop to change the position of obstacleSprites and groundSprites:
for (var i = 0; i < obstacleSprites.length; i++) {
obstacleSprites[i].position.x -= 5;
}
for (var i = 0; i < groundSprites.length; i++) {
groundSprites[i].position.x -= 5;
}
- Mario jump with incorrect gravity
Changing the keypress('w') to kb.presses('w') because kb.presses will only work at the moment of pressing the button
- mouseClicked Function is not working
I search online and find out the function which called "mouseIsPressed" and use it in draw(). Then, I change remove(obstacleSprites) to remove() and command original mouseClicked Function.