Programming / Computing

Game Tugy Project

This program demonstrates a graphical Game Tugy Project.................................................... .      

 

The code for the same is as follows................................................................................ 

 

 

 

 

import java.awt  .*;

import java.awt.event.*;

class Light extends Frame

{

int x,y,k;

public Light()

{

super ("tugy");

MyWindowAdapter adapter=new MyWindowAdapter(this);

addWindowListener(adapter);

x=300;y=50;k=0;

}

public void paint(Graphics g)

{

setBackground(Color.white);

while(k<=1000)

{

g.setColor(Color.black);

g.fillOval(x,y,60,60);

for(int i=1;i<=999999;i++){}

g.setColor(Color.white);

g.fillOval(x,y,60,60);

k++;y++;

//this.repaint();

}

}

}

 

class Game

{

public static void main(String arg[])

{

Light l=new Light();

l.setSize(800,800);

l.setVisible(true);

}

}

 

 

class MyWindowAdapter extends WindowAdapter

{

Light l;

public MyWindowAdapter(Light k)

{

l=k;

}

public void windowClosing(WindowEvent we) 

{

l.setVisible(false);

System.exit(0);

}

}

 

 

© 2010 All rights reserved.

Make a free websiteWebnode