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.


Topics - Narok

Pages: [1]
1
This is part of what I have:
                while (hoverEnemy == true)
                {
                        window.draw(cop);
                        std::cout << "Hover\n";

                        if (clickEnemy)
                        {
                                numofclicks + 1;
                                std::stringstream text;
                                text << "Cop has " << EnemyObject.eHp(copHitPoints, numofclicks) << " hp left ";
                                copHp.setString(text.str());

                               
                                window.draw(copHp);
                                std::cout << "Clicked\n";

                                if(copHitPoints == 0)
                                {
                                        EnemyObject.die();
                                }
                                clickEnemy = false;
                        }

                        hoverEnemy = false;
                }
               

What I want to do is make the health (copHitPoints) go down by 20 every click. The problem is when I set the clickEnemy to false at the end of the code above window.draw(copHp) pops up for a slight second. But when I leave out the clickEnemy = false; click is set to true infinity. What I also want is for the window.draw(cop) to "undraw" when clickEnemy is true.

The EnemyObject.eHp code:

 
        int eHp(int intialHp, int numClicks)
        {
                if (numClicks == 1)
                {
                        intialHp = 80;
                        return intialHp;
                }

                if (numClicks == 2)
                {
                        intialHp = 60;
                        return intialHp;
                }

                if (numClicks == 3)
                {
                        intialHp = 40;
                        return intialHp;
                }

                if (numClicks == 4)
                {
                        intialHp = 20;
                        return intialHp;
                }

                if (numClicks == 5)
                {
                        intialHp = 0;
                        return intialHp;
                }
               
                if (numClicks < 6)
                {
                        intialHp = 0;
                        return intialHp;
                }
        }

2
General / How do I convert a getBlobalBounds() to a int like thing
« on: August 10, 2012, 03:38:03 am »
I'm trying to make it so when I click on a shape it disapears:

      sf::FloatRect rectBounds = enemy.getGlobalBounds();

      if (mouseX == rectBounds && mouseY == rectBounds)
      {
         hoverEnemy = true;
      }

      if (clickEnemy == true && hoverEnemy)
      {
         EnemyObject.die();
         clickEnemy = false;
      }

This ^ obviously doenst work. Is there a way I can do it?

3
General / Muliple Questions
« on: August 08, 2012, 10:19:56 pm »
1) Is there a way to make it so you can only collide with non-alpha parts of the picture? This has been bugging me for awhile because it would be so much easier to have this rather than having to make a ton of different shapes.
 
2) Also, does anyone know how to make a SFML editor, or know where a tut is for one?

3) Also does anyone know how to clear a shape on function command? Or make multiple shapes by using a for loop? I want to make a enemyClass where it has a die function and when the user clicks on the enemy it disapeers. Also I want a enemyObject tied to each enemy shape, is there a way to produce a mass of those?

4) How do you make it so when your mouse intersects a object and is  clicked the object disapears from ^ class.


My idea of what a for loop to make multiple enemies would look like:

sf::RectangleShape enemy;
enemy.setSize(sf::Vector2f(25,25));
enemy.setPosition (100, 200);


int j;

for (j=1; j>=10; j++)
{
    sf::RectangleShape enemy(j);
    enemy(j).setSize(sf::Vector2f(25, 25));
    enemy(j).setPosition (100+(25+(j)), 200);

    enemyClass enemyObject(j);
}

Answering any one of these would be extremly helpful

Thanks

Pages: [1]
anything