Pacman En Java
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import interfaz.VentanaPrincipal;
public class Fantasma extends JLabel implementsRunnable
{
public int velocidad;
public boolean continuar=true;
public boolean derecha=true;
public boolean izquierda=false;
public boolean arriba=false;
public boolean abajo=false;public boolean pintar=true;
int i;
int j;
VentanaPrincipal e;
public boolean estaMuerto=true;
String url;
JLabel[][] e2;
public Fantasma(int x, int y,JLabel [][] e2, boolean estaMuerto,VentanaPrincipal e)
{
this.setIcon(new ImageIcon("src/fotos/green.gif"));
i=x;
j=y;
this.e=e;
this.estaMuerto=estaMuerto;
this.e2=e2;
while(true)
{
int aux =(int)(Math.random()*501);
if(aux>100)
{
velocidad = aux;
break;
}
}
}
public void run()
{
estaMuerto=false;
try
{
while(true)
{if(continuar==true){
if(e.miPacman.getX()>i && e.miPacman.getY()diferenciaY){
subir();
}
else
if(diferenciaXdiferenciaY){
bajar();
}
elseif(diferenciaX0)
subir();
else
if(j-e.miPacman.getY()0)
girarIzquierda();
else
if(i-e.miPacman.getX()=0)
{j--;
e.getMundo()[i][j].setIcon(new ImageIcon("src/fotos/green.gif"));
e.getMundo()[i][j+1].setIcon(new ImageIcon("src/fotos/mundo.PNG"));
}
}
public voidbajar()
{
if(j+1=0)
{
i--;
e.getMundo()[i][j].setIcon(new ImageIcon("src/fotos/green.gif"));
e.getMundo()[i+1][j].setIcon(new ImageIcon("src/fotos/mundo.PNG"));
}}
public void girarDerecha(){
if(i+1=0)
{
if(ven.getTablero()[x][y-1]==1)
{
y--;
ven.getTablero()[x][y]=0;
ven.reproducirComida();
puntaje+=50;...
Regístrate para leer el documento completo.