Page 1 of 2

Help with efficiency of code

Posted: 16 Nov 2010, 22:16
by nxtboyiii
Can someone help me with making this program take up less space on NXT?
I need a more efficient way to get the maps instead of making each one an array.
I could do it by making each map a txt file, but I don't know how to make it read and write the map to the variable "map".

Code: Select all

#download "tiles.ric"
#download "guy.ric"
#download "PROPTINY.ric"
#download "PUNCH.rso"
#download "blacksmith.ric"
#download "blacksmith2.ric"

#define EMY {88,88}
#define SHP {80,88}
#define SVR {64,88}
#define GLD {72,88}
#define SBB {56,88}
#define SWD {88,64}
#define SPX {0,88}
#define GRY {48,88}
#define BLK {8,88}
#define TVL {40,88}
#define VIN {88,16}
#define WTR {40,72}
#define AIR {88,8}
#define COL {64,72}
#define TOC {80,16}
#define PTL {32,88}
#define BBK {48,80}
#define BRK {56,80}
#define STR {64,64}
#define SRR {72,64}
#define STL {80,64}
#define LNS {88,56}


#define sFontTextOut(_x,_y,_fn,_txt,_opt,_hd); _hd.Location.X=_x; _hd.Location.Y=_y; _hd.Filename=_fn; _hd.Text=_txt; _hd.Options=_opt; SysDrawFont(_hd);
#define sGraphicOut(_x,_y,_fn,_opt,_hd); _hd.Location.X=_x; _hd.Location.Y=_y; _hd.Filename=_fn; ; _hd.Options=_opt; SysDrawGraphic(_hd);
#define sGraphicOutEx2(_x,_y,_fn,_var,_opt,_hd); _hd.Location.X=_x; _hd.Location.Y=_y; _hd.Filename=_fn; ArrayInit(_hd.Variables,0,3); _hd.Variables[0]=_var[0]; _hd.Variables[1]=_var[1];_hd.Options=_opt; SysDrawGraphic(_hd);
#define sGraphicOutEx1(_x,_y,_fn,_var,_opt,_hd); _hd.Location.X=_x; _hd.Location.Y=_y; _hd.Filename=_fn; ArrayInit(_hd.Variables,0,2); _hd.Variables[0]=_var[0]; _hd.Options=_opt; SysDrawGraphic(_hd);

//#define map2 {BRK,AIR,AIR,AIR,AIR,AIR,AIR,AIR,GRY,GRY,BLK,BLK,BLK,BLK,BLK,AIR,AIR,PTL,BRK,BRK,BRK,BRK,AIR,AIR,AIR,AIR,AIR,GRY,BRK,STR,STR,STR,BLK,BLK,GRY,AIR,STR,BRK,BRK,WTR,BBK,AIR,AIR,AIR,AIR,AIR,TVL,GRY,BLK,BLK,STR,BLK,BLK,GRY,GRY,STR,BRK,BRK,BRK,STR,AIR,AIR,AIR,AIR,AIR,GRY,GRY,BLK,STL,STR,BBK,BLK,GRY,GRY,STR,BRK,BRK,AIR,STR,BRK,BRK,BRK,BRK,BRK,GRY,GRY,STL,BRK,BRK,BRK,BLK,GRY,STL,BRK,BRK,BRK,AIR,STR,AIR,AIR,AIR,AIR,AIR,GRY,STL,BRK,BLK,BLK,BLK,BLK,STL,BRK,BLK,BRK,BRK,AIR,STR,AIR,VIN,AIR,AIR,AIR,GRY,BRK,BLK,BLK,BLK,BLK,BLK,BRK,BLK,BLK,BRK,BRK,AIR,BRK,BRK,VIN,AIR,AIR,AIR,WTR,GRY,BLK,BLK,BLK,BLK,WTR,GRY,BLK,BLK,BRK};
bool notify=1;
int money;
bool bSword=0;
int bx=0;
bool done=0;
int x;
long life=1500;
int y;
bool s;
int d=24;
int c;
int xp;
int yp=56;
int yl;
long lvl=1;
int pm;
long var[2];
int var2[1];
DrawGraphicType gt1;
DrawGraphicType gt2;
DrawFontType ft1;
//short map[][]={{}};
LocationType map5[]={
BRK,BRK,BRK,BRK,BRK,BRK,BRK,BRK,BRK,TOC,BRK,BRK,BRK,BRK,BRK,AIR,BBK,BBK,BRK,
BRK,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,COL,AIR,BRK,PTL,BBK,BBK,STR,BRK,AIR,BRK,
BRK,AIR,AIR,AIR,AIR,AIR,BBK,BBK,BBK,COL,AIR,BBK,AIR,BRK,BRK,STR,BRK,AIR,BRK,
BRK,AIR,AIR,AIR,STL,BRK,BRK,BRK,BRK,BRK,BRK,BRK,AIR,BBK,BRK,STR,BRK,AIR,PTL,
BRK,AIR,AIR,AIR,STL,AIR,AIR,AIR,AIR,COL,AIR,BRK,BRK,AIR,BR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AIR,AIR,AIR,BRK,
};


bool OnTile(int Xtile,int Ytile)
{
return(map[pm].X == Xtile && map[pm].Y == Ytile);
}

bool NotOnTile(int Xtile,int Ytile)
{
return(!(map[pm].X == Xtile && map[pm].Y == Ytile));
}
#define Buy(_scost,_alh)\
{                   \
  sFontTextOut(5,58,"PROPTINY.ric",StrCat("$",NumToStr(_scost)),DRAW_OPT_FONT_WRAP,ft1);     \
  if(money >= _scost && !_alh)                                                                     \
  {                                                                                       \
   sFontTextOut(35,46,"PROPTINY.ric","Creating...",0x00,ft1);                                  \
   int varb[1];                                                                             \
   for(int c=0; c < 10; c++)                                                                 \
   {                                                                                          \
   varb[0]=0;                                                                                  \
   sGraphicOutEx1(0,0,"blacksmith2.ric",varb,0x00,gt1);                                             \
   Wait(500);                                                                                     \
   ClearScreen();                                                                                \
   varb[0]=23;                                                                                     \
   sGraphicOutEx1(0,0,"blacksmith2.ric",varb,0x00,gt1);                                                 \
   Wait(500);                                                                                        \
   ClearScreen();                                                                                     \
   }                                                                                                    \
   _alh=1;                                                                                     \
   money-=_scost;                                                                                        \
   sFontTextOut(35,46,"PROPTINY.ric","Bought!",0x00,ft1);                                                    \
   sGraphicOut(0,0,"blacksmith.ric",0x00,gt1);                                                                \
   Wait(1000);                                                                                              \
   ClearScreen();                                                                                           \
  }                                                                                                          \
  else if(money < _scost && !_alh)                                                                                      \
  {                                                                                                            \
  sGraphicOut(0,0,"blacksmith.ric",0x00,gt1);                                                                       \
    sFontTextOut(35,46,"PROPTINY.ric","I don't need poor people in my shop. Get outa here you lazy bum.",DRAW_OPT_FONT_WRAP,ft1); \
    Wait(3000);                                                                                                   \
  }                                                                                                                  \
  else if(_alh){sFontTextOut(35,46,"PROPTINY.ric","You already have that, dummie.",DRAW_OPT_FONT_WRAP,ft1);Wait(1500); ClearScreen();}                                                                                                               \
}


