Help with efficiency of code
Posted: 16 Nov 2010, 22:16
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".
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,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AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,AIR,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);
}