Untitled
unknown
plain_text
3 years ago
1.6 kB
6
Indexable
// Suzdavame promenlivi
let myX, myY, brPl; //plX---- platformaX
let plX = [];
let plY = [];
function init() {
// Kodut tuk se izpulnqva vednuj v nachaloto
myX = 400;
myY = 300;
brPl=16;
for(tekushtaPlatforma=0; tekushtaPlatforma<brPl; tekushtaPlatforma++){
plX[tekushtaPlatforma] = randomInteger(710);
plY[tekushtaPlatforma] = 600+randomInteger(600);
}
}
function update() {
myY=myY+2
if(isKeyPressed[37]) {
myX=myX-2
}
if(isKeyPressed[39]) {
myX=myX+2
}
for(tekushtaPlatforma=0;tekushtaPlatforma<brPl;tekushtaPlatforma++){
plY[tekushtaPlatforma]=plY[tekushtaPlatforma]-2
if(areColliding(plX[tekushtaPlatforma], plY[tekushtaPlatforma], 90, 30, myX, myY, 90, 60)) {
myY=plY[tekushtaPlatforma]-60;
}
if(plY[tekushtaPlatforma]<0){
plX[tekushtaPlatforma]=randomInteger(710);
plY[tekushtaPlatforma]=600+randomInteger(250);
}
}
}
function draw() {
// Tuk naprogramirai kakvo da se risuva
drawImage(backStars, 0, 0, 800, 600);
drawImage(cat, myX, myY, 90, 60);
for(tekushtaPlatforma=0;tekushtaPlatforma<brPl;tekushtaPlatforma++){
drawImage(groundStone, plX[tekushtaPlatforma], plY[tekushtaPlatforma], 90, 30)
}
}
function mouseup() {
// Pri klik s lqv buton - pokaji koordinatite na mishkata
console.log("Mouse clicked at", mouseX, mouseY);
}
function keyup(key) {
// Pechatai koda na natisnatiq klavish
console.log("Pressed", key);
}Editor is loading...