#include #include "IrrLib.h" #include using namespace std; using namespace irr; using namespace core; using namespace scene; using namespace video; using namespace io; using namespace gui; int main(){ IrrLib Irrlicht(5, 640, 480, 16, false, true, false); Irr3DObjColor col1; Irr3DObjColor col2; int nHits; int nTimes = 0; //Color 1 col1.a = 255; col1.r = 0; col1.g = 255; col1.b = 5; //color 2 col2.a = 255; col2.r = 0; col2.g = 255; col2.b = 255; //Pos 1 Irr3DPos pos1; pos1.x = 0; pos1.y = 0; pos1.z = 0; Irr3DObj obj1; obj1->setColor(col1); obj1->setMesh("sphere.3ds"); Irr3DObj obj2; obj2->setMesh("cube.3ds"); obj2->setColor(col2); obj1->addToScene(); obj2->addToScene(); Irrlicht.AddFPSCam(); while (Irrlicht.DeviceIsRunning()) if (Irrlicht.IsActiveWindow()) { nHits = CheckForCollision(obj1,obj2); if (nHits > 0) { cout << "The sphere collided with the squre " << nTimes << endl; nTimes++; } if (Irrlicht.IrrEvent.keyStates[KEY_KEY_W]){ Irrlicht.IrrEvent.keyStates[KEY_KEY_W] = false; pos1.x = pos1.x + 10; obj1->Move(pos1); } if (Irrlicht.IrrEvent.keyStates[KEY_KEY_S]){ Irrlicht.IrrEvent.keyStates[KEY_KEY_S] = false; pos1.x = pos1.x - 10; obj1->Move(pos1); } Irrlicht.BeginScene(Irrlicht.Color.RED); Irrlicht.DrawAll(); Irrlicht.EndScene(); nHits = 0; } Irrlicht.EndIrrlicht(); return 0; }