Esempio n. 1
0
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);

	PhysicsScene *scene = new PhysicsScene();

	ScenePrimitive *ground = new ScenePrimitive(ScenePrimitive::TYPE_PLANE, 10, 10);
	ground->loadTexture("Resources/green_texture.png");
	scene->addPhysicsChild(ground, PhysicsSceneEntity::SHAPE_PLANE, 0.0);

	for(int i=0; i < 100; i++) {
		ScenePrimitive *box = new ScenePrimitive(ScenePrimitive::TYPE_BOX, 0.5,0.5,0.5);
		box->loadTexture("Resources/pink_texture.png");
		box->Roll(-45 + (rand() % 90));
		box->Pitch(-45 + (rand() % 90));		
		box->setPosition(-2 + (rand() % 4), i*0.5, -2 + (rand() % 4));
		scene->addPhysicsChild(box, PhysicsSceneEntity::SHAPE_BOX, 1.0);
	}
	
	scene->getDefaultCamera()->setPosition(7,7,7);
	scene->getDefaultCamera()->lookAt(Vector3(0,0,0));
	
}
Esempio n. 2
0
WorldManager::WorldManager()
{
	scene = shared_ptr<PhysicsScene2D>(new PhysicsScene2D(0.1, 60));

	ScenePrimitive *shape = new ScenePrimitive(ScenePrimitive::TYPE_VPLANE, 1.0,0.05);
	shape->setColor(0.0,0.0,0.1,1.0);
	shape->setPosition(0, -0.3);
	scene->addPhysicsChild(shape, PhysicsScene2DEntity::ENTITY_RECT, true);	
	
	ScenePrimitive *shape2 = new ScenePrimitive(ScenePrimitive::TYPE_VPLANE, 0.05, 1.0);
	shape2->setColor(0.0,0.0,0.1,1.0);
	shape2->setPosition(-0.3, -0.4);
	shape2->setRoll(45);
	scene->addPhysicsChild(shape2, PhysicsScene2DEntity::ENTITY_RECT, true);	
	
	ScenePrimitive *shape3 = new ScenePrimitive(ScenePrimitive::TYPE_VPLANE, 0.05, 1.0);
	shape3->setColor(0.0,0.0,0.1,1.0);
	shape3->setPosition(0.3, -0.4);
	shape3->setRoll(-45);
	scene->addPhysicsChild(shape3, PhysicsScene2DEntity::ENTITY_RECT, true);	
	
	// for(int i=0; i < 1000; i++) {
	// 	shape = new ScenePrimitive(ScenePrimitive::TYPE_VPLANE, 0.02,0.02);
	// 	shape->setRoll(rand() % 360);
 //        shape->setColor(RANDOM_NUMBER, RANDOM_NUMBER, RANDOM_NUMBER, 1.0);
	// 	shape->setPosition(-0.3 + (RANDOM_NUMBER*0.6), RANDOM_NUMBER);
	// 	scene->addPhysicsChild(shape, PhysicsScene2DEntity::ENTITY_RECT, false);
	// }
}
Esempio n. 3
0
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));
}
Esempio n. 4
0
ProGameObject::ProGameObject( P::Core* _core )
    : HeliumGameCore( _core ) 
{
    CoreServices::getInstance()->getResourceManager()->addArchive(g_helium_resource_path+"/default.pak");
    CoreServices::getInstance()->getResourceManager()->addDirResource("default", false);
    
    keyboardInput->addEventHandler( P::KEY_1, new AddDice());
    keyboardInput->addEventHandler( P::KEY_2, new AddBoll());
    keyboardInput->addEventHandler( P::KEY_3, new AddBarrel());

    keyboardInput->addEventHandler( P::KEY_d, new YCameraMove());
    keyboardInput->addEventHandler( P::KEY_a, new YNegativeCameraMove());
    keyboardInput->addEventHandler( P::KEY_w, new XCameraMove());
    keyboardInput->addEventHandler( P::KEY_s, new XNegativeCameraMove());
    
    objectWorld.getEngineScenePt()->getDefaultCamera()->setPosition(17,17,17);
	objectWorld.getEngineScenePt()->getDefaultCamera()->lookAt(Vector3(0,0,0));

	ScenePrimitive* ground = new ScenePrimitive(ScenePrimitive::TYPE_PLANE, 16, 16);
	ground->loadTexture(g_helium_resource_path + "/simple_stone_texture.png");
	objectWorld.getEngineScenePt()->addPhysicsChild(ground, PhysicsSceneEntity::SHAPE_PLANE, 0.0);
    
    ScenePrimitive* wall = new ScenePrimitive(ScenePrimitive::TYPE_VPLANE, 16, 4);
	wall->loadTexture(g_helium_resource_path + "/simple_stone_texture.png");
	wall->setPosition( 0, 2, 8 );
	objectWorld.getEngineScenePt()->addPhysicsChild(wall, PhysicsSceneEntity::SHAPE_PLANE, 0.0);
    
    wall = new ScenePrimitive(ScenePrimitive::TYPE_VPLANE, 16, 4);
	wall->loadTexture(g_helium_resource_path + "/simple_stone_texture.png");
	wall->setPosition( 0, 2, -8 );
	objectWorld.getEngineScenePt()->addPhysicsChild(wall, PhysicsSceneEntity::SHAPE_PLANE, 0.0);

    wall = new ScenePrimitive(ScenePrimitive::TYPE_VPLANE, 16, 4);
	wall->loadTexture(g_helium_resource_path + "/simple_stone_texture.png");
	wall->setYaw( 90 );
	wall->setPosition( 8, 2, 0 );
	objectWorld.getEngineScenePt()->addPhysicsChild(wall, PhysicsSceneEntity::SHAPE_PLANE, 0.0);

    wall = new ScenePrimitive(ScenePrimitive::TYPE_VPLANE, 16, 4);
	wall->loadTexture(g_helium_resource_path + "/simple_stone_texture.png");
	wall->setYaw( 90 );
	wall->setPosition( -8, 2, 0 );
	objectWorld.getEngineScenePt()->addPhysicsChild(wall, PhysicsSceneEntity::SHAPE_PLANE, 0.0);
    
    HeliumExitScreenButton exitBt(this);
    this->getScreenWorldPt()->addObject( &exitBt );
}
Esempio n. 5
0
HelloPolycodeApp::HelloPolycodeApp(PolycodeView *view) {

	core = new POLYCODE_CORE(view, 640,480,false,true,0,0,90, 0, true);

	PhysicsScene2D *scene = new PhysicsScene2D(0.1, 50);

	ScenePrimitive *ceiling = new ScenePrimitive(ScenePrimitive::TYPE_VPLANE, 2.0, 0.1);
	ceiling->setColor(0.0, 0.0, 0.0, 1.0);
	ceiling->setPosition(0, 0.5);
	scene->addPhysicsChild(ceiling, PhysicsScene2DEntity::ENTITY_RECT, true);
	
	// Revolute Joint	
	ScenePrimitive *shape = new ScenePrimitive(ScenePrimitive::TYPE_VPLANE, 0.03, 0.2);
    shape->setAnchorPoint(0.0, 1.0, 0.0);
	shape->setPosition(-0.3, 0.48);
	scene->addPhysicsChild(shape, PhysicsScene2DEntity::ENTITY_RECT, false);
	scene->createRevoluteJoint(shape, ceiling, 0.0, 0.01);
	scene->applyImpulse(shape, 10, 0);
	
	// Distance Joint	
	shape = new ScenePrimitive(ScenePrimitive::TYPE_VPLANE, 0.1, 0.02);
	shape->setPosition(0.0, 0.2);
	scene->addPhysicsChild(shape, PhysicsScene2DEntity::ENTITY_RECT, false);
	scene->createDistanceJoint(shape, ceiling, false);
	scene->applyImpulse(shape, 2, 0);
	
	SceneLine *line = new SceneLine(shape, ceiling);
	line->setColor(1.0, 0.0, 0.0, 1.0);
	scene->addChild(line);

	// Prismatic Joint	
	shape = new ScenePrimitive(ScenePrimitive::TYPE_VPLANE, 0.05, 0.1);
	shape->setPosition(0.3, 0.3);
	scene->addPhysicsChild(shape, PhysicsScene2DEntity::ENTITY_RECT, false);
	scene->createPrismaticJoint(ceiling, shape, Vector2(0,1), 0,0, false, -0.3, 0, true);

	SceneEntity *lineAnchor = new SceneEntity();
	lineAnchor->setPosition(0.3,0.5);
	line = new SceneLine(shape, lineAnchor);
	line->setColor(0.0, 1.0, 0.0, 1.0);
	scene->addChild(line);
}
Esempio n. 6
0
void WorldManager::update()
{
	count++;

	if(count % 10 == 0) 
	{
		ScenePrimitive *shape;
		shape = new ScenePrimitive(ScenePrimitive::TYPE_VPLANE, 0.02,0.02);
		shape->setRoll(rand() % 360);
        shape->setColor(RANDOM_NUMBER, RANDOM_NUMBER, RANDOM_NUMBER, 1.0);
		shape->setPosition(-0.3 + (RANDOM_NUMBER*0.6), RANDOM_NUMBER);
		scene->addPhysicsChild(shape, PhysicsScene2DEntity::ENTITY_RECT, false);
	}
}
Esempio n. 7
0
HelloPolycodeApp::HelloPolycodeApp(PolycodeView *view) {

	core = new POLYCODE_CORE(view, 640,480,false,true,0,0,90,0, true);
	
	CoreServices::getInstance()->getResourceManager()->addArchive("Resources/default.pak");
	CoreServices::getInstance()->getResourceManager()->addDirResource("default", false);	

	scene = new PhysicsScene2D(0.01, 50);
	lastEntity = NULL;
	
	for(int i=0; i < 50; i++) {
		ScenePrimitive *shape = new ScenePrimitive(ScenePrimitive::TYPE_VPLANE, 0.1,0.02);
		shape->setRoll(rand() % 360);
		shape->setPosition(-0.5 + RANDOM_NUMBER, -0.5 + RANDOM_NUMBER);
		scene->addCollisionChild(shape, PhysicsScene2DEntity::ENTITY_RECT);
	}
	
}
Esempio n. 8
0
HelloPolycodeApp::HelloPolycodeApp(PolycodeView *view) {

	core = new POLYCODE_CORE(view, 640,480,false,false,0,0,90);

	CoreServices::getInstance()->getResourceManager()->addArchive("Resources/default.pak");
	CoreServices::getInstance()->getResourceManager()->addDirResource("default", false);

	Scene *scene = new Scene();
	ScenePrimitive *ground = new ScenePrimitive(ScenePrimitive::TYPE_PLANE, 5,5);
	ground->loadTexture("Resources/green_texture.png");
	scene->addEntity(ground);

	ScenePrimitive *box = new ScenePrimitive(ScenePrimitive::TYPE_BOX, 1,1,1);
	box->loadTexture("Resources/pink_texture.png");
	box->setPosition(0.0, 0.5, 0.0);
	scene->addEntity(box);
	
	scene->getDefaultCamera()->setPosition(7,7,7);
	scene->getDefaultCamera()->lookAt(Vector3(0,0,0));

}
Esempio n. 9
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();
}
Esempio n. 10
0
HelloPolycodeApp::HelloPolycodeApp(PolycodeView *view) : EventHandler() {

    core = new POLYCODE_CORE(view, 640,480,false,false,0,0,90);

    CoreServices::getInstance()->getResourceManager()->addArchive("Resources/default.pak");
    CoreServices::getInstance()->getResourceManager()->addDirResource("default", false);

    Screen *hud = new Screen();

    onGroundLabel = new ScreenLabel("Arrow keys to control, spacebar to brake, press R to reset car", 16);
    hud->addChild(onGroundLabel);

    scene = new PhysicsScene();

    ScenePrimitive *ground = new ScenePrimitive(ScenePrimitive::TYPE_PLANE, 30, 30);
    ground->loadTexture("Resources/green_texture.png");
    scene->addPhysicsChild(ground, PhysicsSceneEntity::SHAPE_PLANE, 0.0);

    // Some obstacles
    ScenePrimitive *box = new ScenePrimitive(ScenePrimitive::TYPE_BOX, 4,4,6);
    box->setPitch(25.0);
    box->setPosition(7,-1.05, 0.0);
    box->setColor(0.5,0.5,1.0,1.0);
    box->loadTexture("Resources/green_texture.png");
    scene->addPhysicsChild(box, PhysicsSceneEntity::SHAPE_BOX, 0.0);

    box = new ScenePrimitive(ScenePrimitive::TYPE_BOX, 4,4,6);
    box->setPitch(25.0);
    box->setPosition(-7,-1.05, 0.0);
    box->setColor(0.5,0.5,1.0,1.0);
    box->loadTexture("Resources/green_texture.png");
    scene->addPhysicsChild(box, PhysicsSceneEntity::SHAPE_BOX, 0.0);

    box = new ScenePrimitive(ScenePrimitive::TYPE_BOX, 20,2,5);
    box->setPosition(0.0,1.0, -4.3);
    box->setColor(0.5,0.5,1.0,1.0);
    box->loadTexture("Resources/green_texture.png");
    scene->addPhysicsChild(box, PhysicsSceneEntity::SHAPE_BOX, 0.0);

    for(int i=0; i < 10; i++) {
        ScenePrimitive *box = new ScenePrimitive(ScenePrimitive::TYPE_BOX, 0.7,0.7,0.7);
        box->loadTexture("Resources/pink_texture.png");
        box->Roll(-45 + (rand() % 90));
        box->Pitch(-45 + (rand() % 90));
        box->setPosition(-3 + (rand() % 6), 2 + i*0.5, -5 + (rand() % 3));
        scene->addPhysicsChild(box, PhysicsSceneEntity::SHAPE_BOX, 1.0);
    }

    // The vehicle
    vehicle = new ScenePrimitive(ScenePrimitive::TYPE_BOX, 1.0,0.5,2.0);
    vehicle->loadTexture("Resources/pink_texture.png");
    vehicle->setColor(1.0, 1.0, 0.0, 1.0);
    vehicle->setPosition(6,1,5);
    vehicleController = scene->addVehicleChild(vehicle, 5.0, 1.0);

    ScenePrimitive *wheel = new ScenePrimitive(ScenePrimitive::TYPE_SPHERE, 0.3, 10, 10);
    wheel->loadTexture("Resources/pink_texture.png");
    wheel->setColor(0.0, 1.0, 0.0, 1.0);
    vehicleController->addWheel(wheel, Vector3(0.6,0,-0.5), Vector3(0,-1,0), Vector3(-1,0,0), 0.2,  0.3, true);
    scene->addEntity(wheel);

    wheel = new ScenePrimitive(ScenePrimitive::TYPE_SPHERE, 0.3, 10, 10);
    wheel->loadTexture("Resources/pink_texture.png");
    wheel->setColor(0.0, 1.0, 0.0, 1.0);
    vehicleController->addWheel(wheel, Vector3(-0.6,0,-0.5), Vector3(0,-1,0), Vector3(-1,0,0), 0.2,  0.3, true);
    scene->addEntity(wheel);

    wheel = new ScenePrimitive(ScenePrimitive::TYPE_SPHERE, 0.3, 10, 10);
    wheel->loadTexture("Resources/pink_texture.png");
    wheel->setColor(0.0, 1.0, 0.0, 1.0);
    vehicleController->addWheel(wheel, Vector3(0.6,0,0.5), Vector3(0,-1,0), Vector3(-1,0,0), 0.2,  0.3, false);
    scene->addEntity(wheel);

    wheel = new ScenePrimitive(ScenePrimitive::TYPE_SPHERE, 0.3, 10, 10);
    wheel->loadTexture("Resources/pink_texture.png");
    wheel->setColor(0.0, 1.0, 0.0, 1.0);
    vehicleController->addWheel(wheel, Vector3(-0.6,0,0.5), Vector3(0,-1,0), Vector3(-1,0,0), 0.2,  0.3, false);
    scene->addEntity(wheel);

    steeringValue = 0;
    engineForce = 0;
    breaking = false;

    testBox = new ScenePrimitive(ScenePrimitive::TYPE_BOX, 4, 4, 4);
    testBox->loadTexture("Resources/pink_texture.png");
    testBox->setColor(0.3,0.5, 1.0,0.4);
    testBox->setPosition(-5,2,7);
    scene->addCollisionChild(testBox, PhysicsSceneEntity::SHAPE_BOX);


    scene->getDefaultCamera()->setPosition(16,16,16);
    scene->getDefaultCamera()->lookAt(Vector3(0,0,0));

    core->getInput()->addEventListener(this, InputEvent::EVENT_KEYDOWN);
    core->getInput()->addEventListener(this, InputEvent::EVENT_KEYUP);
}