function setup() {
createCanvas(windowWidth, windowHeight);
yCoordinatBold = 100;
ySpeedBold = 6;
windowWidth=650;
GreenBallHit = false
}
let img;
function preload(){
img = createImg('http://mpsteenstrup.dk/FN_maal/FN10.jpg','');
img.hide();
}
function draw() {
background(91,146,229);
image(img,mouseX,mouseY,80,80)
fill(200,0,0)
ellipse(400,yCoordinatBold,200,200);
textSize(30,30)
text("hej",400,200)
// Græsplænen
fill(100,200,80);
rect(0,750,1500,100);
// Cirkel, rød når ramt af mus
fill(0,200,0). // grøn
if(mouseX>300 && mouseX<500 && mouseY>300 && mouseY<500); {
fill(200,0,0) // rød hvid ramt af mus
}
ellipse(400,yCoordinatBold,200,200);
yCoordinatBold += ySpeedBold;
// Skift retning på cirkel , når den rammer grænserbne
if (yCoordinatBold>windowWidth || yCoordinatBold<0){
ySpeedBold = -ySpeedBold;
}
}
function mousePressed (){
if(mouseX>300 && mouseX<500 && mouseY>300 && mouseY<500){}
// } {
}
Comments