Cañi.java
Categorías: CategoryJava | CategoryProgramacion |
1 /*
2 * To change this template, choose Tools | Templates
3 * and open the template in the editor.
4 */
5 package savetheearthsk;
6
7 /**
8 *
9 */
10 import java.awt.Color;
11 import java.awt.Graphics;
12
13 /**
14 *
15 * @author niko y lina
16 *
17 *
18 */
19 /** Esta clase es la que dibuja el cañon del cliente*/
20 public class Cañi extends ObjetoGrafico {
21
22 /**
23 * @param x posicion de cañi
24 * @param y posicion de csñi
25 * @param ancho el ancho de el cañi
26 * @param alto la altura de el cañi
27 */
28 public Cañi(int x, int y, int ancho, int alto) {
29 super(x, y, ancho, alto);
30 }
31
32 /** Es el metodo para pintar la pared
33 * @param g es la clase base para todo contexto grafico
34 */
35 public void paint(Graphics g) {
36
37 // bajo
38 g.setColor(Color.BLACK);
39 int[] bajox = {
40 x + 210 * ancho / 210,
41 x + 160 * ancho / 210,
42 x + 50 * ancho / 210,
43 x + 0 * ancho / 210,};
44 int[] bajoy = {
45 y + 290 * alto / 290,
46 y + 200 * alto / 290,
47 y + 200 * alto / 290,
48 y + 290 * alto / 290,};
49 g.fillPolygon(bajox, bajoy, 4);
50 //boca
51 g.setColor(Color.BLACK);
52 int[] bocax = {
53 x + 140 * ancho / 210,
54 x + 70 * ancho / 210,
55 x + 70 * ancho / 210,
56 x + 140 * ancho / 210,};
57 int[] bocay = {
58 y + 0 * alto / 290,
59 y + 0 * alto / 290,
60 y + 200 * alto / 290,
61 y + 200 * alto / 290,};
62 g.fillPolygon(bocax, bocay, 4);
63 //espina1
64 g.setColor(Color.red);
65 int[] espina1x = {
66 x + 70 * ancho / 210,
67 x + 0 * ancho / 210,
68 x + 70 * ancho / 210,};
69 int[] espina1y = {
70 y + 20 * alto / 290,
71 y + 50 * alto / 290,
72 y + 80 * alto / 290,};
73 g.fillPolygon(espina1x, espina1y, 3);
74 //espina2
75 g.setColor(Color.red);
76 int[] espina2x = {
77 x + 70 * ancho / 210,
78 x + 0 * ancho / 210,
79 x + 70 * ancho / 210,};
80 int[] espina2y = {
81 y + 110 * alto / 290,
82 y + 140 * alto / 290,
83 y + 170 * alto / 290,};
84 g.fillPolygon(espina2x, espina2y, 3);
85 //espina3
86 g.setColor(Color.red);
87 int[] espina3x = {
88 x + 210 * ancho / 210,
89 x + 140 * ancho / 210,
90 x + 140 * ancho / 210,};
91 int[] espina3y = {
92 y + 50 * alto / 290,
93 y + 20 * alto / 290,
94 y + 80 * alto / 290,};
95 g.fillPolygon(espina3x, espina3y, 3);
96 //espina4
97 g.setColor(Color.red);
98 int[] espina4x = {
99 x + 210 * ancho / 210,
100 x + 140 * ancho / 210,
101 x + 140 * ancho / 210,};
102 int[] espina4y = {
103 y + 140 * alto / 290,
104 y + 110 * alto / 290,
105 y + 170 * alto / 290,};
106 g.fillPolygon(espina4x, espina4y, 3);
107 }
108 }
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
