Cañon.java

Categorías: CategoryJava | CategoryProgramacion

   1 /**
   2  *@author Elkin Andrey Garzón Alarcón...Geek Master
   3  *@author Ingrid Lorena Guerrero Mayorga...
   4  *@author Jefferson Fabian Idarraga Idarraga Pinilla...
   5  */
   6 package pinguinogg;
   7 
   8 import java.awt.Color;
   9 import java.awt.Graphics;
  10 
  11 public class Cañon extends ObjetoGrafico {
  12 
  13     //private int x, y, ancho, alto;
  14 
  15     public Cañon(int x, int y, int ancho, int alto) {
  16         super(x, y, ancho, alto);
  17     }
  18 /*
  19  * parametros para la creacion del cañon 
  20  */
  21     public void paint(Graphics g) {
  22         //cañon
  23         g.setColor(new Color(87, 81, 77));
  24         int[] cañon1X = {
  25             x + 135 * ancho / 190,
  26             x + 135 * ancho / 190,
  27             x + 55 * ancho / 190,
  28             x + 55 * ancho / 190,};
  29         int[] cañon1Y = {
  30             y + 100 * alto / 130,
  31             y + 20 * alto / 130,
  32             y + 20 * alto / 130,
  33             y + 100 * alto / 130,};
  34         g.fillPolygon(cañon1X, cañon1Y, 4);
  35 
  36         //borde
  37         g.setColor(new Color(77, 47, 49));
  38         int[] bordeX = {
  39             x + 135 * ancho / 190,
  40             x + 135 * ancho / 190,
  41             x + 55 * ancho / 190,
  42             x + 55 * ancho / 190,};
  43         int[] bordeY = {
  44             y + 20 * alto / 130,
  45             y + 25 * alto / 130,
  46             y + 25 * alto / 130,
  47             y + 20 * alto / 130,};
  48         g.fillPolygon(bordeX, bordeY, 4);
  49 
  50         // base
  51 
  52         g.setColor(new Color(125, 71, 53));
  53         int[] baseX = {
  54             x + 190 * ancho / 190,
  55             x + 190 * ancho / 190,
  56             x + 0 * ancho / 190,
  57             x + 0 * ancho / 190,};
  58         int[] baseY = {
  59             y + 130 * alto / 160,
  60             y + 110 * alto / 160,
  61             y + 110 * alto / 160,
  62             y + 130 * alto / 160,};
  63         g.fillPolygon(baseX, baseY, 4);
  64 
  65         //piko 1
  66 
  67         g.setColor(new Color(77, 47, 49));
  68         int[] piko1X = {
  69             x + 55 * ancho / 190,
  70             x + 40 * ancho / 190,
  71             x + 55 * ancho / 190,};
  72         int[] piko1Y = {
  73             y + 20 * alto / 130,
  74             y + 30 * alto / 130,
  75             y + 40 * alto / 130,};
  76         g.fillPolygon(piko1X, piko1Y, 3);
  77 
  78         //piko 2
  79 
  80         g.setColor(new Color(77, 47, 49));
  81         int[] piko2X = {
  82             x + 135 * ancho / 190,
  83             x + 150 * ancho / 190,
  84             x + 135 * ancho / 190,};
  85         int[] piko2Y = {
  86             y + 20 * alto / 130,
  87             y + 30 * alto / 130,
  88             y + 40 * alto / 130,};
  89         g.fillPolygon(piko2X, piko2Y, 3);
  90 
  91         //esquina 1
  92 
  93         g.setColor(new Color(77, 47, 49));
  94         int[] esquina1X = {
  95             x + 55 * ancho / 190,
  96             x + 0 * ancho / 190,
  97             x + 55 * ancho / 190,};
  98         int[] esquina1Y = {
  99             y + 60 * alto / 130,
 100             y + 90 * alto / 130,
 101             y + 90 * alto / 130,};
 102         g.fillPolygon(esquina1X, esquina1Y, 3);
 103 
 104         //esquina 2
 105 
 106         g.setColor(new Color(77, 47, 49));
 107         int[] esquina2X = {
 108             x + 190 * ancho / 190,
 109             x + 135 * ancho / 190,
 110             x + 135 * ancho / 190,};
 111         int[] esquina2Y = {
 112             y + 90 * alto / 130,
 113             y + 60 * alto / 130,
 114             y + 90 * alto / 130,};
 115         g.fillPolygon(esquina2X, esquina2Y, 3);
 116 
 117 
 118     }
 119 
 120     public void incX(int dx) {
 121         x += dx;
 122     }
 123 
 124     public void decX(int dx) {
 125         x -= dx;
 126     }
 127 
 128     public void incY(int dy) {
 129         y += dy;
 130     }
 131 
 132     public void decY(int dy) {
 133         y -= dy;
 134     }
 135 }

Java/Programas/PinguinoGg/Cañon.java (last edited 2010-10-28 11:43:52 by LorenaGuerrero)