BackgroundManager bm; GameManager gm; static final int pointsToWin = 10; static final boolean DEBUG = true; PFont font; PFont introFont; boolean started; Powerup intp1; Powerup intp2; Powerup intp3; void setup(){ font = loadFont("Monospaced-38.vlw"); introFont = loadFont("SansSerif-25.vlw"); size (400, 750); frameRate(40); smooth(); textFont(font, 30); textAlign(CENTER); resetGame(); setupIntroPowerups(); } void resetGame() { gm = new GameManager(); bm = new BackgroundManager(); started = false; } void setupIntroPowerups() { int pupmargin = 100; int pupDist = 60; intp1 = new Powerup(gm); intp1.velocityX = 0; intp1.velocityY = 0; intp1.visible = true; intp1.type = Powerup.SPEED; intp1.x = pupmargin; intp1.y = height/2 + 25; intp2 = new Powerup(gm); intp2.velocityX = 0; intp2.velocityY = 0; intp2.visible = true; intp2.type = Powerup.PERFECTION; intp2.x = pupmargin; intp2.y = intp1.y + pupDist; intp3 = new Powerup(gm); intp3.velocityX = 0; intp3.velocityY = 0; intp3.visible = true; intp3.type = Powerup.DISCO; intp3.x = pupmargin; intp3.y = intp2.y + pupDist; } void draw() { if (!started) { intro(); return; } bm.update(); gm.update(); bm.drawStars(); gm.drawText(); } void intro() { background(0); fill(bm.lineColor()); textFont(introFont, 20); text("Player 1 is on top.\n\nPlayer 2 is on bottom.", width/2, height/2 - 350); textFont(gm.silkscreenNormal, 24); text("CONTROLS", width/2, height/2 - 210); textFont(introFont, 18); text("\nPlayer 1:\nz moves left x moves right\n" + "Player 2:\n< moves left > moves right\n", width/2, height/2 - 200); textFont(gm.silkscreenNormal, 24); text("POWERUPS", width/2, height/2 - 20); textFont(gm.silkscreenNormal, 8); text("GET A POWERUP PAST YOUR ENEMY TO GET POWER", width/2, height/2 - 5); textFont(introFont, 18); textAlign(LEFT); text("Speed increase", intp1.x + 30, intp1.y + 6); text("Perfection", intp2.x + 30, intp2.y + 6); text("Ugh, headache", intp3.x + 30, intp3.y + 6); textAlign(CENTER); textFont(gm.silkscreenNormal, 24); text("GET " + pointsToWin + " POINTS TO WIN", width/2, height - 140); textFont(gm.silkscreen, 24); text("PRESS SPACE TO BEGIN", width/2, height - 50); intp1.update(); intp2.update(); intp3.update(); } void keyReleased() { gm.keyUp(key); } void keyPressed() { if (!started) { if (key == ' ') { started = true; } return; } gm.keyDown(key); }