Ejemplo n.º 1
0
void TSShapeInstance::animateGround()
{
   mGroundTransform.identity();

   // pick thread which controlls ground transform
   // if we haven't already...
   if (!mGroundThread && !initGround())
      return;

   S32 & loop    = mGroundThread->path.loop;
   F32 & start = mGroundThread->path.start;
   F32 & end   = mGroundThread->path.end;

   // accumulate path transform
   if (loop>0)
   {
      addPath(mGroundThread,start,1.0f);
      while (--loop)
         addPath(mGroundThread,0.0f,1.0f);
      addPath(mGroundThread,0.0f,end);
   }
   else if (loop<0)
   {
      addPath(mGroundThread,start,0.0f);
      while (++loop)
         addPath(mGroundThread,1.0f,0.0f);
      addPath(mGroundThread,1.0f,end);
   }
   else
      addPath(mGroundThread,start,end);
   start = end; // in case user tries to animateGround twice
}
Ejemplo n.º 2
0
        virtual void onInit()
        {
            Demo3DBase::onInit();

            initEnvMap();
            initLights();
            initGround();     

            ior = 0.01f;
            glossiness = 0.01f;
            materialIndex = 0;
            meshIndex = 0;
        }
Ejemplo n.º 3
0
bool init()
{
	if (SDL_Init(SDL_INIT_VIDEO) < 0)
	{
		printf("SDL could not initialize! SDL Error: %s\n", SDL_GetError());
		return false;
	}

	SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
	SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
	SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
	SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
	SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
	SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
	SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8);
	SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
	SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);

	// Create window
	gWindow = SDL_CreateWindow("BasicTest", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE);
	if (!gWindow)
	{
		printf("Window could not be created! SDL Error: %s\n", SDL_GetError());
		return false;
	}

	// Create context
	gContext = SDL_GL_CreateContext(gWindow);
	if (!gContext)
	{
		printf("OpenGL context could not be created! SDL Error: %s\n", SDL_GetError());
		return false;
	}

	// Use Vsync
	if (SDL_GL_SetSwapInterval(1) < 0)
	{
		printf("Warning: Unable to set VSync! SDL Error: %s\n", SDL_GetError());
		return false;
	}

	initEngine();
	initLights();
	initCharacter();
	initWeapon();
	initRide();
	initGround();

	return true;
}
Ejemplo n.º 4
0
bool GameLayer::init()
{
	//NULLIFY!
	ground = NULL;
	m_world = NULL;
	cannon = NULL;
	background = NULL;
	backgroundLight = NULL;
	
	//SET WIN SIZE
	winSize = Director::getInstance()->getVisibleSize();

	worldStartX = 0;
	worldEndX = 5*winSize.width/3;
	worldHeight = worldEndX;
	perspectiveX = (3*winSize.width)/4;

	trajectoryFrames = 0;

	if ( !Layer::init() ) return false;

	directionPoint.Set( 100, 100 );
	globalScale = 0.5;

	//INIT BACKGROUND
	initBackground();

	//INIT BOX2D
	initBox2D();

	//CREATE GROUND
	initGround();
	
	//GENERATE CLOUDS
	generateClouds();
	
	//CREATE CANNON
	initCannon();
	
	//GENERATE ENEMIES
	generateEnemies();

	this->setTouchEnabled(true);
	
	this->schedule( schedule_selector(GameLayer::tick) );
	
	return true;
}
Ejemplo n.º 5
0
void Game::init(sf::RenderWindow* window, Settings* settings)
{
	this->settings = settings;
	this->window = window;

	backgroundColor = sf::Color(0, 0, 0);
	isGameOver = false;
	currentLevel = 0;
	nrOfMeteorsLeftTilNextLevel = 0;

	initGround();
	initMissileBase();
	initCities();
	initProjectileParameters();
	score = Score(settings, sf::Vector2f(5, 5), sf::Color::White);
}
Ejemplo n.º 6
0
worldRenderer::worldRenderer(maze *m) : m(m), bridge(m) {
	pillarBox.setSize(pillarSize, pillarHeight, pillarSize, pillarHeight);
    groundBox.setSize(tileSize, blockHeight * 2.f, tileSize, tileSize);
    wallBox.setSize(tileSize - wallThickness, wallHeight, wallThickness, tileSize * 0.5f);
    startBox.setSize(startBoxSize, startBoxHeight, startBoxSize, startBoxSize);
    endBox.setSize(startBoxSize, startBoxHeight, startBoxSize, startBoxSize);
    arrowBox.setSize(startBoxSize, startBoxHeight, startBoxSize, startBoxSize);
    marble.setSize(marbleRadius, 16, 16);

	width = m->width();
	height = m->height();

	initPillars();
	initGround();
	initWalls();
	initItems();
}
Ejemplo n.º 7
0
void GameLayer::extraInit() {
    
    initRole();
    initGround();
    initCollisions();
    
    setRoleState(ROLE_STATE_JUMP_DOWN);
    setTouchEnabled(false);
    
    BBButton *button = BBButton::create(CCSizeMake(200, 60), this, bbButtonFunI_selector(GameLayer::restart), NULL, NULL, NULL, NULL, "Play Again");
    button->mLabel->setFontSize(30);
    button->setPosition(CCPoint(getContentSize().width - button->getContentSize().width, getContentSize().height - button->getContentSize().height));
    button->mDependedTarget = this;
    this->addChild(button, 10);
    
    setScore(0);
    
    beginCountdown(3);
}
Ejemplo n.º 8
0
GameTrack::GameTrack(GameTrackDesc* desc,GameGraphic* graphics,
		GameResourceManager* _manager,DRenderNode* parent) {
	manager=_manager;
	ground_image=NULL;
	sim=new R2DSim();
	parent_node=parent;
	render_node=parent->createNode();
	num_start_positions=0;
	num_cars=0;

	sim->set_query_func(surface_query,this);

	DResource *ground[4];
	ground[0]=manager->getImg(desc->colors[0]);
	ground[1]=manager->getImg(desc->colors[1]);
	ground[2]=manager->getImg(desc->colors[2]);
	ground[3]=manager->getImg(desc->colors[3]);
	DResource *ground_a=manager->getImg(desc->alpha);
	initGround(manager->client->createTerrain(ground,ground_a),desc->size);
	size=desc->size;
	dvect size2=size/2;

	int quadtree_levels=0;

	float x=max(size.x,size.y);
	while(x>5) {
		x/=2;
		quadtree_levels++;
	}

	printf("Quadtree depth: %d\n",quadtree_levels);
	quadtree=new DQuadTree(-size2,size2,quadtree_levels,NULL);

	for(vector<GameRoadDesc>::iterator i=desc->roads.begin();i!=desc->roads.end();i++) {
		GameRoadDesc* d=&(*i);
		addRoad(manager->client,new GameRoad(d),manager->getImg(i->color));
	}

	for(vector<GameTrackObject>::iterator i=desc->objects.begin();i!=desc->objects.end();i++) {
		GameTrackObject* o=&(*i);
		GameCarBody* body=manager->getBody(o->id);
		if(!body) {
			printf("Can't load object %s, skipping.\n",o->id.c_str());
			continue;
		}

		float scale=o->size_scale.x;

		GameCar* c=new GameCar(body,graphics,manager,scale);
		addObject(c,o->is_static);
	}


	for(int i=0;i<4;i++) {
		grips[i]=desc->grips[i];
		roughnesses[i]=desc->roughnesses[i];
	}

	float b=0.5;
	float f=1;
	sim->add_static_line(cpv(size2.x,size2.y),cpv(size2.x,-size2.y),b,f);
	sim->add_static_line(cpv(size2.x,size2.y),cpv(-size2.x,size2.y),b,f);
	sim->add_static_line(cpv(-size2.x,-size2.y),cpv(-size2.x,size2.y),b,f);
	sim->add_static_line(cpv(-size2.x,-size2.y),cpv(size2.x,-size2.y),b,f);

	//TODO: multiple update points
	update_radius=100;
	update_rad2=dvect(update_radius,update_radius)/2;

	lifetime_skids=7000;
	runtime=0;

	resource_skid=manager->getImg("media/skid01.png");
	//resource_skid=manager->getImg("media/car.png");
}