R
R
Ribachok2020-06-12 20:25:29
C++ / C#
Ribachok, 2020-06-12 20:25:29

Increment int multiple times?

Hello. I wrote the following code (I used SFML):

int q = 0;
if (Keyboard::isKeyPressed(Keyboard::LShift))
{
q++
}
if (q == 1)
{
...
}
if (q == 2)
{
...
}

And the bottom line is that by pressing the shift key, q really increases, but only up to 1. It doesn’t want to go further. What to do?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
edward_freedom, 2020-06-12
@Ribachok

Move the variable declaration out of the loop
int q = 0;

can you tell me how to limit the increase by change? So that it increases only by 1 unit, no more

if(q != 1) {
    q++;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question