Jump to content

  • Log In with Google      Sign In   
  • Create Account


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


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 Enerjak   Members   -  Reputation: 227

Like
0Likes
Like

Posted 29 December 2013 - 04:29 PM

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.



Sponsor:

#2 Samith   Members   -  Reputation: 1914

Like
1Likes
Like

Posted 29 December 2013 - 04:33 PM

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.



#3 Enerjak   Members   -  Reputation: 227

Like
0Likes
Like

Posted 29 December 2013 - 04:44 PM

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






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS