





/**
* @(#)Plane.java
*
*
* @author
* @version 1.00 2009/10/7
*/
import javax.swing.*;
import java.awt.*;
import java.util.*;
import java.awt.event.*;
public class Plane2 extends JApplet implements KeyListener{
/** Initialization method that will be called after the applet is loaded
* into the browser.
*/
public void init() {
setFocusable(true);
addKeyListener(this);
// TODO start asynchronous download of heavy resources
}
public void paint(Graphics g) {
g.setColor(new Color(89,176,219));
g.fillRect(0,0,600,700);
g.setColor(Color.BLUE);
int[]x={210,200,120,120,220,160,160,220,260,260,250,250,230,210
};
int[]y={190,260,340,380,400,440,460,480,440,400,380,240,200,190
};
g.fillPolygon(x,y,14);
int[]a={350,330,310,310,300,300,340,400,400,340,440,440,360,350
};
int[]b={190,200,240,380,400,440,480,460,440,400,380,340,260,190
};
g.fillPolygon(a,b,14);
g.setColor(new Color(124,5,116));
int[]w={280,260,250,240,230,250,250,260,260,300,300,310,310,330,320,310,300,280
};
int[]z={100,120,140,180,200,240,380,400,440,440,400,380,240,200,180,140,120,100
};
g.fillPolygon(w,z,18);
g.setColor(Color.GREEN);
int[]x1={220,220,230,230,220
};
int[]y1={230,290,300,240,230
};
g.fillPolygon(x1,y1,5);
int[]v1={340,330,330,340,340
};
int[]m1={230,240,300,290,230
};
g.fillPolygon(v1,m1,5);
g.setColor(Color.PINK);
int[]x2={200,160,160,220,220,200
};
int[]y2={300,340,370,380,320,300
};
g.fillPolygon(x2,y2,6);
int[]a2={360,340,340,400,400,360
};
int[]b2={300,320,380,370,340,300
};
g.fillPolygon(a2,b2,6);
///////
g.setColor(new Color(169,49,249));
int[]x3={220,180,220,240,220
};
int[]y3={420,440,460,440,420
};
g.fillPolygon(x3,y3,5);
int[]a3={340,320,340,380,340
};
int[]b3={420,440,460,440,420
};
g.fillPolygon(a3,b3,5);
//////
g.setColor(Color.RED);
int[]x4={270,260,300,290,270
};
int[]y4={130,140,140,130,130
};
g.fillPolygon(x4,y4,5);
g.setColor(new Color(12,5,11));
int[]x5={260,280,300,260
};
int[]y5={180,200,180,180
};
g.fillPolygon(x5,y5,4);
g.setColor(Color.WHITE);
g.fillRect(260,140,40,40);
/////
g.setColor(Color.BLACK);
g.fillRect(270,250,20,10);
g.setColor(Color.GRAY);
g.fillRect(270,260,20,70);
g.setColor(Color.RED);
g.fillRect(270,330,20,10);
g.setColor(Color.BLACK);
int[]x6={270,260,260,270,270,290,290,300,300,290,270
};
int[]y6={340,360,370,360,350,350,360,370,360,340,340
};
g.fillPolygon(x6,y6,11);
g.setColor(Color.ORANGE);
g.fillRect(270,350,20,30);
g.setColor(Color.BLACK);
int[]x7={260,270,290,300,260
};
int[]y7={440,460,460,440,440
};
g.fillPolygon(x7,y7,5);
g.setColor(Color.RED);
int[]x8={270,240,220,250,250,270,280,290,310,310,340,320,290,270
};
int[]y8={460,480,520,500,530,500,520,500,530,500,520,480,460,460
};
g.fillPolygon(x8,y8,14);
}
///////////////////////////////////////
public void keyReleased(KeyEvent kr){
}
public void keyTyped(KeyEvent kt){
}
public void keyPressed(KeyEvent kp){
Graphics g1=getGraphics();
int x=270;
int y=230;
try{
if(kp.getKeyCode()==KeyEvent.VK_J){
// g1.clearRect(0,0,400,400);
g1.fillOval(x,y=y-10,20,20);
Thread.sleep(6);
repaint();
}
}catch(InterruptedException e){
}
///////////////////Action troy
int r=20;
try{
if(kp.getKeyCode()==KeyEvent.VK_A){
g1.clearRect(0,0,600,700);
g1.setColor(new Color(89,176,219));
g1.fillRect(0,0,600,700);
g1.setColor(Color.BLUE);
int[]x9={210-r,200-r,120-r,120-r,220-r,160-r,160-r,220-r,260-r,260-r,250-r,250-r,230-r,210-r
};
int[]y9={190,260,340,380,400,440,460,480,440,400,380,240,200,190
};
g1.fillPolygon(x9,y9,14);
int[]a={350-r,330-r,310-r,310-r,300-r,300-r,340-r,400-r,400-r,340-r,440-r,440-r,360-r,350-r
};
int[]b={190,200,240,380,400,440,480,460,440,400,380,340,260,190
};
g1.fillPolygon(a,b,14);
g1.setColor(new Color(124,5,116));
int[]w={280-r,260-r,250-r,240-r,230-r,250-r,250-r,260-r,260-r,300-r,300-r,310-r,310-r,330-r,320-r,310-r,300-r,280-r
};
int[]z={100,120,140,180,200,240,380,400,440,440,400,380,240,200,180,140,120,100
};
g1.fillPolygon(w,z,18);
g1.setColor(Color.GREEN);
int[]x1={220-r,220-r,230-r,230-r,220-r
};
int[]y1={230,290,300,240,230
};
g1.fillPolygon(x1,y1,5);
int[]v1={340-r,330-r,330-r,340-r,340-r
};
int[]m1={230,240,300,290,230
};
g1.fillPolygon(v1,m1,5);
g1.setColor(Color.PINK);
int[]x2={200-r,160-r,160-r,220-r,220-r,200-r
};
int[]y2={300,340,370,380,320,300
};
g1.fillPolygon(x2,y2,6);
int[]a2={360-r,340-r,340-r,400-r,400-r,360-r
};
int[]b2={300,320,380,370,340,300
};
g1.fillPolygon(a2,b2,6);
///////
g1.setColor(new Color(169,49,249));
int[]x3={220-r,180-r,220-r,240-r,220-r
};
int[]y3={420,440,460,440,420
};
g1.fillPolygon(x3,y3,5);
int[]a3={340-r,320-r,340-r,380-r,340-r
};
int[]b3={420,440,460,440,420
};
g1.fillPolygon(a3,b3,5);
//////
g1.setColor(Color.RED);
int[]x4={270-r,260-r,300-r,290-r,270-r
};
int[]y4={130,140,140,130,130
};
g1.fillPolygon(x4,y4,5);
g1.setColor(new Color(12,5,11));
int[]x5={260-r,280-r,300-r,260-r
};
int[]y5={180,200,180,180
};
g1.fillPolygon(x5,y5,4);
g1.setColor(Color.WHITE);
g1.fillRect(260-r,140,40,40);
/////
g1.setColor(Color.BLACK);
g1.fillRect(270-r,250,20,10);
g1.setColor(Color.GRAY);
g1.fillRect(270-r,260,20,70);
g1.setColor(Color.RED);
g1.fillRect(270-r,330,20,10);
g1.setColor(Color.BLACK);
int[]x6={270-r,260-r,260-r,270-r,270-r,290-r,290-r,300-r,300-r,290-r,270-r
};
int[]y6={340,360,370,360,350,350,360,370,360,340,340
};
g1.fillPolygon(x6,y6,11);
g1.setColor(Color.ORANGE);
g1.fillRect(270-r,350,20,30);
g1.setColor(Color.BLACK);
int[]x7={260-r,270-r,290-r,300-r,260-r
};
int[]y7={440,460,460,440,440
};
g1.fillPolygon(x7,y7,5);
g1.setColor(Color.RED);
int[]x8={270-r,240-r,220-r,250-r,250-r,270-r,280-r,290-r,310-r,310-r,340-r,320-r,290-r,270-r
};
int[]y8={460,480,520,500,530,500,520,500,530,500,520,480,460,460
};
g1.fillPolygon(x8,y8,14);
}
Thread.sleep(20);
}catch(InterruptedException e){
}
}
}
No comments:
Post a Comment