32 lines
518 B
JavaScript
32 lines
518 B
JavaScript
|
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';
|
||
|
}
|
||
|
}
|