xxxxxxxxxx
73
var y = 200;
var speed = 2;
var movex = 0;
var movey = - speed;
var counter = 0;
var lost = false;
var a = true;
var done = false;
var start = false;
var x,y;
var pikachu;
var pokemonBall;
function preload(){
pikachu = loadImage("pikachu.png");
pokemonBall = loadImage("Pokemon-Pokeball.png")
}
let clouds;
function setup() {
createCanvas(400, 400);
x = 200;
y = 200;
var ax = random(10,390);
var ay = random(10,390);
}
function draw() {
background(204,255,255);
noStroke();
fill(229,255,204);
rect(0, 350, 550, 105);
noStroke();
if(a == true){
if(done == false){
ax = random(10,390);
ay = random(10,390);
done = true;
}
image(pikachu,ax,ay,80,70);
}
fill(random(256),random(256),random(256))
image(pokemonBall,x,y,50,50);
if((ax-x<=20 && ax-x>=-20) && (ay-y<=20 && ay-y>=-20)){
done = false;
speed = speed + 0.333;
counter++;
}
x+=movex;
y+=movey;
if(keyIsDown(UP_ARROW)){
y = y - 5;
}
if(keyIsDown(DOWN_ARROW)){
y = y + 5;
}
if(keyIsDown(LEFT_ARROW)){
x = x - 5;
}
if(keyIsDown(RIGHT_ARROW)){
x = x + 5;
}
if (y>385) {
y = 385
}
if (y<15) {
y = 15
}
if (x<15) {
x = 15
}
if (x>385) {
x=385
}
}