public void mousePressed() { if (game.screen == 1) { // see above velocity = PVector.fromAngle( radians( (float) angledegrees)); // uses PVector to make a vector from the angle of the shooter if (canfire == true) { // checks if user is able to fire (if ball is active) game.shooterlist[0] = game.shooterlist[1]; // sets active ball to the next ball game.shooterlist[0].setVelocity( velocity.x, velocity.y); // adjusts velocity for ball depending on type game.shooterlist[1] = new Ball( game .createNewBall()); // creates new ball with random type as generated by the // createNewBall function canfire = false; // disables firing while ball is active } } if (game.screen == 0) { // see above if (button.pressed()) { // checks if button is pressed game.gotoGame(); // loads game } } if (game.screen == 2) { if (button.pressed()) { game.reset(); // resets game } } }
public void draw(PApplet canvas, float scale) { PVector orient = PVector.fromAngle(orientation); orient.mult(scale * getRadius()); float x = (float) position.x * scale; float y = (float) position.y * scale; float diameter = getRadius() * 2 * scale; canvas.fill(teamColor); canvas.stroke(0); canvas.ellipse(x, y, diameter, diameter); canvas.line(x, y, x + (float) orient.x, y + (float) orient.y); // Delegate Decoration to Robot float heading = orient.heading(); float drawScale = 100f / scale * getRadius(); canvas.translate(x, y); canvas.rotate(heading); canvas.scale(drawScale); // TODO: How to resolve scale, so that teams don't have to mind it also... decorateRobot(canvas); canvas.scale(1f / drawScale); canvas.rotate(-heading); canvas.translate(-x, -y); }
public PVector getForceVector() { return PVector.fromAngle((float) ((degrees - 90) * (Math.PI / 180))); }