boolean gamePlaying = false; boolean gameTitle = true; eggclass egg; int SCREENSIZE = 400; ArrayList sperms = new ArrayList(); int spermcount = 0; int score = 0; void setup(){ size(400,400); ellipseMode(CENTER); textFont(loadFont("Arial-Black-14.vlw"),14); egg = new eggclass(); frameRate(60); lowLag.init(); lowLag.load("LUDWIGVB.mp3"); lowLag.load("POP.mp3"); } boolean freeze = false; void keyPressed(){ // freeze = true; } float releaseDelay = 100; float timer = 0; void mouseReleased(){ if(! gamePlaying){ gamePlaying = true; gameTitle = false; sperms.clear(); releaseDelay = map(constrain(mouseX,100,300),100,300,120,20); addSperm(); timer = releaseDelay; spermcount = 1; score = 0; } } void draw(){ background(180,40,40); timer--; if(timer < 0 && gamePlaying){ timer = releaseDelay; if(releaseDelay > 10) releaseDelay -= 1; //println(releaseDelay); spermcount++; addSperm(); } if(gamePlaying){ score += spermcount; for(spermclass sperm : sperms){ if(! freeze){sperm.move();} } } // end if(gamePlaying) egg.draw(); for(spermclass sperm : sperms){ sperm.draw(); if(sperm.hit(egg)){ gamePlaying = false; lowLag.play("LUDWIGVB.mp3"); gameTitle = false; } } fill(255); textAlign(CENTER); if(!gameTitle) { text("score: "+score,200,20);} if((! gamePlaying) ){ if(! gameTitle){ text("OH NOES!",200,50); text("YOUR PREGGERS!!!!!!",200,100); text("SEMEN HAS MILLIONS OF SPERMS!!!",200,150); text("remember sometimes the only way to win",200,200); text("is not to play!!!!!!!",200,250); //text("~o ~o ~o click to try again o~ o~ o~",200,300); } else { text("~o ~o ~o look out! o~ o~ o~",200,50); text("you are a precious egg cell!",200,100); text("try not to get PREGGERS!!!!!",200,150); text("click to start and look out for SPERMS!!!",200,200); } String extra = ""; if(!gameTitle) extra = " this time" text("click for how much sex"+extra+":",200,300); text("less sperms",50,350); text("more sperms",350,350); stroke(255); line(100,345,300,345); line(100,345,105,340); line(100,345,105,350); line(300,345,295,340); line(300,345,295,350); stroke(0); } } //--------------------------------add sperm void addSperm(){ lowLag.play("POP.mp3"); float x,y; x = mouseX; y = mouseY; while(abs(mouseX - x ) < 80 ||abs(mouseY - y ) < 80){ if( int(random(2)) == 0){ if( int(random(2)) ==0){ x = -20; } else { x = SCREENSIZE + 20; } y = random(SCREENSIZE - 30)+ 30; } else { if( int(random(2)) ==0){ y = -20; } else { y = SCREENSIZE + 20; } x = random(SCREENSIZE - 30)+ 30; } } sperms.add( new spermclass(x,y)); } //--------------------------------EGG CLASS class eggclass{ public float x,y; void draw(){ if(gamePlaying){ x = mouseX; y = mouseY ; } else { x = constrain(mouseX,100,300); y = 345; } drawEgg(x,y); } eggclass(){ } } void drawEgg(float x, float y){ stroke(0); fill(0); ellipse(x,y,5,5); noFill(); ellipse(x,y,10,10); } //--------------------------------SPERM CLASS class spermclass{ float xs, ys, x, y; float tailx[] = new float[100] ; float taily[] = new float[100]; float accel = .05; int tailsize = 20; spermclass(float px, float py){ x = px; y = py; for(int i = 0; i < tailsize; i++){ tailx[i] = x; taily[i] = y; } } float tailOut = 0; void move(){ for(int i = tailsize-1; i > 0; i--){ tailx[i] = tailx[i-1]; taily[i] = taily[i-1]; } tailx[0] = x; taily[0] = y; if(x < mouseX) { xs += accel; } else { xs -= accel; } if(y < mouseY) ys += accel; else ys -= accel; xs *= .99; ys *= .99; x += xs; y += ys; float facing = atan2(ys,xs); float tailFacing = facing + (PI/2); tailOut+= .2; tailx[0] += 4 * cos(tailFacing) * sin(tailOut); taily[0] += 4 * sin(tailFacing) * sin(tailOut); } void draw(){ stroke(0); for(int i = 1; i < tailsize; i++){ line(tailx[i],taily[i],tailx[i-1],taily[i-1]); } fill(0); ellipse(x,y,3,3); line(x,y,tailx[0], taily[0]); //line(x, y , x + cos(facing)*20, y + sin(facing)*20); } boolean hit(eggclass egg){ if(sqrt( ((x - egg.x) *(x - egg.x) ) + ((y - egg.y) *(y - egg.y) ) ) < 13 ){ return true; } return false; } }