//// project #1: Helix follows mouse, Zeus chases him! //// Jared Paulson, CST 112, 2015 Feb 2 // Global DECLARATIONS // float monsterX, monsterY; float heroX, heroY; float horizon, sunX, sunY; //++++ ADD DECLARATIONS HERE ++++// void setup() { //// Setup: window size, etc. //// size( 640, 480 ); frameRate( 60 ); horizon= height/4; sunY= horizon/2; sunX= width/4; monsterX= width-100; monsterY= height-50; } void draw() { //// Next Frame //// scene(); hero(); monster(); } void scene() { //// Scene: sky, sun, grass. background( 200, 220, 255 ); // Light blue sky. sun(); // Grass fill( 200,255,200 ); rectMode( CORNER ); rect( 0,horizon, width, height*3/4 ); house(); //// Title, name, etc. fill(0); textSize( 20 ); text( "Zeus chases Helix until the end of time!", width/3, 20 ); textSize(12); text( "Jared Paulson, CST 112, 2015 Feb 2", 20, height-20 ); } void sun() { // Sun moves slowly to the right. sunX= sunX + 1; sunX= sunX % width; sunY= horizon - 100*sin( PI * sunX/width ); // Rise and set fill( 255,200,0); ellipse(sunX, sunY, 50,50 ); fill(0); text( sunX, 20,20 ); text( sunY, 20 ,30 ); } void house(){ //House float houseX, houseY; houseX= width*2/3; houseY=horizon-60; fill( 0,0,255 ); noStroke(); rectMode( CORNER ); rect( houseX, houseY, 100, 60 ); triangle( houseX, houseY, houseX+100, houseY, houseX+50, houseY-25 ); stroke(0); // Windows & door fill(255); rect( houseX+5, horizon-50, 20, 30); rect( houseX+75, horizon-50, 20, 30); rect( houseX+40, horizon-50, 20, 50 ); } void monster() { /// move and draw monster "Zeus". /// // +++++ STUB monsterX= monsterX + (heroX-monsterX) / 30; monsterY= monsterY + (heroY-monsterY) / 30; monsterY= monsterY