HelloPolycodeApp.cpp 1.3 KB

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