2
0

HelloPolycodeApp.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. sun = new ScreenShape(ScreenShape::SHAPE_CIRCLE, 100,100, 30);
  12. sun->setPosition(640/2, 480/2);
  13. sun->setColor(0.9, 0.8, 0, 1);
  14. sun->colorAffectsChildren = false;
  15. screen->addChild(sun);
  16. planet = new ScreenShape(ScreenShape::SHAPE_CIRCLE, 50,50, 30);
  17. planet->setPosition(150,0);
  18. planet->setColor(0.2, 0.8, 0, 1);
  19. planet->colorAffectsChildren = false;
  20. sun->addChild(planet);
  21. moon = new ScreenShape(ScreenShape::SHAPE_CIRCLE, 20,20, 30);
  22. moon->setPosition(50,0);
  23. moon->setColor(1, 1, 0.6, 1);
  24. planet->addChild(moon);
  25. planetRotation = 0;
  26. moonRotation = 0;
  27. }
  28. bool HelloPolycodeApp::Update() {
  29. Number elapsed = core->getElapsed();
  30. planetRotation += elapsed ;
  31. moonRotation += elapsed * 6;
  32. planet->setPosition(cosf(planetRotation)*150, sinf(planetRotation)*150);
  33. moon->setPosition(cosf(moonRotation)*50, sinf(moonRotation)*50);
  34. return core->Update();
  35. }