[solved] logic in device->run but keeping it tidy
Posted: Tue Jan 30, 2024 12:59 am
Nice to be here. I didn't want to ask unless necessary. I've only looked up to tutorial 10 so far, so maybe slap my hand.
I did manage to compile. I did add a quit key. I did add a jump button. I did use metatriangle. I have added a child cube to my camera which detects intersections. I have managed that...
Most of the examples have a tiny while loop and the smgr and driver automatically update the game. I felt triggers and logic can be dealt with in the same way. The only thing I've come across so far is adding a scene node animator, because all movement/intersection/hitting walls is essentially animation?
If I want to check intersections now, I do this... Which is messing up the while loop. Can all logic in Irrlicht be dealt with by the smgr?
So from that, to this...?
I did manage to compile. I did add a quit key. I did add a jump button. I did use metatriangle. I have added a child cube to my camera which detects intersections. I have managed that...
Most of the examples have a tiny while loop and the smgr and driver automatically update the game. I felt triggers and logic can be dealt with in the same way. The only thing I've come across so far is adding a scene node animator, because all movement/intersection/hitting walls is essentially animation?
If I want to check intersections now, I do this... Which is messing up the while loop. Can all logic in Irrlicht be dealt with by the smgr?
Code: Select all
while(device->run())
{
if(receiver.IsQuit())
{
device->closeDevice();
}
//
// my messy code here
//
postBox = playerSmallBlock->getTransformedBoundingBox();
earthBox = node4->getTransformedBoundingBox();
playerBox = playerMesh->getTransformedBoundingBox();
if(playerBox.intersectsWithBox(postBox))
{
std::cout << "Player collided with Post.";
}
if(playerBox.intersectsWithBox(earthBox))
{
std::cout << "Player collided with Earth.";
}
driver->beginScene(true, true, f);
smgr->drawAll();
driver->endScene();
}
Code: Select all
while(device->run())
{
driver->beginScene(true, true, SColor(255,100,101,140));
smgr->drawAll();
guienv->drawAll();
driver->endScene();
}