task n2()
{
int ys;
Wait(500);
 while(1)
{
 sGraphicOutEx1(40,yl,"guy.ric",var2,0x00,gt1);
if(map[pm].X == 64 && map[pm].Y == 88)
{
money+=5;
map[pm].X = 88;
map[pm].Y = 8;
}
if(map[pm].X == 72 && map[pm].Y == 88)
{
money+=10;
map[pm].X = 88;
map[pm].Y = 8;
}
/*if(money >= 70 && notify)
{
 s=1;
 Wait(300);
 ClearScreen();
until(ButtonPressed(BTNLEFT,0) || ButtonPressed(BTNRIGHT,0))
{
 RectOut(0,0,99,63);
 TextOut(0,LCD_LINE2,"Buy sword? $70",0x00,ft1);
 TextOut(0,LCD_LINE3,"HoldLeftOrRight",0x00,ft1);

 }
 if(ButtonPressed(BTNLEFT,0))
 {
 bSword=1;
 money -= 70;
 }
 d=width;
c=0;
xp=0;
yp=56;
ClearScreen();
s=0;
 until(done);
 Wait(500);
} */
/*if(ButtonPressed(BTNLEFT,0) && ButtonPressed(BTNRIGHT,0))
{
 s=1;
Wait(320);
d=width;
c=0;
xp=0;
yp=56;
s=0;
}*/
if(life <= 0)
{
s=0;
Wait(500);
TextOut(0,LCD_LINE4,"You DIED.");
Wait(3000);
StopAllTasks();
}
if(map[pm].X == 64 && map[pm].Y == 88)
{
money++;
}
if(map[pm].X==0 && map[pm].Y ==88)
{
StopAllTasks();
}
if(map[pm].X == 32 && map[pm].Y == 88)
{
 s=1;
 Wait(100);
/* for(int e=0; e < ArrayLen(map); e++)
 {
 map[e].X=Random(13)*8;
 map[e].Y=Random(13)*8;
 }      */
 x=0;
 yl=0;
  if(lvl == 1)
 {
 width=19;

 }
  if(lvl == 2)
  {
   width=19;

 }
   if(lvl == 3)
   {
    width=19;
 }
    if(lvl == 4)
   {
    width=19;

 }
  ArrayInit(map,0,width);
  Wait(500);
    if(lvl == 1)
 {
 map=map2;
// map={BRK,AIR,AIR,AIR,AIR,AIR,AIR,AIR,GRY,GRY,BLK,BLK,BLK,BLK,BLK,AIR,AIR,PTL,BRK,BRK,BRK,BRK,AIR,AIR,AIR,AIR,AIR,GRY,BRK,STR,STR,STR,BLK,BLK,GRY,AIR,STR,BRK,BRK,WTR,BBK,AIR,AIR,AIR,AIR,AIR,TVL,GRY,BLK,BLK,STR,BLK,BLK,GRY,GRY,STR,BRK,BRK,BRK,STR,AIR,AIR,AIR,AIR,AIR,GRY,GRY,BLK,STL,STR,BBK,BLK,GRY,GRY,STR,BRK,BRK,AIR,STR,BRK,BRK,BRK,BRK,BRK,GRY,GRY,STL,BRK,BRK,BRK,BLK,GRY,STL,BRK,BRK,BRK,AIR,STR,AIR,AIR,AIR,AIR,AIR,GRY,STL,BRK,BLK,BLK,BLK,BLK,STL,BRK,BLK,BRK,BRK,AIR,STR,AIR,VIN,AIR,AIR,AIR,GRY,BRK,BLK,BLK,BLK,BLK,BLK,BRK,BLK,BLK,BRK,BRK,AIR,BRK,BRK,VIN,AIR,AIR,AIR,WTR,GRY,BLK,BLK,BLK,BLK,WTR,GRY,BLK,BLK,BRK};
 }
  if(lvl == 2)
  {
 map=map3;
 }
   if(lvl == 3)
   {
 map=map4;
 }
    if(lvl == 4)
   {
 map=map5;
 }
   pm=ArrayLen(map)-width+5;
 lvl++;
 ClearScreen();
 until(ButtonPressed(BTNCENTER,0))
 {
 TextOut(0,0,"PressCenterToAdvance");
 }
  until(!ButtonPressed(BTNCENTER,0));
   ClearScreen();
 s=1;
 Wait(100);
 d=x/8*-1+13;
 c=x/8*-1;
xp=0;
yp=56;
ClearScreen();
s=0;
 until(done);
}
if(map[pm].X == 40 && map[pm].Y == 72)
{
 life--;
}
if(SENSOR_2)
{
until(!SENSOR_2);
 s=1;
 Wait(300);
 ClearScreen();
until(SENSOR_2)
{
 RectOut(0,0,99,63);
 NumOut(10,LCD_LINE4,money);
 TextOut(5,3,StrCat("HP:",NumToStr(life)));
 }
 until(!SENSOR_2);
     d=x/8*-1+13;
     c=x/8*-1;
xp=0;
yp=56;
ClearScreen();
s=0;
 until(done);
}
if(map[pm].X == 40  && map[pm].Y == 88)
{
 switch(yl)
 {
 case 0:
 pm=width*7+1;
 x=32;
 break;
  case 8:
 pm=width*6+1;
 x=32;
 break;
  case 16:
 pm=width*5+1;
 x=32;
 break;
  case 24:
 pm=width*4+1;
 x=32;
 break;
  case 32:
 pm=width*3+1;
 x=32;
 break;
  case 40:
 pm=width*2+1;
 x=32;
 break;
  case 48:
 pm=width*1+1;
 x=32;
 break;
  case 56:
 pm=1;
 x=32;
 break;
 }
  s=1;
 Wait(100);
     d=x/8*-1+13;
     c=x/8*-1;
xp=0;
yp=56;
ClearScreen();
s=0;
 until(done);
}
if(ButtonPressed(BTNEXIT,0) && yl != 0)
{
until(!ButtonPressed(BTNEXIT,0));
var2[0]=0;
if((map[pm+width].X == 64 && map[pm+width].Y == 64) || (map[pm+width].X == 72 && map[pm+width].Y == 64) || (map[pm+width].X == 80 && map[pm+width].Y == 64) || (map[pm+width].X == 88 && map[pm+width].Y == 16))
{
yl-=8;
pm+=width;
}
s=1;
Wait(100);
     d=x/8*-1+13;
     c=x/8*-1;
xp=0;
yp=56;
ClearScreen();
s=0;
 until(done);
}
if(ButtonPressed(BTNCENTER,0) && yl != 64)
{
until(!ButtonPressed(BTNCENTER,0));
var2[0]=40;
if(map[pm].X == 80 && map[pm].Y == 88)
{
PlayToneEx(500,200,Volume(),0);
 s=1;
 Wait(500);
 ClearScreen();
 ys=52;
until(ButtonPressed(BTNCENTER,0))
{
 sGraphicOut(0,0,"blacksmith.ric",0x00,gt1);
 sFontTextOut(0,58,"PROPTINY.ric","What do ya want?",0x00,ft1);
 sFontTextOut(35,52,"PROPTINY.ric","Sword",0x00,ft1);
 sFontTextOut(35,22,"PROPTINY.ric","Exit",0x00,ft1);
 sFontTextOut(30,ys,"PROPTINY.ric",">",0x00,ft1);
 if(ButtonPressed(BTNLEFT,0) && ys != 52)
 {
 ys+=6;
 ClearScreen();
 until(!ButtonPressed(BTNLEFT,0));
 }
  if(ButtonPressed(BTNRIGHT,0) && ys != 22)
 {
 ys-=6;
 ClearScreen();
 until(!ButtonPressed(BTNRIGHT,0));
 }
 }
 until(!ButtonPressed(BTNCENTER,0));
 ClearScreen();
 if(ys == 52)
 {
 Buy(70,bSword);
 }
     d=x/8*-1+13;
     c=x/8*-1;
xp=0;
yp=56;
ClearScreen();
s=0;
 until(done);
}
if(((map[pm].X == 64 && map[pm].Y == 64) || (map[pm].X == 72 && map[pm].Y == 64) || (map[pm].X == 80 && map[pm].Y == 64) || (map[pm].X == 88 && map[pm].Y == 16)) && (map[pm-width].X != 56 || map[pm-width].Y != 80) && (map[pm-width].X != 48 || map[pm-width].Y != 80))
{
yl+=8;
pm-=width;
}
s=1;
Wait(100);
    d=x/8*-1+13;
     c=x/8*-1;
xp=0;
yp=56;
ClearScreen();
s=0;
 until(done);
}
if(ButtonPressed(BTNLEFT,0))
{
//until(!ButtonPressed(BTNLEFT,0));
var2[0]=8;
if((map[pm-1].X != 56 && map[pm-1].Y != 80) && (map[pm-1].X != 48 || map[pm-1].Y != 80))
{
s=1;
Wait(100);
x+=8;
pm--;
    d=x/8*-1+13;
     c=x/8*-1;
xp=0;
yp=56;
ClearScreen();
s=0;
 until(done);
}
}
if(ButtonPressed(BTNRIGHT,0))
{
//until(!ButtonPressed(BTNRIGHT,0));
var2[0]=32;
if((map[pm+1].X != 56 && map[pm+1].Y != 80) && (map[pm+1] != 48 || map[pm+1] != 80))
{
s=1;
Wait(100);
x-=8;
pm++;
    d=x/8*-1+13;
     c=x/8*-1;
xp=0;
yp=56;
ClearScreen();
s=0;
 until(done);
}
}

if(yl != 0 && !(map[pm+width].X == 64 && map[pm+width].Y == 64) && !(map[pm+width].X == 56 && map[pm+width].Y == 80) && !(map[pm+width].X == 72 && map[pm+width].Y == 64) && !(map[pm+width].X == 80 && map[pm+width].Y == 64) && !(map[pm+width].X == 48 && map[pm+width].Y == 80) && !(map[pm].X == 88 && map[pm].Y == 16))
{
var2[0]=0;
pm+=width;
yl-=8;
s=1;
Wait(100);
    d=x/8*-1+13;
     c=x/8*-1;
xp=0;
yp=56;
ClearScreen();
s=0;
 until(done);
}
if(SENSOR_1)
{
if(var2[0] == 8)
{
if(map[pm-1].X == 48 && map[pm-1].Y == 80)
{
 var2[0]=16;
  PlayFileEx("PUNCH.rso",Volume(),0);
   map[pm-1].X = 88;
 map[pm-1].Y = 8;
 	RectOut(48,yl,8,8,DRAW_OPT_CLEAR | DRAW_OPT_FILL_SHAPE);
 	}
 else if(map[pm-1].X == 56 && map[pm-1].Y == 88 && bSword)
 {
 var2[0]=56;
  PlayFileEx("mcl.rso",Volume(),0);
   map[pm-1].X = 88;
 map[pm-1].Y = 8;
 	RectOut(48,yl,8,8,DRAW_OPT_CLEAR | DRAW_OPT_FILL_SHAPE);
 	}
  sGraphicOutEx1(40,yl,"guy.ric",var2,0x00,gt1);
 Wait(500);
 var2[0]=32;
  sGraphicOutEx1(40,yl,"guy.ric",var2,0x00,gt1);
}
else if(var2[0] == 32)
{
if(map[pm+1].X == 48 && map[pm+1].Y == 80)
{
 var2[0]=24;
  PlayFileEx("PUNCH.rso",Volume(),0);
   map[pm+1].X = 88;
 map[pm+1].Y = 8;
 	RectOut(48,yl,8,8,DRAW_OPT_CLEAR | DRAW_OPT_FILL_SHAPE);
 	}
 else if(map[pm+1].X == 56 && map[pm+1].Y == 88 && bSword)
 {
 var2[0]=48;
  PlayFileEx("mcl.rso",Volume(),0);
   map[pm+1].X = 88;
 map[pm+1].Y = 8;
 	RectOut(48,yl,8,8,DRAW_OPT_CLEAR | DRAW_OPT_FILL_SHAPE);
 	}
  sGraphicOutEx1(40,yl,"guy.ric",var2,0x00,gt1);
 Wait(500);
 var2[0]=32;
}
}
}
}

