////////////////////////////////////// //globals so we know what page were on int startpage = 0; int gamepage =0; int moveme =0; int fillcol =255; //change the grey of the box here int alphafill =120; //change the alpha of the box here int boxx = 0; // where the box is int boxy =0; int counter =1; //every 50 loops increase baddy speed int baddyspeed =1; int count=1; // /////////////////////////////////////// //initialise classes Startscreen start = new Startscreen(); changestart startgame = new changestart(); gaming game = new gaming (); evilcircle baddy = new evilcircle (); evilcircle baddy2 = new evilcircle (); evilcircle baddy3 = new evilcircle (); evilcircle baddy4 = new evilcircle (); evilcircle baddy5 = new evilcircle (); evilcircle baddy6 = new evilcircle (); newlevel nextlevel = new newlevel (); // //////////////////////////////////////////////////////////////////////////////////////////////// // void setup(){ size (500,500); background (70); noStroke(); smooth(); start.begin(); } void draw (){ //the following all accept on or off commands, so moving the box can be turned on and off, the menu screen can be turned on and off...etc, etc startgame.waitformouse(startpage); game.start(gamepage); baddy.drawme(gamepage); game.movethebox(moveme); baddy.hurtme(moveme,boxx,boxy); nextlevel.increase(counter,count); if (nextlevel.imonlevel == 2){ baddy2.hurtme(moveme,boxx,boxy); } if (nextlevel.imonlevel == 3){ baddy2.hurtme(moveme,boxx,boxy); baddy3.hurtme(moveme,boxx,boxy); } if (nextlevel.imonlevel == 4){ baddy2.hurtme(moveme,boxx,boxy); baddy3.hurtme(moveme,boxx,boxy); baddy4.hurtme(moveme,boxx,boxy); } if (nextlevel.imonlevel == 5){ baddy2.hurtme(moveme,boxx,boxy); baddy3.hurtme(moveme,boxx,boxy); baddy4.hurtme(moveme,boxx,boxy); baddy5.hurtme(moveme,boxx,boxy); } if (nextlevel.imonlevel == 6){ baddy2.hurtme(moveme,boxx,boxy); baddy3.hurtme(moveme,boxx,boxy); baddy4.hurtme(moveme,boxx,boxy); baddy5.hurtme(moveme,boxx,boxy); baddy6.hurtme(moveme,boxx,boxy); } counter=counter+1;//resetable counter count = count+1;//nonresetable } // //////////////////////////////////////////////////////////////////////////////////////////////////// //classes class Startscreen { PImage myfont; //changed to image for web Startscreen () { } void begin() { fill(255); //myfont = createFont("Amerika", 30); //textFont(myfont); //text("Click me to start", 10, 50); myfont = loadImage("pic.gif"); image (myfont,0,0); startpage = 1; //tells the main code were on this page } void end (){ background (70); noLoop(); } } // /////////////////////////////////////// // class changestart { int change; changestart (){ } void waitformouse (int number){ change = number; if (change==1){ // println("waiting"); if((mousePressed == true)&&(mouseX>10)&&(mouseX<270)&&(mouseY>20)&&(mouseY<50)){ //roughly change = 0; startpage = 0; gamepage =1; background (70); //fill(255); //rect (width/2,width/2,width/2,width/2); //what you want to happen after menu 1 } } } } // //////////////////////////////////////// // class gaming { int changer; int positionx; int positiony; int moveaccept; gaming (){ } void start (int num2){ changer = num2; if (changer == 1){ positionx = positiony = (width/2)-5; fill(fillcol, alphafill); rect(positionx,positiony,10,10); changer = 0; //gamepage = 0; moveme =1; } } void movethebox (int num3){ moveaccept=num3; if (moveaccept == 1){ if (keyPressed == true) { if(key == CODED) { if (keyCode == UP) { background (70); if (positiony<10){ positiony = positiony; }else{ positiony = positiony - 10; } fill(fillcol, alphafill); rect(positionx,positiony,10,10); } if (keyCode == RIGHT) { background (70); if (positionx>width-20){ positionx = positionx; }else{ positionx = positionx + 10; } fill(fillcol, alphafill); rect(positionx,positiony,10,10); } if (keyCode == DOWN) { background (70); if (positiony>width-20){ positiony = positiony; }else{ positiony = positiony + 10; } fill(fillcol, alphafill); rect(positionx,positiony,10,10); } if (keyCode == LEFT) { background (70); if (positionx<10){ positionx = positionx; }else{ positionx = positionx - 10; } fill(fillcol, alphafill); rect(positionx,positiony,10,10); } boxx=positionx; boxy=positiony; } }else{//as in if keypressed isnt true background (70); fill(fillcol, alphafill); rect(positionx,positiony,10,10); } } }//end movethebox }//end class // ////////////////////////////////////////////////////// // class evilcircle { int xbox; int ybox; int moveaccept2; int drawer; int pos1; int pos2; int plusorminusx = 1; //this can be changed to -1 the make the evil box go in the other direction int plusorminusy = 1; float myrandomx; float myrandomy; int speed; evilcircle (){ myrandomx = random(450); myrandomy = random(450); int i = int(myrandomx); int j = int(myrandomy); pos1= i;//*10; pos2= j;//*10; //print("x = "); println(i); //print("Y = "); println(j); } void drawme (int num5){ drawer = num5; if (num5 ==1){ smooth(); fill(0,alphafill); rect (pos1,pos2,50,50); gamepage =0; drawer=0; } } void hurtme (int mover2, int numx, int numy){ xbox=numx; ybox=numy; moveaccept2=mover2; if (moveaccept2==1){ //always drawing smooth(); fill(0,alphafill); rect (pos1,pos2,50,50); pos1=pos1+plusorminusx; pos2=pos2+plusorminusy; if (counter == 499){ println("yesy"); if (plusorminusx<0){ plusorminusx = -(plusorminusx*2); println("here1"); }else{ plusorminusx = plusorminusx*2; println("here2"); } if (plusorminusy<0){ plusorminusy = -(plusorminusy*2); println("here3"); }else{ plusorminusy = plusorminusy*2; println("here4"); } } if (pos1>450){ plusorminusx = -(plusorminusx); pos1 = pos1 + plusorminusx; } if(pos2>450){ plusorminusy = -(plusorminusy); pos2 = pos2 + plusorminusy; } if (pos1<0){ plusorminusx = plusorminusx-(plusorminusx*2); pos1 = pos1 + plusorminusx; } if(pos2<0){ plusorminusy = plusorminusy-(plusorminusy*2); pos2 = pos2 + plusorminusy; } if((xbox>pos1)&&(xboxpos2)&&(ybox