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

Pages: [1]
1
General / Re: Event - slow?
« on: December 18, 2016, 10:07:34 pm »
Thanks for the answer. I will read the Thors action system and read more about real time inputs and events. I have also started out, so everything is not easy xD

2
General / Event - slow?
« on: December 18, 2016, 09:17:53 pm »
Hello!

from the beginning i used only if loops and i encountered some problems. I switch to use Event instead. But i feel like the events have some delay(probably bad coding xD). I need someone who can tell what the problem is and how I can make it better without the delay on events :P. When i click with the event code it is delay or I need to spam click for the action to happen.


if code =

sf::Vector2i mousepos = sf::Mouse::getPosition(*window);
       
       
                if (IsThisStrenght = true && mousepos.x > this->getPosition().x && mousepos.x < this->getPosition().x + this->getGlobalBounds().width && mousepos.y > this->getPosition().y && mousepos.y < this->getPosition().y + this->getGlobalBounds().height)
                {
                        if (sf::Mouse::isButtonPressed(sf::Mouse::Left))
                        {

                                        if (this->score->reps >= 10)
                                        {

                                                this->stats->Strength += 1;
                                                this->score->reps -= 10;

                                        }

                        }
                }
 

event code-

       
sf::Vector2i mousepos = sf::Mouse::getPosition(*window);
       
        sf::Event event;
       
        while (window->pollEvent(event))
        {

                if (IsThisStrenght = true && mousepos.x > this->getPosition().x && mousepos.x < this->getPosition().x + this->getGlobalBounds().width && mousepos.y > this->getPosition().y && mousepos.y < this->getPosition().y + this->getGlobalBounds().height)
                {
                        if (event.type == sf::Event::MouseButtonPressed)
                        {
                                if (event.mouseButton.button == sf::Mouse::Left)
                                {

                                        if (this->score->reps >= 10)
                                        {

                                                this->stats->Strength += 1;
                                                this->score->reps -= 10;

                                        }
                                }
                        }
                }
        }

grateful for answer


3
General / Need help with deleting Numbers (INT)!
« on: December 18, 2016, 05:01:24 pm »
Hello guys!

have received a obstacle when I have worked with my game. When i have over 10 reps I can buy a item and it will cost me 10 reps. The problem is when if i get over 20 reps and buy the item it will take away 20 reps but actually it should only cost 10?!.

this is the code Underneath

if (sf::Mouse::isButtonPressed(sf::Mouse::Left))
      {
         if (this->score->reps >= 10)
         {
            
            this->stats->Strength += 1;
            this->score->reps -= 10;
         
         }
      }


Pleas someone can help me with this question!

Pages: [1]