HelloPolycodeApp.cpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #include "HelloPolycodeApp.h"
  2. HelloPolycodeApp::HelloPolycodeApp(PolycodeView *view) {
  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. Scene *scene = new Scene();
  11. sourceEntity = new SceneEntity();
  12. SceneSound *testSound = new SceneSound("Resources/test.wav", 20, 50);
  13. testSound->getSound()->Play(true);
  14. sourceEntity->addChild(testSound);
  15. ScenePrimitive *soundShape = new ScenePrimitive(ScenePrimitive::TYPE_BOX, 1,1,1);
  16. soundShape->setMaterialByName("Default");
  17. sourceEntity->addChild(soundShape);
  18. scene->addEntity(sourceEntity);
  19. SceneLight *light = new SceneLight(SceneLight::AREA_LIGHT, scene, 1000);
  20. scene->addLight(light);
  21. SceneSoundListener *soundListener = new SceneSoundListener();
  22. scene->addEntity(soundListener);
  23. positionValue = 0;
  24. }
  25. HelloPolycodeApp::~HelloPolycodeApp() {
  26. }
  27. bool HelloPolycodeApp::Update() {
  28. positionValue += core->getElapsed();
  29. sourceEntity->setPosition((sin(positionValue) * 20), 0, cos(positionValue) * 50);
  30. sourceEntity->Roll(core->getElapsed() * 120);
  31. sourceEntity->Pitch(core->getElapsed()* 120);
  32. return core->Update();
  33. }