Collect the balls in the bucket using java programming.
hello friends,
here is some codes in java check it out.
Enjoy it.
here is some codes in java check it out.
import java.applet.*;Keep your own images and provide the addresses for them.
import java.awt.*;
import java.awt.event.*;
/*<Applet code="p" height=400 width=400></applet>*/
public class p extends Applet implements MouseMotionListener,Runnable
{
int x,y,k,i,p,px,s=0;
Image img,img1,img2;
Thread t;
String str;
public void init()
{
addMouseMotionListener(this);
t=new Thread(this);
t.start();
img=getImage(getDocumentBase(),"dem.gif"😉;
img1=getImage(getDocumentBase(),"lig.gif"😉;
img2=getImage(getDocumentBase(),"lim.gif"😉;
}
public void run()
{
for(i=0;i<=4000;i++)
{
try
{
repaint();
t.sleep(50);
k=k+5;
if(k==400)
k=0;
}
catch(Exception e)
{
System.out.println("exception "😉;
}
}
}
public void mouseDragged(MouseEvent e)
{}
public void mouseMoved(MouseEvent e)
{
repaint();
x=e.getX();
y=e.getY();
if(y>=380)
{
p=y;
}
}
public void paint(Graphics g)
{
g.drawImage(img,x,p,20,20,this);
g.drawImage(img1,20,k,20,20,this);
if(p<=k)
{
if(x>=0 && x<=22)
{
g.drawString("AAHA MIL GYA",x,p);
s++;
g.drawImage(img2,x,p,20,20,this);
}
}
str="total"+Integer.toString(s);
g.drawString(str,350,350);
}
}
Enjoy it.
0