1. ## BAll owner

How to determine which player is currently holding the ball or which player currently has the possession to it? And also painting/drawing it?

2. ## Re: BAll owner

I really need to solve this one, how should the ball's coordinates dependent on my players coordinates?

ball class:
Code:
```public class Ball {

int xball, yball;
int vY,vX;
int xb,yb; //ball's position/coordinates

private int w,h;

private PlayerSprite player = null;

private Image bball;

public Ball() throws Exception{

xb = 15;
yb = 15;

xball = 0;
yball =15;

vY = 5;
vX = 2;

bball =Image.createImage("/ball.png");

}

public void moveBall()
{
try
{
if(yball >= 15)
vY = vY * -1;

else if(yball <= 0)
vY = vY * -1;

xball+=vX;
yball+=vY;

}
catch(Exception e)
{

e.printStackTrace();

}

}

public void paintBall(Graphics g){

g.drawImage(bball,xb,yball+yb,0);
}

}```
player sprite

Code:
``` int meX;
int meY;

int fWidth;
int fHeight;

int ballx;
int bally;
.
.
.
public void move()
{
this.move(meX,meY);
}```
gamecanvas

Code:
``` switch(keyStatus) {

case GameCanvas.KEY_NUM2:
//up
player[0].move(0,-1);
player[0].setFrame(3);

break;
case GameCanvas.KEY_NUM8:
//down

player[0].move(0,1);
player[0].setFrame(2);

break;
case GameCanvas.KEY_NUM4:
//left

player[0].move(-1,0);
player[0].setFrame(7);

break;
case GameCanvas.KEY_NUM6:
//right

player[0].move(1,0);
player[0].setFrame(8);
break;```