HelloPolycodeApp.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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 = new PhysicsScreen(10, 50);
  11. lastEntity = NULL;
  12. for(int i=0; i < 50; i++) {
  13. ScreenShape *shape = new ScreenShape(ScreenShape::SHAPE_RECT, 30,15);
  14. shape->setRotation(rand() % 360);
  15. shape->setPosition(rand() % 640, rand() % 480);
  16. screen->addCollisionChild(shape, PhysicsScreenEntity::ENTITY_RECT);
  17. }
  18. }
  19. HelloPolycodeApp::~HelloPolycodeApp() {
  20. }
  21. bool HelloPolycodeApp::Update() {
  22. if(lastEntity)
  23. lastEntity->setColor(1.0, 1.0, 1.0, 1.0);
  24. Vector2 mouse = core->getInput()->getMousePosition();
  25. ScreenEntity * entity = screen->getEntityAtPosition(mouse.x, mouse.y);
  26. if(entity) {
  27. entity->setColor(1.0, 0.0, 0.0, 1.0);
  28. lastEntity = entity;
  29. }
  30. return core->Update();
  31. }