2
0

HelloPolycodeApp.cpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #include "HelloPolycodeApp.h"
  2. HelloPolycodeApp::HelloPolycodeApp(PolycodeView *view) {
  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. Scene *scene = new Scene(Scene::SCENE_2D_TOPLEFT);
  7. sourceEntity = new SceneEntity();
  8. SceneSound *testSound = new SceneSound("Resources/test.wav", 200, 600);
  9. testSound->getSound()->Play(true);
  10. sourceEntity->addChild(testSound);
  11. ScenePrimitive *soundShape = new ScenePrimitive(ScenePrimitive::TYPE_CIRCLE, 20,20,10);
  12. sourceEntity->addChild(soundShape);
  13. scene->addChild(sourceEntity);
  14. listenerEntity = new SceneEntity();
  15. SceneSoundListener *soundListener = new SceneSoundListener();
  16. listenerEntity->addChild(soundListener);
  17. soundShape = new ScenePrimitive(ScenePrimitive::TYPE_CIRCLE, 20,20,10);
  18. soundShape->setColor(0.0, 1.0, 0.0, 1.0);
  19. listenerEntity->addChild(soundShape);
  20. scene->addChild(listenerEntity);
  21. listenerPositionValue = 0;
  22. positionValue = 0;
  23. }
  24. HelloPolycodeApp::~HelloPolycodeApp() {
  25. }
  26. bool HelloPolycodeApp::Update() {
  27. positionValue += core->getElapsed();
  28. listenerPositionValue += core->getElapsed() * 0.3;
  29. sourceEntity->setPosition(300 + (sin(positionValue) * 300), 250 + cos(positionValue) * 100);
  30. listenerEntity->setPosition(300 + (sin(listenerPositionValue) * 300), 250);
  31. return core->updateAndRender();
  32. }