//Box B[]; //startScreen S; RotateBox Box; EvilSquare evil, evil1; boolean overButton = false; boolean buttonPress = false; int qwerty = 100; void setup() { size(820, 640); // int lineLength = 30; // int w = width/lineLength; // int h = height/lineLength; //B = new Box[w*h]; //float i = 0; //S = new startScreen(); evil1 = new EvilSquare(qwerty); evil = new EvilSquare(qwerty+100); Box = new RotateBox(); } void draw() { background(175, 200, 250); landscape(); Box.run(); startScrn(); if (buttonPress == true ){ //if (millis()% 10 == 0){ //translate(0,random(-300, 300)); evil.evilRun(); evil1.evilRun(); //for int i == textSize(25); text("DEFEND!", width/2-50,height/2-10); }} void landscape() { noStroke(); fill(20, 200, 125); rect(0, height*.8, width, height); noStroke(); fill(175, 180, 125); triangle(width*.1-10, height*.75, width*.1+10, height*.75, width*.1, height*.75-100); noStroke(); fill(20, 200, 125); ellipse(width*.1, height*.8, 100, 100); } void checkButtons() { if (mouseX > width*.4 && mouseX < width*.6 && mouseY > height*.4 && mouseY <height*.55) { overButton = true; } } void startScrn(){ if (buttonPress ==true){ noFill(); } else { stroke(random(255),random(255),random(255)); strokeWeight(5); fill(230); rect(width/20,height/20, width-width/10,height-height/10); stroke(0); strokeWeight(5); fill(255); rect(width*.4,height*.4, width*.2,height*.15); fill(0); text("start game", width*.46,height*.47); } } //void reset(){ // noFill(); // stroke(0); // strokeWeight(3); // rect (width*.87,height*.9, 80, 30); // text("reset", width*.92,height*.92); //} void mousePressed() { if (overButton && mousePressed) { buttonPress = true ;} } void mouseMoved() { checkButtons(); }
Sorry.
class RotateBox { PVector origin; float angle; int len; RotateBox(){ origin = new PVector(width*.1, height*.75-100); angle=0; len =50; } void update() { PVector mouse = new PVector(mouseX, mouseY); PVector direction = PVector.sub(mouse, origin);//I want to subtract second from first one angle = direction.heading(); } void display() { pushMatrix(); translate(width*.1, height*.75-100); rotate(angle); stroke(0); strokeWeight(4); fill(200,200,175); rect(0, 0, len, 15); popMatrix(); } void run() { update(); display(); } }
class EvilSquare { float x; float y; int qwe; EvilSquare(int _qwe){ qwe = _qwe; x = width +100+qwe; y = height/2; } void scare(){ x --; } void display() { pushMatrix(); stroke(0); fill(255,10, 10); strokeWeight(0); rect(x,y, random(20, 50), random (20, 50)); popMatrix(); } void evilRun(){ scare(); display(); } }