CG
Program to show collision of 2 bodies in java
*/
import java.io.*;
import java.util.*;
import java.awt.*;
import java.applet.*;
public class collision extends Applet
{
int x=0;
int y=100;
int z=500;
int a=100;
int n=0;
Thread t=new Thread();
public void paint(Graphics g)
{
try{
if(x==200)
{
n=100;
}
if(n!=100)
{
g.fillOval(x,y,100,100);
g.fillOval(z,a,100,100);
x=x+1;
z=z-1;
t.sleep(10);
repaint();
}
catch(Exception e)
{}
}
}
/*<applet code = "collision" width = 1000 height = 1000> </applet>*/
No comments:
Post a Comment