JS_Projects/dinosaurrGame/sketch.js

32 lines
518 B
JavaScript
Raw Permalink Normal View History

2022-11-09 23:34:49 +01:00
let player;
let vk = '0';
function setup() {
createCanvas(1920, 880);
textSize(width / 6);
textAlign(CENTER, CENTER);
fill(220);
background(51);
player = new Dinosaur(250, 350, 50, 50);
}
function draw() {
clear();
background(51);
checkClick();
if (player.lost == false)
player.update(vk);
else
text('LOST',width/2,height/4);
player.show();
}
function checkClick() {
vk = null;
if (keyIsDown(UP_ARROW)) {
vk = '1';
} else if (keyIsDown(DOWN_ARROW)) {
vk = '0';
}
}