Jump to content

  • Log In with Google      Sign In   
  • Create Account


#Actualburnt_casadilla

Posted 15 August 2012 - 04:40 PM

[source lang="java"] public void updateGame() { long currentTime = System.currentTimeMillis(); long elapsedTime = currentTime - lastUpdateTime; lastUpdateTime = currentTime; timeSinceLastNewDot += elapsedTime; if (timeSinceLastNewDot >= NEW_DOT_FREQ) { int newX = randomNumber(); int newY = randomNumber(); debugPrint("New dot created at x:" + newX + ", y:" + newY + "."); BALLS.add(new Ball(newX, newY, 20, 20)); BallRectangle.add(new Rectangle(newX, newY, 20, 20)); timeSinceLastNewDot = 0; }[/source]

ok restart lol. this adds a new rectangle every time a new ball is created

woops forgot to make a new arraylist in the init method

[source lang="java"]BallRectangle = new ArrayList<Rectangle>();[/source]

[source lang="java"] public ArrayList<Rectangle> BallRectangle;[/source]

what is the reason for needing both of the lines of code? how come just the first line wont work?

#1burnt_casadilla

Posted 15 August 2012 - 04:33 PM

[source lang="java"] public void updateGame() { long currentTime = System.currentTimeMillis(); long elapsedTime = currentTime - lastUpdateTime; lastUpdateTime = currentTime; timeSinceLastNewDot += elapsedTime; if (timeSinceLastNewDot >= NEW_DOT_FREQ) { int newX = randomNumber(); int newY = randomNumber(); debugPrint("New dot created at x:" + newX + ", y:" + newY + "."); BALLS.add(new Ball(newX, newY, 20, 20)); BallRectangle.add(new Rectangle(newX, newY, 20, 20)); timeSinceLastNewDot = 0; }[/source]

ok restart lol. this adds a new rectangle every time a new ball is created

PARTNERS