im doing an applet and this is what i have so far
[CODE=Java]import java.awt.*;
import java.awt.event. *;
import java.applet.*;
import javax.swing.*;
public class Applet1 extends JApplet
{
Thread t = new Thread();;
int p1;
int p2;
int a=0;
int b=50;
int c=125;
int d=115;
int e=50;
int f=300;
int j=300;
int h=325;
int i=325;
int ani=480;
int [] x = {b+a,c+a,d+a,e+ a};
int [] y = {f+a,j+a,h+a,i+ a};
public void paint(Graphics g)
{
g.setColor(Colo r.black);
g.fillRect(0,0, 500,300);
g.setColor(Colo r.blue);
g.fillRect(0,30 0,500,500);
g.setColor(Colo r.white);
for(int a=1;a<=342;a=a+ 2)
{
p1=1+(int) (Math.random()* 600);
p2=1+(int) (Math.random()* 254);
g.fillOval(p1,p 2,1,1);
}
g.fillOval(450, 30,25,25);
{
ani=ani-1;
g.setColor(Colo r.gray);
g.fillOval(ani, 70,60,40);
g.fillOval(ani, 90,70,30);
g.fillOval(ani-20,105,60,30);
try{t.sleep(100 );} catch(Exception e){}
g.setColor(Colo r.gray);
g.fillOval(ani, 85,50,20);
if(ani<500)repa int();
}
}
}
[/CODE]
the one problem is is when i animate the cloud to move, it repaints the stars in the back round again using the math.random..
what am i doing wrong? im pretty sure every thing is inside a bracket, and dont mind all my ints and the array that i havent used yet..just need to know about the animation
[CODE=Java]import java.awt.*;
import java.awt.event. *;
import java.applet.*;
import javax.swing.*;
public class Applet1 extends JApplet
{
Thread t = new Thread();;
int p1;
int p2;
int a=0;
int b=50;
int c=125;
int d=115;
int e=50;
int f=300;
int j=300;
int h=325;
int i=325;
int ani=480;
int [] x = {b+a,c+a,d+a,e+ a};
int [] y = {f+a,j+a,h+a,i+ a};
public void paint(Graphics g)
{
g.setColor(Colo r.black);
g.fillRect(0,0, 500,300);
g.setColor(Colo r.blue);
g.fillRect(0,30 0,500,500);
g.setColor(Colo r.white);
for(int a=1;a<=342;a=a+ 2)
{
p1=1+(int) (Math.random()* 600);
p2=1+(int) (Math.random()* 254);
g.fillOval(p1,p 2,1,1);
}
g.fillOval(450, 30,25,25);
{
ani=ani-1;
g.setColor(Colo r.gray);
g.fillOval(ani, 70,60,40);
g.fillOval(ani, 90,70,30);
g.fillOval(ani-20,105,60,30);
try{t.sleep(100 );} catch(Exception e){}
g.setColor(Colo r.gray);
g.fillOval(ani, 85,50,20);
if(ani<500)repa int();
}
}
}
[/CODE]
the one problem is is when i animate the cloud to move, it repaints the stars in the back round again using the math.random..
what am i doing wrong? im pretty sure every thing is inside a bracket, and dont mind all my ints and the array that i havent used yet..just need to know about the animation
Comment