Page 4 of 4
Re: NXC code to NBC code
Posted: 25 Jul 2011, 20:49
by nxtboyiii
Ok, sure!
With level 2 it is perfectly fine.
With level 3 it says "File Error! -1" after loading the map and loads the mapt1.txt file slower and it thinks there are enemies and lava everywhere. It must be a problem with reading the text file.
Sorry, I used the wrong test release.
With level 3 it is perfect!
BTW, thanks for making the compiler faster. It helps a lot.
Re: NXC code to NBC code
Posted: 25 Jul 2011, 20:59
by afanofosc
You had me scared there for a second...
John Hansen
Re: NXC code to NBC code
Posted: 26 Jul 2011, 00:32
by nxtboyiii
So, as I asked on page 3, how do I make that section faster(the code between the commented stars)?
Help would be highly appreciated.
Thanks,
nxtboy III
Re: NXC code to NBC code
Posted: 26 Jul 2011, 22:29
by muntoo
Here's what @nxtboyiii is asking about (
mGameTask.nxc
):
Code: Select all
task Game()
{
// int ps,ds;
while(1)
{
if(fmapx == floor(fmapx))
{
paddx=0;
}
else
{
paddx=1;
}
if(SENSOR_2 && SENSOR_1)
{
StopAllTasks();
}
ShootFireBall();
varfb[0]=0;
CheckFireBall();
Jump();
mapy=floor(fmapy);
mapx=floor(fmapx);
if(yj == 16 && jc < 1)
{
jumping=0;
yj=0;
jc=1;
}
else if(yj >= 16 && jc >= 1)
{
jumping=0;
}
if(fmapy == floor(fmapy))
{
paddy=0;
}
else
{
paddy=1;
}
if(fmapx == floor(fmapx))
{
paddx=0;
}
else
{
paddx=1;
}
MoveLeft();
mapy=floor(fmapy);
mapx=floor(fmapx);
if(fmapy == floor(fmapy))
{
paddy=0;
}
else
{
paddy=1;
}
MoveRight();
mapy=floor(fmapy);
mapx=floor(fmapx);
if(fmapx == floor(fmapx))
{
paddx=0;
}
else
{
paddx=1;
}
if(!ButtonPressed(BTNCENTER,0))
{
ffd=1;
}
FireBallHit();
Punch();
Down();
s=0;
mapy=floor(fmapy);
mapx=floor(fmapx);
CheckVargs();
DrawEMY();
Tile();
CheckFireBall();
fballx+=xpp;
fbally+=ypp;
varfb[0]=16;
if(bFire == 1)
GraphicOutEx(fballx,fbally,"fb.ric",varfb);
CheckJumpOn();
if(varemy[0] == 0)
{
varemy[0]=16;
}
else
{
varemy[0]=0;
}
//********************************************************************************************************************
for(int c=0; c < EM; c++)
{
enemy E=emy[c];
E.ex+=xpp;
E.ey+=ypp;
if(E.eli == 0 && E.eat == 3)
{
GraphicOut(E.ex,E.ey,"TS.ric");
}
if(E.eli == 1)
{
if(map[E.mex][E.mey].sld == E.eat && E.ex <= 96 && E.ex >= -16 && E.ey >= -16 && E.ey <= 100)
{
switch(E.eat)
{
case 3:
estr="T.ric";
break;
case 4:
estr="R.ric";
break;
case 5:
estr="B.ric";
break;
}
CheckPY(E);
EMYMoveLeft(E);
E.mex=floor(E.fex);
CheckPY(E);
EMYMoveRight(E);
E.mex=floor(E.fex);
//Move down
CheckPX(E);
EMYMoveDown(E);
E.mey=floor(E.fey);
if(E.eat == 5)
{
if(map[E.mex][E.mey-1].sld >= 1 && E.fey == floor(E.fey))
{
FinishEMoveUp(E);
E.U=1;
}
//Move up
EMYMoveUp(E);
}
E.mex=floor(E.fex);
E.mey=floor(E.fey);
if(E.eat == 5)
{
if(map[E.mex][E.mey+1].sld >= 1 && E.fey == floor(E.fey))
{
FinishEMoveUp(E);
E.U=0;
}
}
CheckPX(E);
CheckPY(E);
map[E.mex+E.pex][E.mey+E.pey].sld=9;
map[E.mex][E.mey].sld=E.eat;
if(E.fex == floor(E.fex))
{
switch(E.sc)
{
case 'L':
map[E.mex+1][E.mey].sld=0;
map[E.mex][E.mey].sld=E.eat;
E.sc='N';
break;
case 'R':
map[E.mex-1][E.mey].sld=0;
map[E.mex][E.mey].sld=E.eat;
E.sc='N';
break;
}
}
if(E.fey == floor(E.fey))
{
FinishEMoveUp(E);
}
if(E.eat == 4 && map[E.mex][E.mey-1].sld <= 2 && E.fey == floor(E.fey))
{
E.eli=0;
map[E.mex][E.mey].sld=0;
}
GraphicOutEx(E.ex,E.ey,estr,varemy);
}
}
emy[c]=E;
}
//********************************************************************************************************************
until(done);
xadd+=xpp;
yadd+=ypp;
s=1;
until(!done);
xpp=0;
ypp=0;
// DrawEMY();
if(bFire == 1)
GraphicOutEx(fballx,fbally,"fb.ric",varfb);
if(!ButtonPressed(BTNLEFT,0) && !ButtonPressed(BTNRIGHT,0))
{
if(gvar[0] == l2 && jumping == 0)
{
gvar[0]=16;
}
else if(gvar[0] == r2 && jumping == 0)
{
gvar[0]=0;
}
}
}
}