// Project 1 // Justin Gonzalez 9/12/14 int score=0 ; float horizon=600; float sunx=100 , suny=100; float jeffx=300 ,jeffy=300; float xerathx=400, xerathy=400; float cassx=200, cassy=200; float bobx=500, boby=500; float goldx=500, goldy=300; void setup(){ //setup// size(1300,900); horizon= height/4; suny= horizon/2; jeffx=width/2; jeffy= height/2; xerathx=30; } void draw(){ //next frame// scene(); hero(); monster(); scoring(); gold(); } void scene(){ //sky, sun ,etc background(100,180,255); fill(255,255,0); ellipse(sunx,suny,50,50); //sun sunx= sunx+2; //grass fill(0,255,0); rectMode(CORNER); rect(0,horizon,width,height*3/4); //grass fill(0); text("Score:" + score,1100,100); } void hero(){ //move and draw hero jeffx= jeffx + (goldx-jeffx) / 45; jeffy= jeffy + (goldy-jeffy) / 45; if (jeffy<=horizon) jeffy=horizon; //body of jeff fill(255,0,0); rectMode(CENTER); rect(jeffx,jeffy, 50,50); //head of jeff fill(255,127,0); ellipse(jeffx,jeffy-30,40,50); fill(0); text("Jeff",jeffx-20,jeffy+10); } void monster(){ ///chase jeff xerathx= xerathx+(jeffx-xerathx)/50; xerathy= xerathy+(jeffy-xerathy)/50; //draw Xerath //body of xerath fill(255,100,0); rectMode(CENTER); rect(xerathx,xerathy, 70,70); fill(0); text("Xerath",xerathx-20,xerathy+10); //head of xerath fill(255,127,0); ellipse(xerathx,xerathy-70/2,65,65); fill(255,255,155); ellipse(xerathx,xerathy-70/2,65/2,65/2); fill(0); ellipse(xerathx,xerathy-70/2,65/4,65/4); //cass ///chase jeff /* cassx= cassx+(jeffx-cassx)/60; cassy= cassy+(jeffy-cassy)/60; //draw cass //body of cass fill(255,0,255); rectMode(CENTER); rect(cassx,cassy, 70,70); fill(0); text("Cass",cassx-20,cassy+10); //head of cass fill(255,127,0); ellipse(cassx,cassy-70/2,65,65); fill(255,0,0); ellipse(cassx,cassy-70/2,65/2,65/2); fill(0); ellipse(cassx,cassy-70/2,65/4,65/4); //bob ///chase jeff bobx= bobx+(jeffx-bobx)/30; boby= boby+(jeffy-boby)/30; //draw bob //body of bob fill(255,200,0); rectMode(CENTER); rect(bobx,boby, 70,70); fill(0); text("Bob",bobx-20,boby+10); //head of bob fill(255,127,0); ellipse(bobx,boby-70/2,65,65); */ } void scoring(){ // determine how far the monster will be to eat hero if (sunx > width) {sunscore();} if(dist (xerathx,xerathy,jeffx,jeffy) <50) {eat();} } void mousePressed(){ //click goldx= mouseX; goldy=mouseY; } void eat(){ /*when the monster eats the hero subtract points amd characters return to their corners*/ score = score-50; jeffx=1300; xerathx=0; background(255,0,0); } void sunscore(){ // as the sun passes the width add points score=score+10; sunx=0; } void gold(){ //draw and place gold fill(255,205,0); ellipse(goldx,goldy,25,25); //gold scoring if(dist (goldx,goldy,jeffx,jeffy) <50) {goldscore();} } void goldscore(){ score=score+100; goldx=random(50,1250); goldy=random(horizon,850); jeffx=1300; xerathx=0; background(255,230,0); } void keyPressed(){ if (key=='q') exit(); //--if (key=='r') ; }