Jump to content
  • Advertisement
Sign in to follow this  
Enerjak

A very annoying syntax Error and isn't an error.

This topic is 1608 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

C:\Users\Rosario\Desktop\Converge 8.0\Projects\OpenGL\main.cpp|278|error: expected primary-expression before ',' token|

This error comes after using this function:

if(lvl_one_mgr->checkCollisionBoundingBox(Ball,playerPad))
    {
      //  char buffer[256];
     //   sprintf(buffer,"Collision: ",true);
    //    drawText(SCREEN_WIDTH/2,SCREEN_HEIGHT/2,buffer,1,1,1,1);
    }

Now, I've looked through the function and everything seems in order. I might be missing something....Here's the function definition for your viewing pleasure:

bool EntityManager::checkCollisionBoundingBox(Entity* ent1, Entity* ent2)
{
    bool ret = false;
    Entities::iterator first;
    Entities::iterator second;

    Rectangle* rA = new Rectangle();
    Rectangle* rB = new Rectangle();

    first = mEntites.begin();
    while(first != mEntites.end())
    {
        ent1 = (*first);
        if(ent1->isVisible())
        {
            second = mEntites.begin();
            while(second != mEntites.end())
            {
                ent2 = (*second);
                if(ent2->isVisible() && ent1 != ent2)
                {
                    // set the first rect.
                    rA->setLeft(ent1->getRectangle()->getLeft() + ent1->getXpos());
                    rA->setTop(ent1->getRectangle()->getTop() + ent1->getYpos());
                    rA->setRight(ent1->getRectangle()->getRight() + ent1->getRectangle()->getWidth() + ent1->getXpos() * ent1->getScale().getX());
                    rA->setBottom(ent1->getRectangle()->getBottom() + ent1->getRectangle()->getLength() + ent1->getYpos() * ent1->getScale().getY());

                    // set the second;
                    rB->setLeft(ent2->getRectangle()->getLeft() + ent2->getXpos());
                    rB->setTop(ent2->getRectangle()->getTop() + ent2->getYpos());
                    rB->setRight(ent2->getRectangle()->getRight() + ent2->getRectangle()->getWidth() + ent2->getXpos() * ent2->getScale().getX());
                    rB->setBottom(ent2->getRectangle()->getBottom() + ent2->getRectangle()->getLength() + ent2->getYpos() * ent2->getScale().getY());

                    if (rA->isInside( rB->getLeft(), rB->getTop() ) ||
                        rA->isInside( rB->getRight(), rB->getTop() ) ||
                        rA->isInside( rB->getLeft(), rB->getBottom() ) ||
                        rA->isInside( rB->getRight(), rB->getBottom() ))
                        {
                            ret = true;
                        }
                }
                second++;
            }
        }
        first++;
    }
    delete rA;
    delete rB;
    return ret;
}

Now sure if there's a syntax error in the function it self or not. I'm using code:blocks 12.11 with the  GNU GCC compiler. Please let me know what I did wrong, chances are.....I did something wrong.

Share this post


Link to post
Share on other sites
Advertisement

Is Ball a type? Ball sounds like something that might be a type, and thus the compiler won't want to treat it as an expression when you try to pass it as an argument to checkCollisionBoundingBox.

 

Or another possible scenario: is Ball a macro? If so, maybe the macro expands into something that isn't an expression, and the compiler is getting tripped up by it.

Share this post


Link to post
Share on other sites

Hehehe........My bad.....thanks for that, I was passing the class rather then the instancer of that class......

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!