Programming / Computing

Rocket Launcher Project

 This program demonstrates a graphical Rocket Launcher........................................................       

 

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

 

 

 

import java.awt.*;

import java.awt.event.*;

class Screen extends Frame

{

public Screen()

{

super("Rocket Launcher");

MyWindowAdapter adapter=new MyWindowAdapter(this);

addWindowListener(adapter);

}

public void paint(Graphics g)

{

int x=350,y=400,w=30,h=100;

int no=5;

//Font f;

//f=new Font("",Font.PLAIN,90);

//setFont(f);

g.drawRect(300,510,300,80);

g.drawRect(605,400,130,180);

g.drawOval(330,582,50,50);

g.drawOval(530,582,50,50);

g.drawOval(620,582,50,50);

g.drawOval(690,582,50,50);

//g.drawString(""+no,600,200);

for(y=400;y>=0;y--)

{

g.setColor(Color.pink);

g.drawRect(x,y,w,h);

g.setColor(Color.red);

g.drawLine(x,y,x+(w/2),y-30);

g.drawLine(x+(w/2),y-30,x+w,y);

g.drawLine(x,y+30,x-20,y+85);

g.drawLine(x-20,y+85,x,y+85);

g.drawLine(x+w,y+30,x+w+20,y+85);

g.drawLine(x+w+20,y+85,x+w,y+85);

for(int k=0;k<=999999;k++)

{

}

g.setColor(Color.white);

g.drawRect(x,y,w,h);

g.drawLine(x,y,x+(w/2),y-30);

g.drawLine(x+(w/2),y-30,x+w,y);

g.drawLine(x,y+30,x-20,y+85);

g.drawLine(x-20,y+85,x,y+85);

g.drawLine(x+w,y+30,x+w+20,y+85);

g.drawLine(x+w+20,y+85,x+w,y+85);

 

}

}

}

 

class Rock

{

public static void main(String arg[])

{

Screen s=new Screen();

s.setSize(900,800);

s.setVisible(true);

}

}

class MyWindowAdapter extends WindowAdapter

{

Screen s;

public MyWindowAdapter(Screen k)

{

s=k;

}

public void windowClosing(WindowEvent we)

{

s.setVisible(false);

System.exit(0);

}

}

 

© 2010 All rights reserved.

Make a free websiteWebnode