task n3()
{
  while(1)
  {
  done=0;
  yp=56;
   if(!s)
   {
    until(c >= x/8*-1+(width*7)+13)
    {
     if(!s)
     {
      until(c==d)
      {
			  if(!s)
			  {
          var[0]=map[c].X;
          var[1]=map[c].Y;
          sGraphicOutEx2(xp,yp,"tiles.ric",var,0x00,gt2);
        	xp+=8;
        	c++;
      	}
      	
      }
       yp-=8;
       xp=0;
       d+=width;
       c+=width-13;
    }
			}
			end:
     d=x/8*-1+13;
     c=x/8*-1;
     done=1;
     Wait(50);
  }
 }
}

task main()
{
pm=ArrayLen(map)-width+5;
SetSensorTouch(S1);
SetSensorTouch(S2);
SetLongAbort(1);
Precedes(n2,n3);
}

Re: Help with efficiency of code

Posted: 17 Nov 2010, 04:40
by nxtboyiii
*bump*

Re: Help with efficiency of code

Posted: 17 Nov 2010, 04:45
by afanofosc
No bumping allowed. Hopefully someone will be able to help you, but you just need to be patient and let what happens happen.

John Hansen

Re: Help with efficiency of code

Posted: 17 Nov 2010, 04:58
by mattallen37
Actually, as I recall, Xander did say it is reasonable to bump, if there is an unanswered question, and it has been like 4-5 DAYS (not hours) since the last post.

