HelloPolycodeApp::HelloPolycodeApp(PolycodeView *view) : EventHandler() { #ifdef __APPLE__ core = new CocoaCore(view, 640,480,false,false,0,0,90); #else core = new SDLCore(view, 640,480,false,false,0,0,90); #endif CoreServices::getInstance()->getResourceManager()->addArchive("Resources/default.pak"); CoreServices::getInstance()->getResourceManager()->addDirResource("default", false); CoreServices::getInstance()->getResourceManager()->addDirResource("Resources", false); Scene *scene = new Scene(); ScenePrimitive *ground = new ScenePrimitive(ScenePrimitive::TYPE_PLANE, 5,5); ground->setMaterialByName("GroundMaterial"); scene->addEntity(ground); ScenePrimitive *box = new ScenePrimitive(ScenePrimitive::TYPE_TORUS, 0.8,0.3,30,20); box->setMaterialByName("CubeMaterial"); box->setPosition(0.0, 0.5, 0.0); scene->addEntity(box); SceneLight *light = new SceneLight(SceneLight::AREA_LIGHT, scene, 5); light->setPosition(1,2,1); scene->addLight(light); scene->getDefaultCamera()->setPosition(7,7,7); scene->getDefaultCamera()->lookAt(Vector3(0,0,0)); }
CurrentApp::CurrentApp(PolycodeView *view) : EventHandler() { core = new SDLCore(view, 640,480,false,false,0,0,120); srand(time(NULL)); CoreServices::getInstance()->getResourceManager()->addArchive("default.pak"); CoreServices::getInstance()->getResourceManager()->addDirResource("default", false); CoreServices::getInstance()->getResourceManager()->addDirResource("Resources", false); scene = new CollisionScene(); level = new LevelManager(30, scene); // Creating the Player object ScenePrimitive * obj = new ScenePrimitive( ScenePrimitive::TYPE_SPHERE, 0.5, 10,10); obj->setPosition(Vector3(0.0, 0.0, 0.0)); obj->setMaterialByName("CubeMaterial"); scene->addCollisionChild(obj); hud = new Screen(); keys_pressed = new ScreenLabel("Stats: ",16); hud->addChild(keys_pressed); coins_hud = new ScreenLabel("Coins: 0", 16); coins_hud->setPosition(0,20); time_hud = new ScreenLabel("Time: 00:00:00", 16); time_hud->setPosition(0,40); hud->addChild(coins_hud); hud->addChild(time_hud); player = Player(obj); core->getInput()->addEventListener(this, InputEvent::EVENT_KEYDOWN); core->getInput()->addEventListener(this, InputEvent::EVENT_KEYUP); //player.Load(scene, hud); //physScene->addPhysicsChild(obj, PhysicsSceneEntity::SHAPE_SPHERE, 1.0); player.Load(scene); timer.start(); }
HelloPolycodeApp::HelloPolycodeApp(PolycodeView *view) { #ifdef __APPLE__ core = new CocoaCore(view, 640,480,false,false,0,0,90); #else core = new SDLCore(view, 640,480,false,false,0,0,90); #endif CoreServices::getInstance()->getResourceManager()->addArchive("Resources/default.pak"); CoreServices::getInstance()->getResourceManager()->addDirResource("default", false); CoreServices::getInstance()->getResourceManager()->addDirResource("Resources", false); Scene *scene = new Scene(); ScenePrimitive *ground = new ScenePrimitive(ScenePrimitive::TYPE_PLANE, 5,5); ground->setMaterialByName("GroundMaterial"); scene->addEntity(ground); scene->getDefaultCamera()->setPosition(7,7,7); scene->getDefaultCamera()->lookAt(Vector3(0,0,0)); Mesh *mesh = new Mesh(Mesh::QUAD_MESH); // mesh->createBox(1, 1, 1); mesh->createTorus(0.3,0.2,10,10); SceneParticleEmitter *emitter = new SceneParticleEmitter("Default", scene, Particle::MESH_PARTICLE, ParticleEmitter::CONTINUOUS_EMITTER, 4, 100, Vector3(0.0,1.0,0.0), Vector3(0.0,0.0,0.0), Vector3(0.3, 0.0, 0.3), Vector3(1.5,1.5,1.5), mesh); emitter->useScaleCurves = true; emitter->scaleCurve.addControlPoint2d(0, 0.1); emitter->scaleCurve.addControlPoint2d(0.5, 0.3); emitter->scaleCurve.addControlPoint2d(1, 0); scene->addEntity(emitter); SceneLight *light = new SceneLight(SceneLight::AREA_LIGHT, scene, 5); light->setPosition(3,2,3); light->setLightColor(1,0,0); scene->addLight(light); light = new SceneLight(SceneLight::AREA_LIGHT, scene, 5); light->setPosition(-3,2,3); light->setLightColor(0,1,0); scene->addLight(light); light = new SceneLight(SceneLight::AREA_LIGHT, scene, 5); light->setPosition(-3,2,-3); light->setLightColor(0,0,1); scene->addLight(light); light = new SceneLight(SceneLight::AREA_LIGHT, scene, 5); light->setPosition(3,2,-3); light->setLightColor(1,0,1); scene->addLight(light); light = new SceneLight(SceneLight::SPOT_LIGHT, scene, 4); light->setPosition(0,2,2); light->setSpotlightProperties(30,6); light->setLightColor(1,1,0); scene->addLight(light); light->lookAt(Vector3(0,0,0)); light->enableShadows(true); light = new SceneLight(SceneLight::SPOT_LIGHT, scene, 4); light->setPosition(0,2,-2); light->setSpotlightProperties(30,6); light->setLightColor(0,1,1); scene->addLight(light); light->lookAt(Vector3(0,0,0)); light->enableShadows(true); }
HelloPolycodeApp::HelloPolycodeApp(PolycodeView *view) : EventHandler() { core = new POLYCODE_CORE(view, 640,480,false,true,6,16,90, 0, true); CoreServices::getInstance()->getResourceManager()->addArchive("Resources/default.pak"); CoreServices::getInstance()->getResourceManager()->addDirResource("default", false); CoreServices::getInstance()->getResourceManager()->addDirResource("Resources", false); scene = new Scene(); ScenePrimitive *ground = new ScenePrimitive(ScenePrimitive::TYPE_PLANE, 5,5); ground->setMaterialByName("GroundMaterial"); scene->addEntity(ground); torus = new ScenePrimitive(ScenePrimitive::TYPE_TORUS, 0.8,0.3,30,20); torus->setMaterialByName("CubeMaterial"); torus->setPosition(0.0, 0.5, 0.0); scene->addEntity(torus); SceneLight *light = new SceneLight(SceneLight::POINT_LIGHT, scene, 5); light->setPosition(3,2,3); light->setLightColor(1,0,0); scene->addLight(light); light = new SceneLight(SceneLight::POINT_LIGHT, scene, 5); light->setPosition(-3,2,3); light->setLightColor(0,1,0); scene->addLight(light); light = new SceneLight(SceneLight::POINT_LIGHT, scene, 5); light->setPosition(-3,2,-3); light->setLightColor(0,0,1); scene->addLight(light); light = new SceneLight(SceneLight::POINT_LIGHT, scene, 5); light->setPosition(3,2,-3); light->setLightColor(1,0,1); scene->addLight(light); lights = new Entity(); scene->addChild(lights); light = new SceneLight(SceneLight::SPOT_LIGHT, scene, 4); light->setPosition(0,4,1); light->setLightColor(1,1,0); scene->addLight(light); lights->addChild(light); light->lookAt(Vector3(0,0,0)); light->enableShadows(true); light->getSpotlightCamera()->frustumCulling = false; light = new SceneLight(SceneLight::SPOT_LIGHT, scene, 4); light->setPosition(0,4,-1); light->setLightColor(0,1,1); scene->addLight(light); lights->addChild(light); light->lookAt(Vector3(0,0,0)); light->enableShadows(true); light->getSpotlightCamera()->frustumCulling = false; cameraRotation = 0.0; }