PoderDePinguino.java
1
2
3
4
5
6 import java.awt.Color;
7 import java.awt.Graphics;
8
9 public class PoderDePinguino extends ObjetoGrafico implements Runnable{
10 private Lienzo lienzo;
11 private Fantasma[] fantasma;
12 private Pared[] paredes;
13 private FantasmaEvolucion[] fantasmasEvolucion;
14 public PoderDePinguino (int x, int y, int a, int e, Lienzo l, Fantasma[] fantasmas, Pared[] pareds, FantasmaEvolucion[] fantasmaEvolucions) {
15 super(x, y, a ,e);
16 lienzo = l;
17 fantasma = fantasmas;
18 paredes = pareds;
19 fantasmasEvolucion = fantasmaEvolucions;
20 }
21 public void paint (Graphics g){
22 if(visible){
23 g.setColor(Color.cyan);
24 g.fillOval(getPosX(), getPosY(), getAncho(), getAlto());
25 }
26 }
27 public void run(){
28 for (;;){
29 moverDerecha(10);
30 for(int i = 0; i < fantasma.length; i++){
31 if(colisiona(fantasma[i])){
32 setVisible(false);
33 fantasma[i].setVisible(false);
34 fantasma[i].setPosY(1000);
35 }
36 }
37 for(int j=0; j < paredes.length;j++){
38 if(colisiona(paredes[j])){
39 setVisible(false);
40
41
42
43
44 }
45 }
46 for (int h = 0; h < fantasmasEvolucion.length; h++){
47 if (colisiona(fantasmasEvolucion[h])){
48 setVisible(false);
49 fantasmasEvolucion[h].setVisible(false);
50 fantasmasEvolucion[h].setPosY(1000);
51 }
52 }
53 lienzo.repaint();
54 try{Thread.sleep(50);}catch(Exception e){}
55 }
56 }
57 }
CategoryJava | CategoryProgramacion
Java/Programas/MazeDallcu/PoderDePinguino.java (last edited 2008-11-13 15:09:50 by UldySoto)