Re: Help with efficiency of code

Posted: 17 Nov 2010, 13:22
by mightor
Yeah, but this was seriously premature bumping. Patience is a virtue and all that larkin'.

- Xander

Re: Help with efficiency of code

Posted: 17 Nov 2010, 18:34
by spillerrec
It reminds me, I have promised to write a file I/O guide, I completely forgot...

But what is the reason for the "sFontTextOut" define? Why use a low level function when you use it in same way as the high level function would do behind the scenes? (Well, if it could compile efficiently that is...)
You use the same .ric file and you can use the same options (DRAW_OPT_FONT_WRAP) for all the calls, so you could do it like this:

Code: Select all

DrawFontType ft1;
ft1.Filename = "PROPTINY.ric";  //Assign this only once, instead of doing it each time you want to use FontTextOut
ft1.Options = DRAW_OPT_FONT_WRAP;

#define sFontTextOut(_x,_y,_txt); ft1.Location.X=_x; ft1.Location.Y=_y; ft1.Text=_txt; SysDrawFont(ft1);
This will reduce the amount of code used for each call as you don't constantly reassign the filename and options.

Btw, why do you have the macro function "Buy(..,..)"? You only use it once and secondly it is so long that it would probably be better with a normal function.

Also, you probably don't need to use LocationType for your maps as they use int, make your own struct using byte if possible, it should reduce memory usage quite a bit.

Re: Help with efficiency of code

Posted: 17 Nov 2010, 22:15
by nxtboyiii
afanofosc wrote:No bumping allowed. Hopefully someone will be able to help you, but you just need to be patient and let what happens happen.

John Hansen
Oh. Sorry. :oops:

Re: Help with efficiency of code

Posted: 17 Nov 2010, 22:39
by nxtboyiii
spillerrec wrote:It reminds me, I have promised to write a file I/O guide, I completely forgot...

But what is the reason for the "sFontTextOut" define? Why use a low level function when you use it in same way as the high level function would do behind the scenes? (Well, if it could compile efficiently that is...)
You use the same .ric file and you can use the same options (DRAW_OPT_FONT_WRAP) for all the calls, so you could do it like this:

Code: Select all

DrawFontType ft1;
ft1.Filename = "PROPTINY.ric";  //Assign this only once, instead of doing it each time you want to use FontTextOut
ft1.Options = DRAW_OPT_FONT_WRAP;

#define sFontTextOut(_x,_y,_txt); ft1.Location.X=_x; ft1.Location.Y=_y; ft1.Text=_txt; SysDrawFont(ft1);
This will reduce the amount of code used for each call as you don't constantly reassign the filename and options.

Btw, why do you have the macro function "Buy(..,..)"? You only use it once and secondly it is so long that it would probably be better with a normal function.

Also, you probably don't need to use LocationType for your maps as they use int, make your own struct using byte if possible, it should reduce memory usage quite a bit.
The functions with the "s" at the beginning are to take up less space. I need to know a way to make each map a .txt file and code to read the file and write it to the variable "map".

Re: Help with efficiency of code

Posted: 22 Nov 2010, 20:31
by nxtboyiii
Whenever I try to load the map, it says "File Error! -1"
Does it work to put a structure array into another structure and save and load the structure?
Can someone please help?

Code: Select all

#download "tiles.ric"
#download "guy.ric"
#download "PROPTINY.ric"
#download "PUNCH.rso"
#download "blacksmith.ric"
#download "blacksmith2.ric"

#define HTH {64,80}
#define GUY {88,88}
#define EMY {88,80}
#define SHP {80,88}
#define SVR {64,88}
#define GLD {72,88}
#define SBB {56,88}
#define SWD {88,64}
#define SPX {0,88}
#define GRY {48,88}
#define BLK {8,88}
#define TVL {40,88}
#define VIN {88,16}
#define WTR {40,72}
#define AIR {88,8}
#define COL {64,72}
#define TOC {80,16}
#define PTL {32,88}
#define BBK {48,80}
#define BRK {56,80}
#define STR {64,64}
#define SRR {72,64}
#define STL {80,64}
#define LNS {88,56}


#define sFontTextOut(_x,_y,_fn,_txt,_opt,_hd); _hd.Location.X=_x; _hd.Location.Y=_y; _hd.Filename=_fn; _hd.Text=_txt; _hd.Options=_opt; SysDrawFont(_hd);
#define sGraphicOut(_x,_y,_fn,_opt,_hd); _hd.Location.X=_x; _hd.Location.Y=_y; _hd.Filename=_fn; ; _hd.Options=_opt; SysDrawGraphic(_hd);
#define sGraphicOutEx2(_x,_y,_fn,_var,_opt,_hd); _hd.Location.X=_x; _hd.Location.Y=_y; _hd.Filename=_fn; ArrayInit(_hd.Variables,0,3); _hd.Variables[0]=_var[0]; _hd.Variables[1]=_var[1];_hd.Options=_opt; SysDrawGraphic(_hd);
#define sGraphicOutEx1(_x,_y,_fn,_var,_opt,_hd); _hd.Location.X=_x; _hd.Location.Y=_y; _hd.Filename=_fn; ArrayInit(_hd.Variables,0,2); _hd.Variables[0]=_var[0]; _hd.Options=_opt; SysDrawGraphic(_hd);

