//Tristan Szakacs //Project one float creatureX; float creatureY; float stalkerX, stalkerY; float horizon; float sunX, sunY; color night = color( 255); color day = color( 200, 200, 0); float birbX, birbY; float x = 100; float y = 0; float speed = 0; float gravity = 0.1; void setup() { size(500, 500); horizon = height/4; } void draw() { sky(); sun(); grass(); house(); tree(); creature1(); stalker(); birb(); if( keyPressed ){ if( key == 'b' || key == 'B') { missile(); } } } //Method to create the sky. void sky() { if( sunX < (width * 0.65)) background( 50, 100, 200); if( sunX > (width * 0.65)) background(50, 100, 125); } //Method to create the Sun. void sun() { ellipseMode(CENTER); fill( day); ellipse( (float) sunX, sunY, 90, 90); sunX= (sunX + 1) % (width+100)-0.5; sunY= horizon-20 - 0.75 * horizon * sin( PI * sunX/width ); stroke(1); if( sunX > (width * 0.65)) day = night; if( sunX < (width * 0.65)) day = color(200, 200, 0); } void house() { rectMode(CENTER); fill(175, 100, 0); rect(250, 225, 100, 100); fill(0); triangle(175, 200, 250, 100, 325, 200); //Pathway to house. rectMode(CENTER); fill(30); rect( 250, 400, 40, 250); } void tree() { //Creates tree, and sets color. rectMode(CENTER); ellipseMode(CENTER); fill(125, 20, 0); rect(125, 225, 40, 90); fill( 0, 127, 0); ellipse( 125, 180, 90, 90); } void grass() { rectMode(CENTER); fill(0, 127, 0); rect(250, 500, 500, 500); } //Method to create creature 1. void creature1() { creatureX = creatureX + (mouseX-creatureX) / 10; creatureY = creatureY + (mouseY-creatureY) / 20; fill(250); ellipse( creatureX, creatureY-30, 50, 50); line( creatureX, creatureY-10, creatureX, creatureY+75); line( creatureX, creatureY+75, creatureX+10, creatureY+90); line( creatureX, creatureY+75, creatureX-10, creatureY+90); } //Creature 2. void stalker() { stalkerX = stalkerX + (creatureX-stalkerX) / 40; stalkerY = stalkerY + (creatureY-stalkerY) / 60; fill(75); ellipseMode(CENTER); rect( stalkerX, stalkerY, 25, 90); ellipse( stalkerX, stalkerY-30, 50, 50); line( stalkerX, stalkerY+40, stalkerX+10, stalkerY+60); line( stalkerX, stalkerY+40, stalkerX-10, stalkerY+60); } void birb() { triangle( (float) birbX, birbY + 5, birbX, birbY + 20, birbX - 20, birbY + 5); birbX = (birbX - 2) % width; if ( birbX < 0) { birbX = 500; } } void missile() { rect(birbX,y,10, 10); y = y + speed; speed = speed + gravity; if ( y > height) { speed = speed * -0.75; } }