import processing.opengl.*; void setup() { size(1400, 900, OPENGL); background(0); smooth(); } void draw() { lights(); Rink(); // How to turn this into an object? RinkMarkings(); Net(); Puck(); GreenTeam(); RedTeam(); } void GreenTeam() { fill(0,255,0); stroke(160,32,240); //OFFENCE rect(width/3,height/3-100,40,40); rect(width/3,height/2,40,40); rect(width/3,height-200,40,40); //DEFENCE rect(width/3-150,height/2-130,40,40); rect(width/3-150,height-330,40,40); // Goalie fill(0,255,0); rect(175,height/2,40,40); } void RedTeam() { fill(255,0,0); stroke(255,255,0); //OFFENCE rect(width/2+235,height/3-100,40,40); rect(width/2+235,height/2,40,40); rect(width/2+235,height-200,40,40); //DEFENCE rect(width/2+400,height/2-130,40,40); rect(width/2+400,height-330,40,40); // Goalie fill(255,0,0); rect(width-175,height/2,40,40); } int puckX; int puckY; int puckXspeed; int puckYspeed; void Puck(){ puckX = puckX + puckXspeed; puckY = puckY + puckYspeed; fill(0); noStroke(); ellipse(width/2+100,height/2,15,15); } int Net1X; int Net1Y; int Net2X; int Net2Y; void Net() { //Left Net pushMatrix(); translate(133, 450); fill(200); strokeWeight(8); box(30, 100, 80); popMatrix(); // Right Net pushMatrix(); translate(width-133, 450); fill(200); strokeWeight(8); box(30, 100, 80); popMatrix(); } void RinkMarkings() { // center circle fill(255); stroke(0, 0, 255); strokeWeight(2); ellipse(width/2, height/2, 200, 200); //4 red circles stroke(255, 0, 0); ellipse(width-300, 180, 200, 200); ellipse(width-300, height-180, 200, 200); ellipse(300, 180, 200, 200); ellipse(300, height-180, 200, 200); // dots fill(255, 0, 0); ellipse(width-300, 180, 20, 20); ellipse(width-300, height-180, 20, 20); ellipse(300, 180, 20, 20); ellipse(300, height-180, 20, 20); fill(255, 0, 0); ellipse(width-600, 180, 10, 10); ellipse(width-600, height-180, 10, 10); ellipse(600, 180, 10, 10); ellipse(600, height-180, 10, 10); // Middle Red Line stroke(255, 0, 0); fill(255, 0, 0); rect(width/2, height/2, 1, 787); // middle Blue Cricle fill(0, 0, 255); ellipse(width/2, height/2, 25, 25); // blue lines fill(0, 0, 255); noStroke(); rect(width/2-200, height/2, 15, 787); rect(width/2+200, height/2, 15, 787); // right goal mouth stroke(255, 0, 0); fill(0, 0, 255); ellipse(width-155, height/2, 150, 150); // right filler rect to cover blue cricle fill(255); noStroke(); rect(width-111, height/2, 75, 155); // right ice puck line fill(255, 0, 0); stroke(255, 0, 0); strokeWeight(7); rect(width-150, height/2, 1, 767); // left goal mouth strokeWeight(2); fill(0, 0, 255); ellipse(155, height/2, 150, 150); // left filler rect to cover blue cricle fill(255); noStroke(); rect(111, height/2, 75, 155); // left ice puck line fill(255, 0, 0); stroke(255, 0, 0); strokeWeight(7); rect(150, height/2, 1, 767); // trapizoid stroke(255,0,0); strokeWeight(7); line(150,height/2-75,40,height/2-125); line(150,height/2+75,40,height/2+125); line(width-150,height/2-75,width-40,height/2-125); line(width-150,height/2+75,width-40,height/2+125); } void Rink() { stroke(128);// Grey boards strokeWeight(100); fill(255); rectMode(CENTER); rect(width/2, height/2, width-300, height-50); fill(255); stroke(128); strokeWeight(100); arc(width/2+500, width/2-20, 390, 390, 0, PI/2); // bottom right corner arc(width/2-499, width/2-20, 390, 390, PI/2, PI); // bottom left corner arc(width/2-499, width/2-480, 390, 390, PI, 3*PI/2);// top left corner arc(width/2+500, width/2-480, 390, 390, -PI/2, 0); //top right corner //fillers fill(255); noStroke(); rect(105, height/2, 200, 500); rect(width-105, height/2, 200, 500); fill(150); rect(width-5, height/2, 66, 500); rect(6, height/2, 66, 500); }