//#define map2 {BRK,AIR,AIR,AIR,AIR,AIR,AIR,AIR,GRY,GRY,BLK,BLK,BLK,BLK,BLK,AIR,AIR,PTL,BRK,BRK,BRK,BRK,AIR,AIR,AIR,AIR,AIR,GRY,BRK,STR,STR,STR,BLK,BLK,GRY,AIR,STR,BRK,BRK,WTR,BBK,AIR,AIR,AIR,AIR,AIR,TVL,GRY,BLK,BLK,STR,BLK,BLK,GRY,GRY,STR,BRK,BRK,BRK,STR,AIR,AIR,AIR,AIR,AIR,GRY,GRY,BLK,STL,STR,BBK,BLK,GRY,GRY,STR,BRK,BRK,AIR,STR,BRK,BRK,BRK,BRK,BRK,GRY,GRY,STL,BRK,BRK,BRK,BLK,GRY,STL,BRK,BRK,BRK,AIR,STR,AIR,AIR,AIR,AIR,AIR,GRY,STL,BRK,BLK,BLK,BLK,BLK,STL,BRK,BLK,BRK,BRK,AIR,STR,AIR,VIN,AIR,AIR,AIR,GRY,BRK,BLK,BLK,BLK,BLK,BLK,BRK,BLK,BLK,BRK,BRK,AIR,BRK,BRK,VIN,AIR,AIR,AIR,WTR,GRY,BLK,BLK,BLK,BLK,WTR,GRY,BLK,BLK,BRK};
bool notify=1;
int yg=2;
int iNuminr;
int money;
long xg=8;
bool bSword=0;
int bx=0;
bool done=0;
int x=0;
long life=1500;
int y=0;
bool s;
int d=24;
int c;
int xp;
int yp=56;
int yl=48;
long lvl=1;
int pm;
long var[2];
int var2[1];
struct point
{
 byte X;
 byte Y;
};
struct gamesave
{
 long _pm;
 long _x;
 long _y;
 int _xg;
 int _yg;
 int _yl;
 int _money;
 bool _bSword;
 point _map[];
 long _width;
 long _height;
 bool _1;
 bool _2;
};
gamesave Game;
DrawGraphicType gt1;
DrawGraphicType gt2;
DrawFontType ft1;
//short map[][]={{}};
point map5[]={
BRK,BRK,BRK,BRK,BRK,BRK,BRK,BRK,BRK,TOC,BRK,BRK,BRK,BRK,BRK,AIR,BBK,BBK,BRK,
BRK,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,COL,AIR,BRK,PTL,BBK,BBK,STR,BRK,AIR,BRK,
BRK,AIR,AIR,AIR,AIR,AIR,BBK,BBK,BBK,COL,AIR,BBK,AIR,BRK,BRK,STR,BRK,AIR,BRK,
BRK,AIR,AIR,AIR,STL,BRK,BRK,BRK,BRK,BRK,BRK,BRK,AIR,BBK,BRK,STR,BRK,AIR,PTL,
BRK,AIR,AIR,AIR,STL,AIR,AIR,AIR,AIR,COL,AIR,BRK,BRK,AIR,BRK,STR,BRK,AIR,BRK,
BRK,AIR,AIR,STL,STR,AIR,AIR,AIR,AIR,COL,AIR,BRK,BRK,AIR,BRK,STR,BRK,WTR,BRK,
BRK,AIR,STL,STR,AIR,AIR,AIR,AIR,AIR,COL,AIR,BRK,BRK,AIR,BBK,STR,BRK,WTR,BRK,
BRK,STL,STR,STL,STR,STR,STR,SRR,AIR,COL,AIR,BBK,BRK,BRK,BRK,BRK,BRK,BRK,BRK,
};

point map4[]={
BRK,BRK,AIR,AIR,AIR,AIR,BBK,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,BRK,
BRK,BRK,AIR,AIR,VIN,BRK,BRK,BRK,AIR,VIN,AIR,AIR,AIR,WTR,AIR,AIR,AIR,BR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AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,BRK,
BRK,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,BRK,AIR,AIR,AIR,AIR,AIR,BRK,BRK,BRK,BRK,BRK,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,BRK,
BRK,AIR,AIR,AIR,AIR,AIR,SVR,AIR,AIR,BRK,AIR,AIR,AIR,AIR,AIR,BRK,BRK,HTH,AIR,BBK,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,BRK,
BRK,BRK,BRK,BRK,BRK,BRK,BRK,BRK,BRK,BRK,BRK,BRK,BRK,BRK,BRK,BRK,BRK,BRK,BRK,BRK,BRK,BRK,BRK,BRK,BRK,BRK,BRK,BRK,BRK,BRK,BRK,BRK,BRK,BRK,BRK,BRK,BRK,BRK,BRK,BRK,BRK,BRK,BRK,BRK,BRK,BRK,BRK,BRK,BRK,BRK,BRK,BRK,BRK,BRK,BRK,BRK,BRK,BRK,BRK,BRK,
};

