// Rotating Sun float val; float sunX, sunY; float moonX, moonY; float SunSpeed = -0.003; // Rotating Moon float MoonSpeed = -0.003; // Spawn Coordinates int spawnX = 128; int spawnY = 150; // Sven (Character) float charX = spawnX; float charY = spawnY; float charSpeedx = 4; float charSpeedy = 2; int charDirectionx = 1; int charDirectiony = 1; // Harley (Bird) float birdX; float birdY; float birdeasing = 0.05; // Ghost (Monster) float monX; float monY; float easing = 0.005; void setup() { size(800,600); frameRate(60); } void draw() { scene(); spawnhouse(); ghost(); sven(); bird(); action(); } void scene() { background(#413BFF); stroke(0); // Sun sunX = sin(val); sunY = cos(val); sunX *= 400; sunY *= 200; sunX += width/2; sunY += height/2; fill(255, 255, 0); ellipse(sunX, sunY, 70, 70); val += SunSpeed; // Background Change if (sunY > 300) { background(#020B36); } // Moon moonX = -sin(val); moonY = -cos(val); moonX *= 400; moonY *= 200; moonX += width/2; moonY += height/2; fill(#EBF7B9); ellipse(moonX, moonY, 70, 70); val += MoonSpeed; // Foreground fill(#67C461); rect(0,200,width,height); fill(#67C461); } void spawnhouse() { // Body fill(255); rect(50,115,155,115); // Roof fill(255,0,0); triangle(45,120,125,50,210,120); // Door / Spawn fill(#5A3906); rect(113,170,30,60); } void ghost() { // HE IS *OFF* SCREEN fill(255); stroke(255); //monX = width+30; //monY = 0; float targetX = birdX; float dx = targetX - monX; monX += dx * easing; float targetY = birdY; float dy = targetY - monY; monY += dy * easing; rect(monX-30,monY,60,80); ellipse( monX, monY, 60,60); triangle(monX-30,monY+80,monX-10,monY+80,monX-20,monY+100); triangle(monX-10,monY+80,monX+10,monY+80,monX,monY+100); triangle(monX+10,monY+80,monX+30,monY+80,monX+20,monY+100); fill(255,0,0); ellipse(monX-15,monY,15,30); ellipse(monX+15,monY,15,30); if (sunY < 300){ easing = 0; }else{ easing = 0.005; } } void sven() { stroke(0); fill(#FAD9CC); // Head ellipse(charX, charY, 50, 50); // Body fill(#11F7DA); rect(charX - 20, charY + 25, 40, 70); // Left Arm line(charX-20, charY+25, charX-40, charY+85); // Right Arm line(charX+20, charY+25, charX+40, charY+85); // Left Eye fill(255); ellipse(charX-10, charY-5, 10, 15); fill(0); ellipse(charX-9, charY-5, 3, 3); // Right Eye fill(255); ellipse(charX+10, charY-5, 10, 15); fill(0); ellipse(charX+11, charY-5, 3, 3); } void bird() { // birdX = width/2; // birdY = height/2; float BtargetX = charX; float bdx = BtargetX - birdX; birdX += bdx * birdeasing; float BtargetY = charY; float bdy = BtargetY - birdY; birdY += bdy * birdeasing; // Body ellipse(birdX,birdY,40,20); // Head ellipse(birdX-20,birdY-2,20,18); // Beak fill(#D3783C); triangle(birdX-30,birdY-5,birdX-30,birdY-1,birdX-36,birdY+1); // Eye fill(255); ellipse(birdX-22,birdY-3,10,10); fill(0); ellipse(birdX-22,birdY-3,4,4); // Wing triangle(birdX-10,birdY-8,birdX+13,birdY-25,birdX+13,birdY-8); } void action() { // Character Declarations charX = charX + (charSpeedx * charDirectionx); charY = charY + (charSpeedy * charDirectiony); // Change X Direction if (charX > width-20 || charX < 20) { charDirectionx *= -1; } //Change y Direction if (charY < 150 || charY > height-60) { charDirectiony *= -1; } }