Jump to content

  • Log In with Google      Sign In   
  • Create Account


#Actualburnt_casadilla

Posted 12 August 2012 - 07:15 PM

1. The values i;m using are the int variables i declared in the constructor. The drawing of the ball is within the class, but im then calling the method through my main paint method with mainBall.paintMainBall(g).

2. The values being updated in the key method are the mainBall.xspeed and mainBall.yspeed. And this part works fine because the coordinates do change when i press a key.

3. Actually i cant really find where im drawing the ball except in the class. and i thought that in the main run method it was being repainted but obviously it isnt.

holy shit youre a genius. i changed the variables in the paintMainBall method to xpos and ypos and it worked Posted Image

i guess i was just repeatedly drawing the ball to x and y, but they never even changed.\

and now i can FINALLY move onto collision. im thinking:

1. create the public Rectangle getBounds() method with a for loop
2. the for loop will run everytime a new ball is created in the arraylist
3. within the for loop i use ballPositionX = balls.get(0).getx(); and ballPositionY = balls.get(0).gety(); to grab the coordinates of the ball
4. then i add return (something) to return the rectangle

i think thatll work for creating the rectangle around the ball, but in order to actually use it, i might store it in an array and then use (if (playerRectangle.intersects(enemyRectangle)) somewhere in order to stop the mainBall when it comes in contact with another ball

oh but in order to make it a little easier at first, im going to create a fixed ball at 250, 250 just so i can try out the method without getting for loops at first

another issue i just realized is that i have no idea how to use the getBounds method -.-

public Rectangle getBounds()
{
//what do i put in here in order to get the bounds of a circle at point 250, 250 and 20 height and 20 width?

// and this returns a value too so im making an arraylist for this too?
}

#6burnt_casadilla

Posted 12 August 2012 - 07:05 PM

1. The values i;m using are the int variables i declared in the constructor. The drawing of the ball is within the class, but im then calling the method through my main paint method with mainBall.paintMainBall(g).

2. The values being updated in the key method are the mainBall.xspeed and mainBall.yspeed. And this part works fine because the coordinates do change when i press a key.

3. Actually i cant really find where im drawing the ball except in the class. and i thought that in the main run method it was being repainted but obviously it isnt.

holy shit youre a genius. i changed the variables in the paintMainBall method to xpos and ypos and it worked Posted Image

i guess i was just repeatedly drawing the ball to x and y, but they never even changed.\

and now i can FINALLY move onto collision. im thinking:

1. create the public Rectangle getBounds() method with a for loop
2. the for loop will run everytime a new ball is created in the arraylist
3. within the for loop i use ballPositionX = balls.get(0).getx(); and ballPositionY = balls.get(0).gety(); to grab the coordinates of the ball
4. then i add return (something) to return the rectangle

i think thatll work for creating the rectangle around the ball, but in order to actually use it, i might store it in an array and then use (if (playerRectangle.intersects(enemyRectangle)) somewhere in order to stop the mainBall when it comes in contact with another ball

oh but in order to make it a little easier at first, im going to create a fixed ball at 250, 250 just so i can try out the method without getting for loops at first

#5burnt_casadilla

Posted 12 August 2012 - 07:01 PM

1. The values i;m using are the int variables i declared in the constructor. The drawing of the ball is within the class, but im then calling the method through my main paint method with mainBall.paintMainBall(g).

2. The values being updated in the key method are the mainBall.xspeed and mainBall.yspeed. And this part works fine because the coordinates do change when i press a key.

3. Actually i cant really find where im drawing the ball except in the class. and i thought that in the main run method it was being repainted but obviously it isnt.

holy shit youre a genius. i changed the variables in the paintMainBall method to xpos and ypos and it worked Posted Image

i guess i was just repeatedly drawing the ball to x and y, but they never even changed.\

and now i can FINALLY move onto collision. im thinking:

1. create the public Rectangle getBounds() method with a for loop
2. the for loop will run everytime a new ball is created in the arraylist
3. within the for loop i use ballPositionX = balls.get(0).getx(); and ballPositionY = balls.get(0).gety(); to grab the coordinates of the ball
4. then i add return (something) to return the rectangle

i think thatll work for creating the rectangle around the ball, but in order to actually use it, i might store it in an array and then use (if (playerRectangle.intersects(enemyRectangle)) somewhere in order to stop the mainBall when it comes in contact with another ball

#4burnt_casadilla

Posted 12 August 2012 - 06:53 PM

1. The values i;m using are the int variables i declared in the constructor. The drawing of the ball is within the class, but im then calling the method through my main paint method with mainBall.paintMainBall(g).

2. The values being updated in the key method are the mainBall.xspeed and mainBall.yspeed. And this part works fine because the coordinates do change when i press a key.

3. Actually i cant really find where im drawing the ball except in the class. and i thought that in the main run method it was being repainted but obviously it isnt.

holy shit youre a genius. i changed the variables in the paintMainBall method to xpos and ypos and it worked :D

i guess i was just repeatedly drawing the ball to x and y, but they never even changed.

#3burnt_casadilla

Posted 12 August 2012 - 06:52 PM

1. The values i;m using are the int variables i declared in the constructor. The drawing of the ball is within the class, but im then calling the method through my main paint method with mainBall.paintMainBall(g).

2. The values being updated in the key method are the mainBall.xspeed and mainBall.yspeed. And this part works fine because the coordinates do change when i press a key.

3. Actually i cant really find where im drawing the ball except in the class. and i thought that in the main run method it was being repainted but obviously it isnt.

holy shit youre a genius. i changed the variables in the paintMainBall method to xpos and ypos and it worked :D

i guess i was just repeatedly drawing the ball to x and y, but they never even changed.

#2burnt_casadilla

Posted 12 August 2012 - 06:52 PM

1. The values i;m using are the int variables i declared in the constructor. The drawing of the ball is within the class, but im then calling the method through my main paint method with mainBall.paintMainBall(g).

2. The values being updated in the key method are the mainBall.xspeed and mainBall.yspeed. And this part works fine because the coordinates do change when i press a key.

3. Actually i cant really find where im drawing the ball except in the class. and i thought that in the main run method it was being repainted but obviously it isnt.

holy shit youre a genius. i changed the variables in the paintMainBall method to xpos and ypos and it worked :D

i guess i was just repeatedly drawing the ball to x and y, but they never even changed.

PARTNERS