My method isnt looping in my while()

hello, i made a botAI_it class for my AI enemy in my 2D game in c++, SDL;
I have a main game loop where everything goes and they all loop as they shouold.
1
2
3
4
5
bool run =true;
while (run)
{
//code
}

In my bot class, i have a method which moves the bot.
1
2
3
4
void botAI_it::move()
{
botX -=0.9;
}

since i have this method inside a loop, it should keep looping and slowly move it across like my character controlled by keys, but this bot only moves once and doesnt loop. When i put "cout<<"sdfsd;" in the method, that loops fine and keep saying the cout.
You're omitting important parts of code. Include everything that might have an effect on the movement, as well as the state of your bool run.
thanks for the reply. My class is in its own header and everything relating to my bot: x,y width, height etc, is privater so obviously i need my methods to do something with them. I cant include bool run because that is in my main.cpp , not in my class.
ALSO:::: If i said : "botWidth-=90;" then that would work, it would decreas its width by 90, but only once. I want to to keep doing the code sinmce its in the loop
It sounds like it loops but something else is wrong. Are you sure you don't set botX to some value somewhere else in your code? Is botX a floating point number?
OHHH!!!! thankyou you are a GENUIS!!! i had a set() function so it would moveit then just set it again. All i had to do was take the set() out of the loop and just put it into the main(). THANKYOU!
btw, it is a float. is a float just a number that can have decimals? what else does it do?
Topic archived. No new replies allowed.