HelloPolycodeApp.cpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #include "HelloPolycodeApp.h"
  2. HelloPolycodeApp::HelloPolycodeApp(PolycodeView *view) {
  3. #ifdef __APPLE__
  4. core = new CocoaCore(view, 640,480,false,false,0,0,90);
  5. #else
  6. core = new SDLCore(view, 640,480,false,false,0,0,90);
  7. #endif
  8. CoreServices::getInstance()->getResourceManager()->addArchive("Resources/default.pak");
  9. CoreServices::getInstance()->getResourceManager()->addDirResource("default", false);
  10. Screen *screen = new Screen();
  11. sourceEntity = new ScreenEntity();
  12. ScreenSound *testSound = new ScreenSound("Resources/test.wav", 200, 600);
  13. testSound->getSound()->Play(true);
  14. sourceEntity->addChild(testSound);
  15. ScreenShape *soundShape = new ScreenShape(ScreenShape::SHAPE_CIRCLE, 20,20,10);
  16. sourceEntity->addChild(soundShape);
  17. screen->addChild(sourceEntity);
  18. listenerEntity = new ScreenEntity();
  19. ScreenSoundListener *soundListener = new ScreenSoundListener();
  20. listenerEntity->addChild(soundListener);
  21. soundShape = new ScreenShape(ScreenShape::SHAPE_CIRCLE, 20,20,10);
  22. soundShape->setColor(0.0, 1.0, 0.0, 1.0);
  23. listenerEntity->addChild(soundShape);
  24. screen->addChild(listenerEntity);
  25. listenerPositionValue = 0;
  26. positionValue = 0;
  27. }
  28. HelloPolycodeApp::~HelloPolycodeApp() {
  29. }
  30. bool HelloPolycodeApp::Update() {
  31. positionValue += core->getElapsed();
  32. listenerPositionValue += core->getElapsed() * 0.3;
  33. sourceEntity->setPosition(300 + (sin(positionValue) * 300), 250 + cos(positionValue) * 100);
  34. listenerEntity->setPosition(300 + (sin(listenerPositionValue) * 300), 250);
  35. return core->Update();
  36. }