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 - Narok

Pages: [1]
1
This was already answered. ;)

window.draw(copHp); is called only when clickEnemy is true, it's no surprise that you can only catch a glimpse of it.

No it was commented on, the millisecond is my problem, and the fix is my question

2
As for your code, have a look at the example in the documentation, do you see how nicely the updating & event handling is split from the drawing part? You should definitely follow that rule. Don't ever draw stuff within in your logic part (updating/event handling) and only use a small if-statement switch for drawing or not drawing something with in the drawing part. :)
(ot: thanks Laurent for that website, otherwise you'd read that wrong spelling once more ;D)

I know how it goes: Events, Logic, then Rendering. And my question is how do I fix the clickEnemy thing so it will record the number of clicks, but wont appear and disappear in a millisecond

3
General / Re: G.
« on: August 11, 2012, 04:40:59 pm »
numofclicks = numofclicks + 1, noted

I don't use it to update copHitPoints because I put it into where I want copHitPoints to display.

I know it's no surprise, I'm asking how to make it so it will update with clicks

What!?!?

I use while so it doesn't bug out on me and freeze

I think I'm going to try if (clickEnemy == true && numofclicks == 1)
{
//something
}

4
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;
                }
        }

5
General / Re: eXpl0it3r
« on: August 10, 2012, 06:07:06 am »
Thanks it works for the most part. Somethings don't work though like:

Hover is always true even when the mouse is away from the square so when you click it always works no matter where you are.

I can't draw an object when it's hovered or clicked:

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

                if (enemy.getGlobalBounds().contains(static_cast<sf::Vector2f>(sf::Mouse::getPosition(window))))
                {
                        hoverEnemy = true;
                }

                if (hoverEnemy = true)
                {
                        std::cout << "Hover\n";
                        window.draw(enemyHover);
                }
                if (clickEnemy == true && hoverEnemy)
                {
                        EnemyObject.die();
                        window.draw(enemyClicked);
                        std::cout << "Clicked";
                        clickEnemy = false;
                }

6
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?

7
General / Re:Re: eXpl0it3r
« on: August 08, 2012, 11:19:37 pm »
1) Thanks

2) No haha. I meant is there a tut on how to make your own editor with SFML or C++ for SFML. Like on the right side there would be a list of objects to chose, and when you clicked one it would ask for the size, color, and if you wanted to texture it, then you could determine the position by dragging it around in real time instead of having to guess and check like we have to do now.

3) Will do, thanks.

8
General / Re: eXpl0it3r
« on: August 08, 2012, 10:47:12 pm »
1) So are you saying pixel perfeect is very buggy?

2) An editor for all of those, or most.

3) I don't actually know too much C++ lol, I'm cutting corners for some, and the rest I'm learning by doing.

9
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