me parece que debo usar temporizadores.. como se usan..
les dejo parte del codigo para que vean como lo estoy trabajando...
Código:
char mapa[MAXFILAS][MAXCOLS]={
"A A",
"A A",
"A A",
"A S S A",
"A A",
"ASSSSSSSSSSSSSSSSSSSSSSSSSSSSSA",
"XXXXXXXEXXXXXXXXXXXXXXXXXXXXXX ",
"A S E S A",
"A A",
"ASSSSSSSSSSSSSSSSSSSSSSSSSSSSSA",
"XXFXXXXXXXXXEXXXXXXFXXXXXXXXXX ",
"AS E S S A",
"A A",
"ASSSSSSSSSSSSSSSSSSSSSSSSSSSSSA",
"XFXXXXXEXXXXXXXXXXXXEXXXXXXXXX ",
"A E E A",
"A A",
"ASSSSSSSSSSSSSSSSSSSSSSSSSSSSSA",
"XXXXFXXXXXXXXEXXXXXXXXXXEXXXXX ",
"AS E E SA",
"A A",
"ASSSSSSSSSSSSSSSSSSSSSSSSSSSSSA",
"XXXXXEXXXXXXXXXXXFXXXXXXXXXXXX ",
"A S E A",
"A A",
"A SSSSSSSSSSSSSSSSSSSSSSA",
"LLLLLLLLLLLLLLLLLLLLLLLLLLLLLL"
};
for(i=0; i<MAXCOLS; i++)
for (j=0; j<MAXFILAS; j++)
{
if (mapa[j][i]=='X')
draw_sprite(buffer, nube, i*ESCALA, j*ESCALA);
if (mapa[j][i]=='F')
draw_sprite(buffer, ladrillo, i*ESCALA, j*ESCALA);
if (mapa[j][i]=='S')
draw_sprite(buffer,mon, i*ESCALA, j*ESCALA);
if (mapa[j][i]=='E')
draw_sprite(buffer,esc, i*ESCALA, j*ESCALA);
if (mapa[j][i]=='L')
draw_sprite(buffer,suelo, i*ESCALA, j*ESCALA);
}
//carga objetos
if ( keypressed() )
{
tecla=readkey()>>8;
switch (tecla)
{
case KEY_UP:
if(mapa[posYPLAYER-1][posXPLAYER]=='E')
posYPLAYER-=1;
if(mapa[posYPLAYER][posXPLAYER]=='E')
posYPLAYER-=1;
if(mapa[posYPLAYER+1][posXPLAYER]=='E')
posYPLAYER-=1;
break;
case KEY_DOWN:
if(mapa[posYPLAYER+2][posXPLAYER]=='E')
posYPLAYER+=1;
if(mapa[posYPLAYER][posXPLAYER]=='E')
posYPLAYER+=1;
break;
case KEY_LEFT:
if(mapa[posYPLAYER][posXPLAYER-1]!='A')
posXPLAYER-=1;break;
case KEY_RIGHT:
if(mapa[posYPLAYER][posXPLAYER+1]!='A')
posXPLAYER+=1;break;
case KEY_S:
posYPLAYER-=2;
// draw_sprite (buffer,icono, posXPLAYER*ESCALA, posYPLAYER*ESCALA);
// blit(buffer, screen, 0,0,0,0,SCREEN_W,SCREEN_H);
posYPLAYER+=2;
// draw_sprite (buffer,icono, posXPLAYER*ESCALA, posYPLAYER*ESCALA);
// blit(buffer, screen, 0,0,0,0,SCREEN_W,SCREEN_H);
}
}
//SOLOO MOVIMIENTO
textprintf(buffer,font,1,24,palette_color[14],"Monedas: %d",monedas);
blit(buffer, screen, 0,0,0,0,SCREEN_W,SCREEN_H);
}//fin while
y queda asi.. come las monedas.. igual...