HelloPolycodeApp.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #include "HelloPolycodeApp.h"
  2. HelloPolycodeApp::HelloPolycodeApp(PolycodeView *view) : EventHandler() {
  3. #ifdef __APPLE__
  4. core = new CocoaCore(view, 640,480,false,0,90);
  5. #else
  6. core = new SDLCore(view, 640,480,false,0,90);
  7. #endif
  8. CoreServices::getInstance()->getResourceManager()->addArchive("Resources/default.pak");
  9. CoreServices::getInstance()->getResourceManager()->addDirResource("default", false);
  10. PhysicsScene *scene = new PhysicsScene();
  11. ScenePrimitive *ground = new ScenePrimitive(ScenePrimitive::TYPE_PLANE, 10, 10);
  12. ground->loadTexture("Resources/green_texture.png");
  13. scene->addPhysicsChild(ground, PhysicsSceneEntity::SHAPE_PLANE, 0.0);
  14. for(int i=0; i < 100; i++) {
  15. ScenePrimitive *box = new ScenePrimitive(ScenePrimitive::TYPE_BOX, 0.5,0.5,0.5);
  16. box->loadTexture("Resources/pink_texture.png");
  17. box->Roll(-45 + (rand() % 90));
  18. box->Pitch(-45 + (rand() % 90));
  19. box->setPosition(-2 + (rand() % 4), i*0.5, -2 + (rand() % 4));
  20. scene->addPhysicsChild(box, PhysicsSceneEntity::SHAPE_BOX, 1.0);
  21. }
  22. scene->getDefaultCamera()->setPosition(7,7,7);
  23. scene->getDefaultCamera()->lookAt(Vector3(0,0,0));
  24. }
  25. void HelloPolycodeApp::handleEvent(Event *event) {
  26. }
  27. bool HelloPolycodeApp::Update() {
  28. return core->Update();
  29. }