/*bool OnTile(int Xtile,int Ytile)
{
return(map[pm].X == Xtile && map[pm].Y == Ytile);
}
                                                                      `
bool NotOnTile(int Xtile,int Ytile)
{
return(!(map[pm].X == Xtile && map[pm].Y == Ytile));
}     */
string RandomText(int numin)
{
 switch(numin)
 {
  case 0:
  return ("Hello!");
  break;
    case 1:
  return ("Go away!");
  break;
    case 2:
  return ("Do I know you??");
  break;
    case 3:
  return ("I LIKE PIE!!");
  break;
    case 4:
  return ("Get lost, kid");
  break;
    case 5:
  return ("PALENO!");
  break;
    case 6:
  return ("Nice to meet you!");
  break;
    case 7:
  return ("Nice day, isn't it?");
  break;
    case 8:
  return ("Don't come any closer!");
  break;
    case 9:
  return ("AAAAAHHHHH!!!!!!");
  break;
    case 10:
  return ("Hi.");
  break;
 }
}
#define Buy(_scost,_alh)\
{                   \
  sFontTextOut(5,58,"PROPTINY.ric",StrCat("$",NumToStr(_scost)),DRAW_OPT_FONT_WRAP,ft1);     \
  if(money >= _scost && !_alh)                                                                     \
  {                                                                                       \
   sFontTextOut(35,46,"PROPTINY.ric","Creating...",0x00,ft1);                                  \
   int varb[1];                                                                             \
   for(int c=0; c < 10; c++)                                                                 \
   {                                                                                          \
   varb[0]=0;                                                                                  \
   sGraphicOutEx1(0,0,"blacksmith2.ric",varb,0x00,gt1);                                             \
   Wait(500);                                                                                     \
   ClearScreen();                                                                                \
   varb[0]=23;                                                                                     \
   sGraphicOutEx1(0,0,"blacksmith2.ric",varb,0x00,gt1);                                                 \
   Wait(500);                                                                                        \
   ClearScreen();                                                                                     \
   }                                                                                                    \
   _alh=1;                                                                                     \
   money-=_scost;                                                                                        \
   sFontTextOut(35,46,"PROPTINY.ric","Bought!",0x00,ft1);                                                    \
   sGraphicOut(0,0,"blacksmith.ric",0x00,gt1);                                                                \
   Wait(1000);                                                                                              \
   ClearScreen();                                                                                           \
  }                                                                                                          \
  else if(money < _scost && !_alh)                                                                                      \
  {                                                                                                            \
  sGraphicOut(0,0,"blacksmith.ric",0x00,gt1);                                                                       \
    sFontTextOut(35,46,"PROPTINY.ric","I don't need poor people in my shop. Get outa here you lazy bum.",DRAW_OPT_FONT_WRAP,ft1); \
    Wait(3000);                                                                                                   \
  }                                                                                                                  \
  else if(_alh){sFontTextOut(35,46,"PROPTINY.ric","You already have that, dummie.",DRAW_OPT_FONT_WRAP,ft1);Wait(1500); ClearScreen();}                                                                                                               \
}


