Ejemplo n.º 1
0
// initialize each object that will be shown on screen
void init()
{
	glutIgnoreKeyRepeat(1);

	glEnable(GL_LINE_STIPPLE);

	ball.init();

	player.init();
	ai.init();

	o1.init();
	o2.init();
}
Ejemplo n.º 2
0
void Map::createMap()
{
    //TODO : Add a quadrant system
    const int w = m_pSurface->w / World::ratio;
    const int h = m_pSurface->h / World::ratio;

    b2Vec2 oldPos(0.0f,0.f);
    const float minDis = 3;
    for(unsigned int i=0; i<16*5; i++)
    {
        bool foundPos = false;
        while(foundPos == false)
        {
            b2Vec2 pos(rand()%w, rand()%h);
            if(b2DistanceSquared(pos, oldPos) >= minDis)
            {
                foundPos = true;
                oldPos = pos;
            }
        }

        Obstacle * obs = new Obstacle(m_pWorld, oldPos);
        obs->init();

        m_Obstacles.push_back(obs);
    }

}
Ejemplo n.º 3
0
Obstacle* Obstacle::create(Obstacle::Type type)
{
    Obstacle *ret = new Obstacle();
    
    if (ret && ret->init(type))
    {
        ret->autorelease();
    }
    else
    {
        CC_SAFE_DELETE(ret);
    }
    return ret;
};
Ejemplo n.º 4
0
void ColoredCubeApp::initApp()
{
	D3DApp::initApp();
	
	audio->playCue(MAIN_TRACK);

	srand(time(0));

	left = Vector3(1,0,0);
	right = Vector3(-1,0,0);
	forward = Vector3(0,0,-1);
	back = Vector3(0,0,1);
	up = Vector3(0,1,0);
	down = Vector3(0,-1,0);
	zero = Vector3(0,0,0);
	
	whiteBox.init(md3dDevice, 1.0f, WHITE);
	redBox.init(md3dDevice, 1.0f, RED);
	blueBox.init(md3dDevice, 1.0f, BLUE);
	greenBox.init(md3dDevice, 1.0f, GREEN);
	crimBox.init(md3dDevice, 0.8f, CRIMSON);
	dRedBox.init(md3dDevice, 0.8f, DARKRED);
	dBlueBox.init(md3dDevice, 0.25f, DARKBLUE);

	line.init(md3dDevice, 10.0f, GREEN);

	////// New Stuff added by Steve //////
	gLine.init(md3dDevice, 10.0f, GREEN);
	rLine.init(md3dDevice, 10.0f, RED);
	bLine.init(md3dDevice, 10.0f, BLUE);
	xLine.init(&rLine, Vector3(0,0,0), 10);
	xLine.setPosition(Vector3(0,0,0));
	yLine.init(&gLine, Vector3(0,0,0), 10);
	yLine.setPosition(Vector3(0,0,0));
	yLine.setRotationZ(ToRadian(90));
	zLine.init(&bLine, Vector3(0,0,0), 10);
	zLine.setPosition(Vector3(0,0,0));
	zLine.setRotationY(ToRadian(90));
	numberOfObstacles = 50;
	float obstacleScale = 2.5f;
	float playerScale = 2.67f;
	Vector3 oScale(obstacleScale, obstacleScale, obstacleScale);
	Vector3 pScale(playerScale, playerScale, playerScale);
	playerBox.init(md3dDevice, playerScale, WHITE);
	player.init(&playerBox, sqrt(playerScale * 2.0f), Vector3(0, 2, 0), Vector3(0, 0, 0), 10, pScale, audio);
	player.linkInput(input);

	int posZ = 0;
	int posX = 0;
	int chance = 0;
	int r = 0;
	float floorSpeed = floor.getSpeed();
	for (int i=0; i<numberOfObstacles; ++i)
	{	
		Box* box = new Box();
		box->init(md3dDevice, obstacleScale, GREEN);
		obstacleBoxes.push_back(box);
		Obstacle o;
		o.init(box, sqrt(5.0f), Vector3(0,0,200), Vector3(0,0,-1), 0, Vector3(oScale));
		o.setInActive();
		obstacles.push_back(o);
	}
	///Set obstacle cluster variables
	clusterSize = 1;
	clusterSizeVariation = 3;
	clusterSeparation = 100;
	cubeSeparation = 30;
	lineJiggle = 3;
	cubeJiggle = 3;
	clusterJiggle = 10;
	floorMovement = 0.0f;

	//Other floor variables
	floorClusterCounter = 0;
	floorClusterThreshold = 7;
	floorSpeedIncrease = 5;

	//New spectrum HUD by Andy
	specHudBox[0].init(md3dDevice, .5f, 1.0f, 1.0f, RED, YELLOW);
	specHudBox[1].init(md3dDevice, .5f, 1.0f, 1.0f, YELLOW, GREEN);
	specHudBox[2].init(md3dDevice, .5f, 1.0f, 1.0f, GREEN, CYAN);
	specHudBox[3].init(md3dDevice, .5f, 1.0f, 1.0f, CYAN, BLUE);
	specHudBox[4].init(md3dDevice, .5f, 1.0f, 1.0f, BLUE, MAGENTA);
	specHudBox[5].init(md3dDevice, .5f, 1.0f, 1.0f, MAGENTA, RED);
	cursorBox.init(md3dDevice, .15f, 1.0f, .75f, BLACK, BLACK);

	Vector3 specPos = Vector3(11.0f, 25.0f, -5.0f);
	spectrum[0].init(&specHudBox[0], 1.0f,specPos + Vector3(0.0f,0.0f,0.0f), Vector3(0.0f,0.0f,0.0f), 0, Vector3(0.0f,0.0f,0.0f));
	spectrum[1].init(&specHudBox[1], 1.0f,specPos + Vector3(2.0f,0.0f,0.0f), Vector3(0.0f,0.0f,0.0f), 0, Vector3(0.0f,0.0f,0.0f));
	spectrum[2].init(&specHudBox[2], 1.0f,specPos + Vector3(4.0f,0.0f,0.0f), Vector3(0.0f,0.0f,0.0f), 0, Vector3(0.0f,0.0f,0.0f));
	spectrum[3].init(&specHudBox[3], 1.0f,specPos + Vector3(6.0f,0.0f,0.0f), Vector3(0.0f,0.0f,0.0f), 0, Vector3(0.0f,0.0f,0.0f));
	spectrum[4].init(&specHudBox[4], 1.0f,specPos + Vector3(8.0f,0.0f,0.0f), Vector3(0.0f,0.0f,0.0f), 0, Vector3(0.0f,0.0f,0.0f));
	spectrum[5].init(&specHudBox[5], 1.0f,specPos + Vector3(10.0f,0.0f,0.0f), Vector3(0.0f,0.0f,0.0f), 0, Vector3(0.0f,0.0f,0.0f));
	cursor.init(&cursorBox,1.0f,specPos + Vector3(-.80f, -1.0f, 0.0f), Vector3(0.0f,0.0f,0.0f), 0, Vector3(0.0f,0.0f,0.0f));


	gameObject1.init(&whiteBox, sqrt(2.0f), Vector3(-10,0,0), Vector3(0,0,0), 0,Vector3(2,2,2));
	gameObject2.init(&redBox, sqrt(2.0f), Vector3(4,0,0), Vector3(0,0,0), 0,Vector3(2,2,2));
	gameObject3.init(&redBox, sqrt(2.0f), Vector3(-4,0,0), Vector3(0,0,0), 0,Vector3(2,2,2));

	floor.init(md3dDevice);

	gameOver = false;
	activeMessage = false;
	messageTimer = 0.0f;

	//init lights - using pointlights
	lightType = 1;
	numberOfLights = 1;
	for (int i=0; i<numberOfLights; ++i)
	{
		Light l;
		l.pos = Vector3(0, 50, -17);
		l.ambient = Color(0.67f, 0.67f, 0.67f);
		l.diffuse = Color(1.0f, 1.0f, 1.0f);
		l.specular = Color(1.0f, 1.0f, 1.0f);
		l.att.x = 1.5f;
		l.att.y = 0.0f;
		l.att.z = 0.0f;
		l.range = 97.0f;
		lights.push_back(l);
	}


	buildFX();
	buildVertexLayouts();

}