Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - neverbend007

Pages: [1]
1
Graphics / Re: Bounding Box Collision Detection
« on: December 03, 2014, 06:23:29 pm »
Hi, yeah ballOneHit is initialised to false when it is declared. My robot displays and functions perfectly, all three sections of his arm work as they should. When the game window opens, I can only see the robot, no balloon, but that is because the if statement is true so ballHitOne immediately becomes true and so the balloon is never drawn.

I was going by the instructions on this page:

http://sfml-dev.org/tutorials/2.0/graphics-transform.php

Am I misunderstanding them or am I looking a the wrong section completely?

2
Graphics / Bounding Box Collision Detection
« on: December 03, 2014, 03:29:14 pm »
I am trying to write a very basic game for my first SFML project. Its a robot with a jointed arm that will be able to pop balloons with his hand only. The problem I am having is that when checking to see if the pincer sprite intersects with the balloon sprite , it returns true all the time, regardless of the placement of the balloon or the robot pincer. I am using transform to place the various parts of the robot arm, and this is whats causing the problem I think, but I don't know why. I have tried using bounding box collision in a separate program where transform is not used and it worked perfectly. The transformation and detection code is below. I am brand new to SFML so apologies for my ignorance here!!

        sf::Transform trBody;
        trBody.translate(sBodyPos);
        /////////////////////////////////////////////////

        sf::Transform trArm1;
        trArm1.translate(sArm1Pos);

        sf::Transform rotArm1;
        rotArm1.rotate(sArm1Rot);

        sf::Transform TR1 = trBody*trArm1*rotArm1;
        /////////////////////////////////////////////////

        sf::Transform trArm2;
        trArm2.translate(sArm2Pos);

        sf::Transform rotArm2;
        rotArm2.rotate(sArm2Rot);

        sf::Transform TR2 = TR1*trArm2*rotArm2;
        /////////////////////////////////////////////////

        sf::Transform trPincer1;
        trPincer1.translate(sPincer1Pos);

        sf::Transform TR3 = TR2*trPincer1;
        /////////////////////////////////////////////////

        sf::Transform trPincer2;
        trPincer2.translate(sPincer2Pos);

        sf::Transform TR4 = TR2*trPincer2;
        /////////////////////////////////////////////////
        sf::Transform trBalloon1;
        trBalloon1.translate(sBalloon1Pos);

        if (sPincer1.getGlobalBounds().intersects(sBalloon1.getGlobalBounds())){

            cout << "Bang" << endl;
            ballOneHit = true;

        }

        // Clear screen
        app.clear();
        app.draw(sArm2, TR2);
        app.draw(sPincer1, TR3);
        app.draw(sPincer2, TR4);
        app.draw(sArm1, TR1);
        app.draw(sBody, trBody);

        if (ballOneHit == false){

            app.draw(sBalloon1, trBalloon1);

        }

        // Update the window
        app.display();



 

Pages: [1]
anything