NXC code to NBC code

Discussion specific to NXT-G, NXC, NBC, RobotC, Lejos, and more.
nxtboyiii
Posts: 366
Joined: 02 Oct 2010, 07:08
Location: Everywhere

Re: NXC code to NBC code

Post 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.
Thanks, and have a nice day,
nxtboy III

programnxt.com
afanofosc
Site Admin
Posts: 1256
Joined: 26 Sep 2010, 19:36
Location: Nashville, TN
Contact:

Re: NXC code to NBC code

Post by afanofosc »

You had me scared there for a second... :-)

John Hansen
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
nxtboyiii
Posts: 366
Joined: 02 Oct 2010, 07:08
Location: Everywhere

Re: NXC code to NBC code

Post 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
Thanks, and have a nice day,
nxtboy III

programnxt.com
muntoo
Posts: 834
Joined: 01 Oct 2010, 02:54
Location: Your Worst Nightmare
Contact:

Re: NXC code to NBC code

Post 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;
            }
        }
    }
}
Image

Commit to LEGO Mindstorms Robotics Stack Exchange:
bit.ly/MindstormsSE


Commit to LEGO Stack Exchange: bit.ly/Area51LEGOcommit
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest