Files
penguin-jump-p5js/sketch.js

49 lines
874 B
JavaScript
Raw Normal View History

2026-06-24 19:56:56 +03:00
const TEXT_SIZE = 12;
const CHARACTER_SIZE = 50;
var charimg;
function preload() {
charimg = loadImage('/penguin.png');
}
function setup() {
createCanvas(300, 600);
frameRate(60)
textSize(TEXT_SIZE)
textAlign(LEFT, TOP);
c.size = CHARACTER_SIZE;
c.pos.x = width / 2 - CHARACTER_SIZE / 2;
c.pos.y = height / 2 - CHARACTER_SIZE / 2;
c.img = charimg;
}
function draw() {
fill(0, 0, 0);
background(225);
text(`X/Y : ${mouseX}|${mouseY}`, 2, 2);
getPlatforms()
.forEach(p => {
p.step();
p.draw()
})
c.step(); // Run Logic
c.draw(); // Draw the character
}
function keyPressed() {
if (key === 'c') {
c.jump();
}
}
function mouseClicked() {
if (mouseButton === LEFT) {
spawnPlatform(mouseX, mouseY);
console.log(PLATFORMS_LIST)
}
}