You can use UniversalGUIIndent. (I use the UniversalGUIIndent plugin for Notepad++. Code Indenting/Formatting is as simple as Ctrl+Shift+Alt+J.)
Code: Select all
bool OnTile(int pointx, int pointy, int paddx2, int paddy2, char ptile)
{
return((map[pointx][pointy].p == ptile) || (map[pointx+paddx2][pointy+paddy2].p == ptile) || (map[pointx][pointy+paddy2].p == ptile) || (map[pointx+paddx2][pointy].p == ptile));
}
bool OnTTile(char ptile)
{
return(xy == ptile || xpy == ptile || xyp == ptile || xpyp == ptile);
}
bool OnSLDTile(byte pox, byte poy, byte pdx, byte pdy, char ptile)
{
return((map[pox][poy].sld == ptile) || (map[pox+pdx][poy].sld == ptile) || (map[pox][poy+pdy].sld == ptile) || (map[pox+pdx][poy+pdy].sld == ptile));
}
bool OnETile(int pt, int pox, int poy)
{
return(map[pox][poy].p == pt);
}
MapType RTile(int pointx, int pointy, int paddx2, int paddy2, char ptile)
{
MapType ont;
if (map[pointx][pointy].p == ptile)
{
ont.x=pointx;
ont.y=pointy;
return(ont);
}
if (map[pointx+paddx2][pointy].p == ptile)
{
ont.x=pointx+paddx2;
ont.y=pointy;
return(ont);
}
if (map[pointx][pointy+paddy2].p == ptile)
{
ont.x=pointx;
ont.y=pointy+paddy2;
return(ont);
}
if (map[pointx+paddx2][pointy+paddy2].p == ptile)
{
ont.x=pointx+paddx2;
ont.y=pointy+paddy2;
return(ont);
}
}
void Tile()
{
unsigned long t0;
xy=map[mapx][mapy].p;
xpy=map[mapx+paddx][mapy].p;
xyp=map[mapx][mapy+paddy].p;
xpyp=map[mapx+paddx][mapy+paddy].p;
MapType tilem;
if (fmapy == floor(fmapy))
{
if ((OnETile(UNS,mapx,mapy-1) || OnETile(UNS,mapx+paddx,mapy-1)) && bu == 0)
{
t0=CurrentTick()/1000;
bu=1;
}
if (CurrentTick()/1000-t0 >= 1)
{
if (OnETile(UNS,mapx,mapy-1) && bu == 1)
{
map[mapx][mapy-1].sld=0;
map[mapx][mapy-1].p=3;
bu=0;
}
if (OnETile(UNS,mapx+paddx,mapy-1) && bu == 1)
{
map[mapx+paddx][mapy-1].sld=0;
map[mapx+paddx][mapy-1].p=3;
bu=0;
}
}
if (jumping == 1 || bUp)
{
if (OnETile(CBR,mapx,mapy+1))
{
jc=2;
ong=0;
map[mapx][mapy+1].sld=0;
map[mapx][mapy+1].p=AIR;
repeat(10)
{
RectOut(x+Random(16),y+16+Random(16),Random(3),Random(3));
}
}
if (OnETile(CBR,mapx+paddx,mapy+1))
{
jc=2;
ong=0;
map[mapx+paddx][mapy+1].sld=0;
map[mapx+paddx][mapy+1].p=AIR;
repeat(10)
{
RectOut(x+Random(16),y+16+Random(16),Random(3),Random(3));
}
}
if (OnETile(CB2,mapx,mapy+1))
{
jc=2;
ong=0;
map[mapx][mapy+1].p=BLO;
map[mapx][mapy+2].p=CON;
repeat(10)
{
RectOut(x+Random(16),y+16+Random(16),Random(3),Random(3));
}
}
if (OnETile(CB2,mapx+paddx,mapy+1))
{
jc=2;
ong=0;
map[mapx+paddx][mapy+1].p=BLO;
map[mapx+paddx][mapy+2].p=CON;
repeat(10)
{
RectOut(x+Random(16),y+16+Random(16),Random(3),Random(3));
}
}
if (OnETile(QES,mapx,mapy+1))
{
jc=2;
ong=0;
map[mapx][mapy+1].p=BLO;
map[mapx][mapy+2].p=MUS;
}
if (OnETile(QES,mapx+paddx,mapy+1))
{
jc=2;
ong=0;
map[mapx+paddx][mapy+1].p=BLO;
map[mapx+paddx][mapy+2].p=MUS;
}
}
}
/* if(OnETile(MUS,mapx,mapy))
{
map[mapx][mapy].p=AIR;
if(msize == 22)
{
msa=192;
csf=1;
}
else
{
msa=96;
}
msize=22;
}*/
if (OnETile(MUS,mapx+paddx,mapy))
{
map[mapx+paddx][mapy].p=AIR;
if (msize == 22)
{
msa=192;
csf=1;
}
else
{
msa=96;
csf=0;
}
msize=22;
}
if (OnSLDTile(mapx,mapy,paddx,paddy,-2) || OnTTile(LAV) || OnTTile(LAB) || OnSLDTile(mapx,mapy,paddx,paddy,4) || OnSLDTile(mapx,mapy,paddx,paddy,-1) || OnSLDTile(mapx,mapy,paddx,paddy,8) || OnTTile(FIR))
{
if (msa == 192)
{
msa=96;
csf=0;
}
else if (msa == 96)
{
msa=0;
msize=20;
}
else
{
dead=1;
}
}
if (mapy == 0)
{
dead=1;
}
if (OnTTile(CON))
{
tilem=RTile(mapx,mapy,paddx,paddy,CON);
map[tilem.x][tilem.y].p=AIR;
if (m == 0)
PlayFileEx("buding.rso",Volume(),0);
}
if (OnTTile(END))
{
//Display winning screen or go to next level
SetDisplayFlags(DISPLAY_ON | DISPLAY_REFRESH);
s=0;
TextOut(0,0,"loading...");
Wait(1000);
lvl++;
GraphicOut(0,0,"title.ric");
RectOut(10,5,80,5,DRAW_OPT_CLEAR | DRAW_OPT_FILL_SHAPE);
if (lvl <= levels)
{
PlayToneEx(700,30,1,0);
unlockedlevels++;
}
LoadMap(lvl);
xadd=0;
yadd=0;
mapx=2;
mapy=1;
xx=16;
yy=8;
fmapx=2;
fmapy=1;
x=32;
y=16;
xpp=0;
ypp=0;
bFire=0;
paddx=0;
paddy=0;
yj=0;
ffd=0;
jumping=0;
dgArgs.Variables[1]=dovar;
int cnt=2;
int cnt2=2;
lvlc=NumToStr(lvl);
ul=NumToStr(unlockedlevels);
OpenFileAppend("mariosave.txt",mfsize,mhandle);
WriteLnString(mhandle,lvlc,cnt);
WriteLnString(mhandle,ul,cnt2);
CloseFile(mhandle);
s=1;
}
}
Of course, it's still quite messy. Try splitting it into at least 5 functions - the file saving, for example, could be in a separate function.