////////////////////////////////////// //globals so we know what page were on int startpage = 0; int gamepage =0; int moveme =0; // /////////////////////////////////////// //initialise classes Startscreen start = new Startscreen(); changestart startgame = new changestart(); gaming game = new gaming (); // ////////////////////////////////////// // 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); game.movethebox(moveme); //delay(100); } // //////////////////////////////////////////////////////////////////////////////////////////////////// //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 } } // /////////////////////////////////////// // class changestart { int change; changestart (){ } void waitformouse (int number){ change = number; if (change==1){ 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(255, 120); 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(255, 120); rect(positionx,positiony,10,10); } if (keyCode == RIGHT) { background (70); if (positionx>width-20){ positionx = positionx; }else{ positionx = positionx + 10; } fill(255, 120); rect(positionx,positiony,10,10); } if (keyCode == DOWN) { background (70); if (positiony>width-20){ positiony = positiony; }else{ positiony = positiony + 10; } fill(255, 120); rect(positionx,positiony,10,10); } if (keyCode == LEFT) { background (70); if (positionx<10){ positionx = positionx; }else{ positionx = positionx - 10; } fill(255, 120); rect(positionx,positiony,10,10); } } } } }//end movethebox }//end class // ////////////////////////////////////////////////////// //