import greenfoot.*;
public class felix extends Actor
{
int indiceX=0;
int indiceY=0;
coordenada plano= new coordenada;
public boolean posible(int incrementox, int incrementoy)
{ if( indiceX+incrementox>=0 && indiceX+incrementox<5 && indiceY+incrementoy>=0 && indiceY+incrementoy<3)
return true; else return false; }
public void salta(int direccion)
{coordenada posicion;
posicion=new coordenada();
posicion= plano;
if (posicion.x != plano.x)
{ posicion.x+= direccion; }
int distancia;
if (direccion>0)
{ distancia=plano.x-posicion.x;}
else
{ distancia=(plano.x+posicion.x);}
int altura=distancia/2;
boolean flag=false;
if (posicion.y<altura)
{posicion.y--;}
if (flag== true)
{if (posicion.y>plano .y)
{posicion.y++;}
}
if (posicion.y==altura)
{flag=true;}
setLocation (posicion.x,posicion.y);
}
public felix()
{ coordenada token= new coordenada();
token.x=115; token.y=304; plano=token;
token.x=196; token.y=304; plano=token;
token.x=299; token.y=304; plano=token;
token.x=399; token.y=304; plano=token;
token.x=476; token.y=304; plano=token;
token.x=115; token.y=486; plano=token;
token.x=196; token.y=486; plano=token;
token.x=299; token.y=486; plano=token;
token.x=399; token.y=486; plano=token;
token.x=476; token.y=486; plano=token;
token.x=115; token.y=606; plano=token;
token.x=196; token.y=606; plano=token;
token.x=299; token.y=606; plano=token;
token.x=399; token.y=606; plano=token;
token.x=476; token.y=606; plano=token;
}
public void act()
{
if(Greenfoot.isKeyDown("left")==true)
{ if(posible(-1,0)==true) { salta(-1); } }
if(Greenfoot.isKeyDown("right")==true)
{ if(posible(+1,0)==true) { salta(1); }}
}
}

