Hi,
I'm pretty new to Java, I have studied a couple of modules on it at University (even though I'm studyin Networking :confused:) and I like what I see, so plan to continue expanding my knowledge on it :cool:.
I am developping a small bat and ball game which initially, I thought would be relatively straight forward... How wrong could I be?
I am having problems repainting the bat.
Initially my ball moves around the screen and my bat is painted. I have attached a mouselistener to my main applet which gets the x co-ordinate that the mouse is at, which is then passed to a constructor inside my bat class.
Although, for some reason my bat remains stationary.
I have added some S.O.P testing and I have found where the issue is, although I can't find a way round it. Any help will be much appreciated :cool:.
S.O.P produces this...Code:import java.awt.*;
public class Bat
{
public int x;
public void setx (int x)
{
this.x = x;
System.out.println("X1 = "+this.x);
}
public void paint (Graphics h)
{
System.out.println("X2 = "+x);
h.setColor(Color.red);
h.fillRect(x, 490, 50, 10);
System.out.println("X3 = "+x);
System.out.println("Painted");
}
}
Why is the x value being reset to 0?:confused:Quote:
X1 = 224
X2 = 0
Painted
Thanks in advance

