if you want the working version, download it from the website I mentioned earlier
Code: Select all
short lvl;
bool done,s;
int xp,yp,c,d,xvg,oxy,money;
int cou[EMAX];
char sc[EMAX];
int iac[EMAX];
int EMYCT;
int rrx,rry;
string gstr="";
char recover;
char tostr[1];
int xguy,yguy,width,height,pm,xg,yg,yl,xn,yn,life,jumpcount,fallh;
int var[2];
int varg[1];
int emx[EMAX];
int emy[EMAX];
int epm[EMAX];
bool elive[EMAX];
int vare[1];
brk map[500];
task engine()
{
int punchadd;
while(1)
{
GraphicOutEx(xg,yl,"guy.ric",varg);
if(ButtonPressed(BTNCENTER,0) && SENSOR_1)
{
until(!SENSOR_1);
rrx=0;
rry=height;
xvg=width;
s=1;
Wait(100);
ClearScreen();
TextOut(70,LCD_LINE3,StrCat("$",NumToStr(money)));
TextOut(70,LCD_LINE2,StrCat("HP:",NumToStr(life)));
for(int xv=0; xv < ArrayLen(map); xv++)
{
if(xv == xvg)
{
xvg+=width;
rry--;
rrx=0;
}
if(map[xv].SLD == 1)
{
PointOut(rrx,rry);
}
rrx++;
}
until(SENSOR_1);
until(!SENSOR_1);
d=(xguy/16*-1)+width*(yguy/16*-1)+7;
c=(xguy/16*-1)+width*(yguy/16*-1);
xp=0;
yp=48;
s=0;
until(done);
}
repeat(2)
{
if(ButtonPressed(BTNCENTER,0) && !SENSOR_1)//Jump/climb
{
until(!ButtonPressed(BTNCENTER,0));
if((map[pm-width].SLD == 0 || (OnTile(pm,32,16) && map[pm-width].SLD == 0)) && jumpcount < 2 && map[pm-width].alv == 0)
{
jumpcount++;
if(pv == rit)
pv=ritj;
else if(pv == lft)
pv=lftj;
if(yl == 32)
{
yn=16;
yguy+=16;
repeat(4)
{
yn-=4;
GraphicOutEx(xg,yl,"guy.ric",varg);
AfterMove(25);
DrawEMY(0,-4);
}
yn=0;
AfterMove(0);
DrawEMY();
}
else if(yl != 32)
{
repeat(4)
{
RectOut(xg,yl,11,11,DRAW_OPT_CLEAR | DRAW_OPT_FILL_SHAPE);
yl+=4;
GraphicOutEx(xg,yl,"guy.ric",varg);
AfterMove(25);
}
}
pm-=width;
}
}
}
if(ButtonPressed(BTNRIGHT,0))
{
pv=rit;
if(map[pm+1].SLD == 0 && map[pm+1].alv == 0)
{
PlayFileEx("step.rso",Volume(),0);
if(width-(xguy/16*-1) > 7)
{
/* for(int e=0; e < EMYCT; e++)
{
emx[e]-=16;
}*/
xn=16;
xguy-=16;
repeat(4)
{
xn-=4;
GraphicOutEx(xg,yl,"guy.ric",varg);
AfterMove(25);
DrawEMY(-4,0);
}
xn=0;
AfterMove(0);
}
else
{
repeat(4)
{
RectOut(xg,yl,11,11,DRAW_OPT_CLEAR | DRAW_OPT_FILL_SHAPE);
xg+=4;
GraphicOutEx(xg,yl,"guy.ric",varg);
AfterMove(25);
}
}
pm++;
}
}
if(ButtonPressed(BTNLEFT,0))
{
pv=lft;
if(map[pm-1].SLD == 0 && map[pm-1].alv == 0)
{
PlayFileEx("step.rso",Volume(),0);
if(xg == 16)
{
/* for(int e=0; e < EMYCT; e++)
{
emx[e]+=16;
}*/
xguy+=16;
xn=-16;
repeat(4)
{
xn+=4;
GraphicOutEx(xg,yl,"guy.ric",varg);
AfterMove(25);
DrawEMY(4,0);
}
xn=0;
AfterMove(0);
}
else if(xg != 16)
{
repeat(4)
{
RectOut(xg,yl,11,11,DRAW_OPT_CLEAR | DRAW_OPT_FILL_SHAPE);
xg-=4;
GraphicOutEx(xg,yl,"guy.ric",varg);
AfterMove(25);
}
}
pm--;
}
}
if(map[pm+width].SLD == 0 && map[pm+width].alv == 0)//Fall down
{
if((OnTile(pm+width,32,16) && ButtonPressed(BTNEXIT,0)) || !OnTile(pm+width,32,16))
{
fallh++;
if(pv == rit)
pv=ritj;
else if(pv == lft)
pv=lftj;
if(height-yguy/16*-1 > 4)
{
yguy-=16;
yn=-16;
repeat(4)
{
yn+=4;
GraphicOutEx(xg,yl,"guy.ric",varg);
AfterMove(25);
RectOut(0,60,100,4,DRAW_OPT_CLEAR | DRAW_OPT_FILL_SHAPE);
DrawEMY(0,4);
}
yn=0;
AfterMove(0);
}
else
{
repeat(4)
{
RectOut(xg,yl,11,11,DRAW_OPT_CLEAR | DRAW_OPT_FILL_SHAPE);
yl-=4;
GraphicOutEx(xg,yl,"guy.ric",varg);
AfterMove(25);
}
}
pm+=width;
if(pv == ritj)
pv=rit;
else if(pv == lftj)
pv=lft;
}
}
}
}
//draw the map tile by tile
task displaymap()
{
unsigned long t0;
while(1)
{
done=0;
until(s == 0);
d=(xguy/16*-1)+width*(yguy/16*-1)+7;
c=(xguy/16*-1)+width*(yguy/16*-1);
xp=0;
yp=48;
until(c >= ((xguy/16*-1)+width*(yguy/16*-1))+width*4) //loops until the y axis of the row is below the screen
{
until(c==d)
{
if(s == 1)
goto end;
var[0]=map[c].X;
var[1]=map[c].Y;
GraphicOutEx(xn+xp,yn+yp,"gmtilesb.ric",var);//draw a tile at the x axis of xn+xp, y axis of yn+yp
//yn and xn are variables to make moving from tile to tile smoothly possible
xp+=16; //make the x axis of the next tile drawn 16 pixels to the right
c++;
}
//go to the next line
yp-=16;
xp=0;
d+=width;
c+=width-7;
}
done=1;
Wait(20);
end:
}
}