HelloPolycodeApp.cpp 1.2 KB

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