Very new at Box2D, would appreciate help.
I've got a simple function that takes in a b2World and b2Body*, where the body is supposed to fall until it collides with a ground box (already created in main())
The code is essentially as follows:
void snake::update(b2World world, b2Body* snake)
{
bool running = true;
Clock deltaClock;
Time deltaTime;
while (running)
{
deltaTime = deltaClock.getElapsedTime();
deltaClock.restart();
world.Step(deltaTime.asSeconds(), 6, 2);
position = snake->GetPosition();
char ch;
if (_kbhit())
{
ch = _getch();
if (ch == 'x')
{
running = false;
}
}
}
}
This code was originally implemented in main(), and it worked fine. However, when I tried to move it to its own function in a separate class, the collision no longer works... I've got no idea as to why, as it was literally copy/pasted, just changing around variable names to fit the parameters...
I've got no idea what's going wrong, and if you need any additional information, I'd be more than happy to provide.
Thanks in advance.