task n2()
{
int ys;
Wait(500);
 while(1)
{
 if((map[pm-1].X == 88 && map[pm-1].Y == 80) || (map[pm+1].X == 88 && map[pm+1].Y == 80))
 {
  life-=5;
  if(SENSOR_1 && bSword)
  {
   if(var2[0] == 8)
   {
    var2[0]=56;
    map[pm-1].X=88;
    map[pm-1].Y=8;
   }
   else if(var2[0] == 24)
   {
    var2[0]=48;
        map[pm+1].X=88;
    map[pm+1].Y=8;
   }
   sGraphicOutEx1(xg,yl,"guy.ric",var2,0x00,gt1);
   Wait(500);
   var2[0]=8;
   until(!SENSOR_1);
  }
 }
if(ButtonPressed(BTNCENTER,0) && ButtonPressed(BTNEXIT,0) && SENSOR_1)
{
 StopAllTasks();
}
if(SoundFlags() == SOUND_FLAGS_IDLE)
{
 PlayFileEx("Mario Theme Son.rmd",1,0);
}
 sGraphicOutEx1(xg,yl,"guy.ric",var2,0x00,gt1);
  if(map[pm].X == 64 && map[pm].Y == 80)
 {
  life+=30;
 }
 if(map[pm].X == 88 && map[pm].Y == 88)
 {
  string textinput;
  s=1;
  iNuminr=Random(11);
  RectOut(0,0,99,42,DRAW_OPT_FILL_SHAPE | DRAW_OPT_CLEAR);
  switch(pm)
  {
   default:
   textinput=RandomText(iNuminr);
   break;
   case 466:
   textinput="Welcome to the bank! Take what you need!";
   break;
  }
  sFontTextOut(2,34,"PROPTINY.ric",textinput,DRAW_OPT_FONT_WRAP,ft1);
    Wait(200);
  until(ButtonPressed(BTNCENTER,0));
    d=(x/8*-1)+width*(y/8*-1)+13;
     c=(x/8*-1)+width*(y/8*-1);
xp=0;
yp=56;
ClearScreen();
s=0;
 until(done);
 }
if(map[pm].X == 64 && map[pm].Y == 88)
{
money+=5;
map[pm].X = 88;
map[pm].Y = 8;
}
if(map[pm].X == 72 && map[pm].Y == 88)
{
money+=10;
map[pm].X = 88;
map[pm].Y = 8;
}
/*if(money >= 70 && notify)
{
 s=1;
 Wait(300);
 ClearScreen();
until(ButtonPressed(BTNLEFT,0) || ButtonPressed(BTNRIGHT,0))
{
 RectOut(0,0,99,63);
 TextOut(0,LCD_LINE2,"Buy sword? $70",0x00,ft1);
 TextOut(0,LCD_LINE3,"HoldLeftOrRight",0x00,ft1);

 }
 if(ButtonPressed(BTNLEFT,0))
 {
 bSword=1;
 money -= 70;
 }
 d=width;
c=0;
xp=0;
yp=56;
ClearScreen();
s=0;
 until(done);
 Wait(500);
} */
/*if(ButtonPressed(BTNLEFT,0) && ButtonPressed(BTNRIGHT,0))
{
 s=1;
Wait(320);
d=width;
c=0;
xp=0;
yp=56;
s=0;
}*/
if(life <= 0)
{
s=0;
Wait(500);
TextOut(0,LCD_LINE4,"You DIED.");
Wait(3000);
StopAllTasks();
}
if(map[pm].X == 64 && map[pm].Y == 88)
{
money++;
}
if(map[pm].X==0 && map[pm].Y ==88)
{
StopAllTasks();
}
if(map[pm].X == 32 && map[pm].Y == 88)
{
 s=1;
 Wait(100);
/* for(int e=0; e < ArrayLen(map); e++)
 {
 map[e].X=Random(13)*8;
 map[e].Y=Random(13)*8;
 }      */
 x=0;
 yl=0;
 yg=2;
  if(lvl == 1)
 {
 width=19;

 }
  if(lvl == 2)
  {
   width=19;

 }
   if(lvl == 3)
   {
    width=19;
 }
    if(lvl == 4)
   {
    width=19;

 }
  ArrayInit(map,0,width);
  Wait(500);
    if(lvl == 1)
 {
 map=map2;
// map={BRK,AIR,AIR,AIR,AIR,AIR,AIR,AIR,GRY,GRY,BLK,BLK,BLK,BLK,BLK,AIR,AIR,PTL,BRK,BRK,BRK,BRK,AIR,AIR,AIR,AIR,AIR,GRY,BRK,STR,STR,STR,BLK,BLK,GRY,AIR,STR,BRK,BRK,WTR,BBK,AIR,AIR,AIR,AIR,AIR,TVL,GRY,BLK,BLK,STR,BLK,BLK,GRY,GRY,STR,BRK,BRK,BRK,STR,AIR,AIR,AIR,AIR,AIR,GRY,GRY,BLK,STL,STR,BBK,BLK,GRY,GRY,STR,BRK,BRK,AIR,STR,BRK,BRK,BRK,BRK,BRK,GRY,GRY,STL,BRK,BRK,BRK,BLK,GRY,STL,BRK,BRK,BRK,AIR,STR,AIR,AIR,AIR,AIR,AIR,GRY,STL,BRK,BLK,BLK,BLK,BLK,STL,BRK,BLK,BRK,BRK,AIR,STR,AIR,VIN,AIR,AIR,AIR,GRY,BRK,BLK,BLK,BLK,BLK,BLK,BRK,BLK,BLK,BRK,BRK,AIR,BRK,BRK,VIN,AIR,AIR,AIR,WTR,GRY,BLK,BLK,BLK,BLK,WTR,GRY,BLK,BLK,BRK};
 }
  if(lvl == 2)
  {
 map=map3;
 }
   if(lvl == 3)
   {
 map=map4;
 }
    if(lvl == 4)
   {
 map=map5;
 }
   pm=width+1;
   xg=8;
 lvl++;
 ClearScreen();
 until(ButtonPressed(BTNCENTER,0))
 {
 TextOut(0,0,"PressCenterToAdvance");
 }
  until(!ButtonPressed(BTNCENTER,0));
   ClearScreen();
 s=1;
 Wait(100);
 d=(x/8*-1)+width*(y/8*-1)+13;
 c=(x/8*-1)+width*(y/8*-1);
xp=0;
yp=56;
ClearScreen();
s=0;
 until(done);
}
if(map[pm].X == 40 && map[pm].Y == 72)
{
 life--;
}
if(SENSOR_2)
{
until(!SENSOR_2);
 s=1;
 Wait(300);
 ClearScreen();
until(SENSOR_2)
{
 RectOut(0,0,99,63);
 NumOut(10,LCD_LINE4,money);
 TextOut(5,3,StrCat("HP:",NumToStr(life)));
 NumOut(10,LCD_LINE7,pm);
 }
 until(!SENSOR_2);
     d=(x/8*-1)+width*(y/8*-1)+13;
     c=(x/8*-1)+width*(y/8*-1);
xp=0;
yp=56;
ClearScreen();
s=0;
 until(done);
}
if(map[pm].X == 40  && map[pm].Y == 88)
{
  s=1;
 Wait(100);
 pm=width*yg-(width-1);
  xg=8;
  x=0;
     d=(x/8*-1)+width*(y/8*-1)+13;
     c=(x/8*-1)+width*(y/8*-1);
xp=0;
yp=56;
ClearScreen();
s=0;
 until(done);
}
if(ButtonPressed(BTNEXIT,0) && yl != 0)
{
var2[0]=0;
if(!(map[pm+width].X == 56 && map[pm+width].Y == 80) && !(map[pm+width].X == 48 && map[pm+width].Y == 80))
{
if(height-y/8*-1 > 8)
{
 y-=8;
}
else
{
 yl-=8;
}
  yg++;
pm+=width;
}
s=1;
Wait(100);
     d=(x/8*-1)+width*(y/8*-1)+13;
     c=(x/8*-1)+width*(y/8*-1);
xp=0;
yp=56;
ClearScreen();
s=0;
 until(done);
}
if(ButtonPressed(BTNCENTER,0))
{
var2[0]=40;
if(map[pm].X == 80 && map[pm].Y == 88 && SENSOR_1)
{
 s=1;
 Wait(500);
 ClearScreen();
 ys=52;
until(ButtonPressed(BTNCENTER,0))
{
 sGraphicOut(0,0,"blacksmith.ric",0x00,gt1);
 sFontTextOut(0,58,"PROPTINY.ric","What do ya want?",0x00,ft1);
 sFontTextOut(35,52,"PROPTINY.ric","Sword",0x00,ft1);
  sFontTextOut(35,46,"PROPTINY.ric","Save",0x00,ft1);
  sFontTextOut(35,40,"PROPTINY.ric","Load",0x00,ft1);
 sFontTextOut(35,22,"PROPTINY.ric","Exit",0x00,ft1);
 sFontTextOut(30,ys,"PROPTINY.ric",">",0x00,ft1);
 if(ButtonPressed(BTNLEFT,0) && ys != 52)
 {
 ys+=6;
 ClearScreen();
 until(!ButtonPressed(BTNLEFT,0));
 }
  if(ButtonPressed(BTNRIGHT,0) && ys != 22)
 {
 ys-=6;
 ClearScreen();
 until(!ButtonPressed(BTNRIGHT,0));
 }
 }
 until(!ButtonPressed(BTNCENTER,0));
 ClearScreen();
 if(ys == 52)
 {
 Buy(70,bSword);
 }
 if(ys == 46)
 {
   unsigned int fsize=300;
   unsigned short handle;
   unsigned int result;
   long length=ArrayLen(map);

         Game._pm=pm;
   Game._money=money;
   Game._x=x;
   Game._xg=xg;
   Game._y=y;
   Game._yg=yg;
   Game._yl=yl;
   Game._bSword=bSword;
   Game._width=width;
   Game._height=height;
   ArrayInit(Game._map,0,length);
   Game._map=map;
        DeleteFile("RPG.dat");
   result=CreateFile("RPG.dat",fsize,handle);
   if(result==LDR_SUCCESS)
   {
      PlayToneEx(500,30,1,0);
      Write(handle,Game);
      CloseFile(handle);
   }
      NumOut(20,24,result);
   Wait(1000);
 }
  if(ys == 40)
 {
   unsigned int fsize=300;
   unsigned short handle;
   unsigned int result;
   result=OpenFileRead("RPG.dat",fsize,handle);
   if(result==LDR_SUCCESS)
   {
     PlayToneEx(500,30,1,0);
      Read(handle,Game);
      CloseFile(handle);
   }
      long length=ArrayLen(Game._map);
       pm=Game._pm;
   money=Game._money;
   x=Game._x;
   xg=Game._xg;
   y=Game._y;
   yg=Game._yg;
   yl=Game._yl;
   bSword=Game._bSword;
   height=Game._height;
   width=Game._width;
   ArrayInit(map,0,length);
   map=Game._map;
   NumOut(0,24,pm);
   Wait(1000);
 }

     d=(x/8*-1)+width*(y/8*-1)+13;
     c=(x/8*-1)+width*(y/8*-1);
xp=0;
yp=56;
ClearScreen();
s=0;
 until(done);
}
if(/*((map[pm].X == 64 && map[pm].Y == 64) || (map[pm].X == 72 && map[pm].Y == 64) || (map[pm].X == 80 && map[pm].Y == 64) || (map[pm].X == 88 && map[pm].Y == 16)) && */!(map[pm-width].X == 56 && map[pm-width].Y == 80) && !(map[pm-width].X == 48 && map[pm-width].Y == 80))
{
if(yl != 48)
{
 yl+=8;
}
else
{
 y+=8;
}
  yg--;
pm-=width;
}
s=1;
Wait(100);
    d=(x/8*-1)+width*(y/8*-1)+13;
     c=(x/8*-1)+width*(y/8*-1);
xp=0;
yp=56;
ClearScreen();
s=0;
 until(done);
}
if(ButtonPressed(BTNLEFT,0))
{
//until(!ButtonPressed(BTNLEFT,0));
var2[0]=8;
if((map[pm-1].X != 56 && map[pm-1].Y != 80) && (map[pm-1].X != 48 || map[pm-1].Y != 80))
{
s=1;
Wait(100);
if(xg != 8)
{
  xg-=8;
}
else
{
 x+=8;
}
pm--;
    d=(x/8*-1)+width*(y/8*-1)+13;
     c=(x/8*-1)+width*(y/8*-1);
xp=0;
yp=56;
ClearScreen();
s=0;
 until(done);
 }
}
if(ButtonPressed(BTNRIGHT,0))
{
//until(!ButtonPressed(BTNRIGHT,0));
var2[0]=32;
if((map[pm+1].X != 56 && map[pm+1].Y != 80) && (map[pm+1] != 48 || map[pm+1] != 80))
{
s=1;
Wait(100);
if(width-(x/8*-1) > 13)
{
  x-=8;
}
else
{
 xg+=8;
}
pm++;
    d=(x/8*-1)+width*(y/8*-1)+13;
     c=(x/8*-1)+width*(y/8*-1);
xp=0;
yp=56;
ClearScreen();
s=0;
 until(done);
 }
/*else if((map[pm+1].X != 56 && map[pm+1].Y != 80) && (map[pm+1] != 48 || map[pm+1] != 80))
{

}*/
}

/*if(yl != 0 && !(map[pm+width].X == 64 && map[pm+width].Y == 64) && !(map[pm+width].X == 56 && map[pm+width].Y == 80) && !(map[pm+width].X == 72 && map[pm+width].Y == 64) && !(map[pm+width].X == 80 && map[pm+width].Y == 64) && !(map[pm+width].X == 48 && map[pm+width].Y == 80) && !(map[pm].X == 88 && map[pm].Y == 16))
{
var2[0]=0;
pm+=width;
yl-=8;
s=1;
Wait(100);
    d=(x/8*-1)+width*(y/8*-1)+13;
     c=(x/8*-1)+width*(y/8*-1);
xp=0;
yp=56;
ClearScreen();
s=0;
 until(done);
}*/
if(SENSOR_1)
{
if(var2[0] == 8)
{
if(map[pm-1].X == 48 && map[pm-1].Y == 80)
{
 var2[0]=16;
  PlayFileEx("PUNCH.rso",Volume(),0);
   map[pm-1].X = 88;
 map[pm-1].Y = 8;
 	RectOut(48,yl,8,8,DRAW_OPT_CLEAR | DRAW_OPT_FILL_SHAPE);
 	}
 else if(map[pm-1].X == 56 && map[pm-1].Y == 88 && bSword)
 {
 var2[0]=56;
  PlayFileEx("mcl.rso",Volume(),0);
   map[pm-1].X = 88;
 map[pm-1].Y = 8;
 	RectOut(48,yl,8,8,DRAW_OPT_CLEAR | DRAW_OPT_FILL_SHAPE);
 	}
  sGraphicOutEx1(xg,yl,"guy.ric",var2,0x00,gt1);
 Wait(500);
 var2[0]=32;
  sGraphicOutEx1(xg,yl,"guy.ric",var2,0x00,gt1);
}
else if(var2[0] == 32)
{
if(map[pm+1].X == 48 && map[pm+1].Y == 80)
{
 var2[0]=24;
  PlayFileEx("PUNCH.rso",Volume(),0);
   map[pm+1].X = 88;
 map[pm+1].Y = 8;
 	RectOut(48,yl,8,8,DRAW_OPT_CLEAR | DRAW_OPT_FILL_SHAPE);
 	}
 else if(map[pm+1].X == 56 && map[pm+1].Y == 88 && bSword)
 {
 var2[0]=48;
  PlayFileEx("mcl.rso",Volume(),0);
   map[pm+1].X = 88;
 map[pm+1].Y = 8;
 	RectOut(48,yl,8,8,DRAW_OPT_CLEAR | DRAW_OPT_FILL_SHAPE);
 	}
  sGraphicOutEx1(xg,yl,"guy.ric",var2,0x00,gt1);
 Wait(500);
 var2[0]=32;
}
}
}
}

task n3()
{
  while(1)
  {
  done=0;
  yp=56;
   if(!s)
   {
    until(c >= ((x/8*-1)+width*(y/8*-1))+width*8)
    {
     if(!s)
     {
      until(c==d)
      {
      //NumOut(30,30,IsInMap(map,pm));
			  if(!s)
			  {
			   if(c != pm)
			   {
          var[0]=map[c].X;
          var[1]=map[c].Y;
          sGraphicOutEx2(xp,yp,"tiles.ric",var,0x00,gt2);
          }
        	xp+=8;
        	c++;
      	}

      }
       yp-=8;
       xp=0;
       d+=width;
       c+=width-13;
    }
			}
			end:
     d=(x/8*-1)+width*(y/8*-1)+13;
     c=(x/8*-1)+width*(y/8*-1);
     done=1;
     Wait(50);
  }
 }
}

task main()
{
pm=width+1;
SetSensorTouch(S1);
SetSensorTouch(S2);
SetAbortFlag(BTNSTATE_NONE);
Precedes(n2,n3);
}

Re: Help with efficiency of code

Posted: 23 Nov 2010, 19:53
by nxtboyiii
Can somebody please help?
I need an answer a.s.a.p..(Sorry I'm so impatient, I just can't help it. :( )