Escolar Documentos
Profissional Documentos
Cultura Documentos
package Unidad_4;
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
ban[ind]=0;
}
{
g.setColor(Color.WHITE);
Font fb2 = new Font("TimesNewRoman",Font.BOLD,20);
g.setFont(fb2);
g.drawString("GAME OVER PRESIONA F1 PARA COMENZAR DE NUEVO",
100, 100);
}
g.setColor(Color.BLUE);
Font fb = new Font("TimesNewRoman",Font.BOLD,50);
g.setFont(fb);
if(t==1)
{
g.drawString(titulo, 300,50);
Retardo(2000);
t=0;
}
g.setColor(Color.YELLOW);
g.drawImage(pacman,cordx,cordy,100,100,this);//pacman
//g.fillArc(cordx, cordy, 100, 100,angi,rad); // dibuja a pacman
g.setColor(Color.red);
g.fillRect(300,200,100,100);// cuadro 1
g.fillRect(700,200,100,100);// cuadro 2
g.fillRect(300,450,100,100);// cuadro 3
g.fillRect(700,450,100,100);// cuadro 4
}
switch(key)
{
case KeyEvent.VK_UP:
imagen="pacman up.png";
pacman=getImage(getDocumentBase(),imagen);
if((cordx>=250 && cordx<=350) && cordy==300 || (cordx>=650
&& cordx<=750) && cordy==300 ||(cordx>=250 && cordx<=350) && cordy==550 || (cordx>=650
&& cordx<=750) && cordy==550)
// cuadro 3
{ // cuadro 1
// cuadro 4
// cuadro 2
}
else
{
cordy-=50;
angi=30;
rad=-240;
}
if(ban[0]==0)
{
puntaje+=10000;
ban[0]=1;
}
}
if(cordx==400 && cordy==200) //validacion comida 2
{
c2=1;
if(ban[1]==0)
{
puntaje+=10000;
ban[1]=1;
}
}
if(cordx==600 && cordy==200) //validacion comida 3
{
c3=1;
if(ban[2]==0)
{
puntaje+=10000;
ban[2]=1;
}
}
if(cordx==800 && cordy==200) //validacion comida 4
{
c4=1;
if(ban[3]==0)
{
puntaje+=10000;
ban[3]=1;
}
}
if(cordx==200 && cordy==450) //validacion comida 5
{
c5=1;
if(ban[4]==0)
{
puntaje+=10000;
ban[4]=1;
}
}
if(cordx==400 && cordy==450) //validacion comida 6
{
c6=1;
if(ban[5]==0)
{
puntaje+=10000;
ban[5]=1;
}
}
if(cordx==600 && cordy==450) //validacion comida 7
{
c7=1;
if(ban[6]==0)
{
puntaje+=10000;
ban[6]=1;
}
}
if(cordx==800 && cordy==450) //validacion comida 8
{
c8=1;
if(ban[7]==0)
{
puntaje+=10000;
ban[7]=1;
}
}
break;
case KeyEvent.VK_DOWN:
imagen="pacman down.png";
pacman=getImage(getDocumentBase(),imagen);
if((cordx>=250 && cordx<=350) && cordy==100 || (cordx>=650
&& cordx<=750) && cordy==100 ||(cordx>=250 && cordx<=350) && cordy==350 || (cordx>=650
&& cordx<=750) && cordy==350)
// cuadro 3
{ // cuadro 1
// cuadro 4
// cuadro 2
}
else
{
cordy+=50;
angi=-30;
rad=240;
}
{
puntaje+=10000;
ban[1]=1;
}
}
if(cordx==600 && cordy==200) //validacion comida 3
{
c3=1;
if(ban[2]==0)
{
puntaje+=10000;
ban[10]=1;
}
}
if(cordx==800 && cordy==200) //validacion comida 4
{
c4=1;
if(ban[3]==0)
{
puntaje+=10000;
ban[3]=1;
}
}
if(cordx==200 && cordy==450) //validacion comida 5
{
c5=1;
if(ban[4]==0)
{
puntaje+=10000;
ban[4]=1;
}
}
if(cordx==400 && cordy==450) //validacion comida 6
{
c6=1;
if(ban[5]==0)
{
puntaje+=10000;
ban[5]=1;
}
}
if(cordx==600 && cordy==450) //validacion comida 7
{
c7=1;
if(ban[6]==0)
{
puntaje+=10000;
ban[6]=1;
}
}
if(cordx==800 && cordy==450) //validacion comida 8
{
c8=1;
if(ban[7]==0)
{
puntaje+=10000;
ban[7]=1;
}
}
case KeyEvent.VK_LEFT:
imagen="pacman left.png";
pacman=getImage(getDocumentBase(),imagen);
if(cordx==400 && (cordy>=150 && cordy<=250) || cordx==800 &&
(cordy>=150 && cordy<=250) || cordx==400 && (cordy>=400 && cordy<=500) || cordx==800 &&
(cordy>=400 && cordy<=500))
// cuadro 3
{ // cuadro 1
// cuadro 4
}
else
{
cordx-=50;
angi=120;
rad=-240;
// cuadro 2
ban[5]=1;
}
}
if(cordx==800 && cordy==450) //validacion comida 8
{
c8=1;
if(ban[7]==0)
{
puntaje+=10000;
ban[7]=1;
}
}
case KeyEvent.VK_RIGHT:
imagen="pacman right.png";
pacman=getImage(getDocumentBase(),imagen);
if(cordx==200 && (cordy>=150 && cordy<=250) || cordx==600 &&
(cordy>=150 && cordy<=250) || cordx==200 && (cordy>=400 && cordy<=500) || cordx==600 &&
(cordy>=400 && cordy<=500))
// cuadro 3
{ // cuadro 1
// cuadro 4
}
// cuadro 2
else
{
cordx+=50;
angi=60;
rad=240;
}
{
c5=1;
if(ban[4]==0)
{
puntaje+=10000;
ban[4]=1;
}
}
if(cordx==600 && cordy==450) //validacion comida 7
{
c7=1;
if(ban[6]==0)
{
puntaje+=10000;
ban[6]=1;
}
}
c1=0;c2=0;c3=0;c4=0;c5=0;c6=0;c7=0;c8=0;puntaje=0;t=1;cordx=500;cordy=350;
for(ind=0;ind<8;ind++)
ban[ind]=0;
}
repaint();
}
}
switch(key)
{
case KeyEvent.VK_UP:
angi=60;
rad=-300;
break;
case KeyEvent.VK_DOWN:
angi=-60;
rad=300;
break;
case KeyEvent.VK_LEFT:
angi=150;
rad=-300;
break;
case KeyEvent.VK_RIGHT:
angi=30;
rad=300;
}
repaint();
}