Jump to content

  • Log In with Google      Sign In   
  • Create Account


#Actualburnt_casadilla

Posted 11 August 2012 - 04:38 PM

figured that out the hard way lol

[source lang="java"] public Ball ball[]; static final int NUM_OF_BALLS = 4; int i; int randomx = (int)(Math.random() * 400); int randomy = (int)(Math.random() * 400); int randomx2 = (int)(Math.random() * 400); int randomy2 = (int)(Math.random() * 400); int randomx3 = (int)(Math.random() * 400); int randomy3 = (int)(Math.random() * 400); int randomx4 = (int)(Math.random() * 400); int randomy4 = (int)(Math.random() * 400); class Ball { int x; int y; int width; int height; Color mycolor; public Ball(int x, int y, int width, int height, Color mycolor) { this.x = x; this.y = y; this.width = width; this.height = height; this.mycolor = mycolor; }//end ball public void paint(Graphics g) { for(i = 0; ilessthanNUM_OF_BALLS; i++) { g.setColor(ball[i].mycolor); g.fillOval((int)ball[i].x, (int)ball[i].y, (int)ball[i].width, (int)ball[i].height); }//end for }//end paint }//ball class public void update(Graphics g)//doublebuffer dont touch!! { if(dbImage == null) { dbImage = createImage(this.getSize().width, this.getSize().height); dbg = dbImage.getGraphics(); } dbg.setColor(getBackground()); dbg.fillRect(0, 0, this.getSize().width, this.getSize().height); dbg.setColor(getForeground()); paint(dbg); g.drawImage(dbImage, 0, 0, this); } public void init() { this.setSize(WIDTH, HEIGHT); ball = new Ball[NUM_OF_BALLS]; ball[0] = new Ball(randomx, randomy, 20, 20, Color.red); ball[1] = new Ball(randomx2, randomy2, 20, 20, Color.blue); ball[2] = new Ball(randomx3, randomy3, 20, 20, Color.green); ball[3] = new Ball(randomx4, randomy4, 20, 20, Color.magenta); System.out.println(randomx + " " + randomy); System.out.println(randomx2 + " " + randomy2); System.out.println(randomx3 + " " + randomy3); System.out.println(randomx4 + " " + randomy4);[/source]

#1burnt_casadilla

Posted 11 August 2012 - 04:36 PM

figured that out the hard way lol

[source lang="java"] public Ball ball[]; static final int NUM_OF_BALLS = 4; int i; int randomx = (int)(Math.random() * 400); int randomy = (int)(Math.random() * 400); int randomx2 = (int)(Math.random() * 400); int randomy2 = (int)(Math.random() * 400); int randomx3 = (int)(Math.random() * 400); int randomy3 = (int)(Math.random() * 400); int randomx4 = (int)(Math.random() * 400); int randomy4 = (int)(Math.random() * 400); class Ball { int x; int y; int width; int height; Color mycolor; public Ball(int x, int y, int width, int height, Color mycolor) { this.x = x; this.y = y; this.width = width; this.height = height; this.mycolor = mycolor; }//end ball public void paint(Graphics g) { for(i = 0; i<NUM_OF_BALLS; i++) { g.setColor(ball[i].mycolor); g.fillOval((int)ball[i].x, (int)ball[i].y, (int)ball[i].width, (int)ball[i].height); }//end for }//end paint }//ball class public void update(Graphics g)//doublebuffer dont touch!! { if(dbImage == null) { dbImage = createImage(this.getSize().width, this.getSize().height); dbg = dbImage.getGraphics(); } dbg.setColor(getBackground()); dbg.fillRect(0, 0, this.getSize().width, this.getSize().height); dbg.setColor(getForeground()); paint(dbg); g.drawImage(dbImage, 0, 0, this); } public void init() { this.setSize(WIDTH, HEIGHT); ball = new Ball[NUM_OF_BALLS]; ball[0] = new Ball(randomx, randomy, 20, 20, Color.red); ball[1] = new Ball(randomx2, randomy2, 20, 20, Color.blue); ball[2] = new Ball(randomx3, randomy3, 20, 20, Color.green); ball[3] = new Ball(randomx4, randomy4, 20, 20, Color.magenta); System.out.println(randomx + " " + randomy); System.out.println(randomx2 + " " + randomy2); System.out.println(randomx3 + " " + randomy3); System.out.println(randomx4 + " " + randomy4);[/source]

PARTNERS