I''ve just started with Java, though I''ve been coding C/C++ for about 2 years and java-script for about 5, so I am very familiar with the syntax. I wrote this simple applet the other day, and it did something completely unexpected (or atleast I didn''t expect it)
public JavaAp3 extends Applet
{
public paint(Graphics g)
{
int x,n,m;
Image img;
img=getImage(getCodeBase(),"knight.gif");
x=(int)(Math.random*25);
while(x>=0){
n=(int)(Math.random*200);
m=(int)(Math.random*200);
g.drawImage(img,n,m,this);
x--;
}
}
}
|
Now, I thought this would run once and I would have a random number of knights at random locations on the screen. But instead, it continues to rerun the applet over and over again, so that I have a random number of knights constantly blinking on the screen over and over again.
Can I make it stop? How can I take advantage of this? Is there a faster way of putting stuff on screen (this is almost as slow as java-script)?
Are you even trying to be intelligent?
''cuz if you are, it ain''t workin''
Down with Tiberia!