Beispiel #1
0
MyGame::MyGame()	{
	//Init variables
	ammo = 0;
	force = 0;
	waveno=0;
	
	cube	= new OBJMesh(MESHDIR"cube.obj");
	cube->SetTexture(SOIL_load_OGL_texture(
			TEXTUREDIR"Barren Reds.jpg", SOIL_LOAD_AUTO,
			SOIL_CREATE_NEW_ID, SOIL_FLAG_MIPMAPS));
	if(!cube->GetTexture()) {
		cout << "barren reds is playing up" << endl;
	}
	quad	= Mesh::GenerateQuad();


	enemy = new OBJMesh(MESHDIR"ico2.obj");
	enemy ->SetTexture(SOIL_load_OGL_texture(
			TEXTUREDIR"leo.png", SOIL_LOAD_AUTO,
			SOIL_CREATE_NEW_ID, SOIL_FLAG_MIPMAPS));
	if(!enemy->GetTexture()) {
		cout << "leopard skins f****d" << endl;
	}
	
	sphere	= new OBJMesh(MESHDIR"ico2.obj");
	sphere->SetTexture(SOIL_load_OGL_texture(
			TEXTUREDIR"swirl.tga", SOIL_LOAD_AUTO,
			SOIL_CREATE_NEW_ID, SOIL_FLAG_MIPMAPS));
	if(!sphere->GetTexture()) {
		cout << "swirl is BUM" << endl;
	}

	player  = new OBJMesh(MESHDIR"ico2.obj");
	player->SetTexture(SOIL_load_OGL_texture(
			TEXTUREDIR"cliff.jpg", SOIL_LOAD_AUTO,
			SOIL_CREATE_NEW_ID, SOIL_FLAG_MIPMAPS));
	if(!player->GetTexture()) {
		cout << "cliff is f****d" << endl;
	}
	
	CubeMap = SOIL_load_OGL_cubemap(
		TEXTUREDIR"interstellar_ft.tga", TEXTUREDIR"interstellar_bk.tga",
		TEXTUREDIR"interstellar_up.tga", TEXTUREDIR"interstellar_dn.tga",
		TEXTUREDIR"interstellar_rt.tga", TEXTUREDIR"interstellar_lf.tga", 
		SOIL_LOAD_RGB,
		SOIL_CREATE_NEW_ID,0);
	enemy->SetCubeMap(CubeMap);
	if(!CubeMap)
		cout << "cube maps f*****g broken";
	

	bumpShader = new Shader(SHADERDIR"bumpVertex.glsl",SHADERDIR"bumpFragment.glsl");
	if(!bumpShader->LinkProgram()) {
		return;
	}

	
	enemyShader = new Shader(SHADERDIR"perPixelVertex.glsl",SHADERDIR"enemyFragment.glsl");
	if(!enemyShader->LinkProgram()) {
		return;
	}

	heightmap = new HeightMap(TEXTUREDIR"stage1.raw");
	heightmap->SetTexture(SOIL_load_OGL_texture(
			TEXTUREDIR"grass.jpg", SOIL_LOAD_AUTO,
			SOIL_CREATE_NEW_ID, SOIL_FLAG_MIPMAPS));
	heightmap->SetBumpMap(SOIL_load_OGL_texture(
			TEXTUREDIR"grassbump.jpg", SOIL_LOAD_AUTO,
			SOIL_CREATE_NEW_ID, SOIL_FLAG_MIPMAPS));
	SetTextureRepeating(heightmap->GetBumpMap(),true);

	if(!heightmap->GetTexture()){
		cout << "height maps f*****g broken" << endl;
	}

	if(!heightmap->GetBumpMap()) {	
		cout << "height map bump map f*****g broken" << endl;
	}

	for(int i = 0; i < NO_PROJECTILES; ++i) {
		projectiles[i] = BuildSphereEntity(25.0f);
		projectiles[i]->GetPhysicsNode().SetPosition(Vector3((51.0f* i) + 100.0f,500.0f,30.0f * i));
		projectiles[i]->GetPhysicsNode().sleep = true;
	}

	for(int i = 0; i < NO_LASERS; ++i) {
		PhysicsSystem::GetPhysicsSystem().AddLaser(buildLaserEntity());

	}
	
	PlanePos = Vector3(2048.0f,100.0f,2048.0f); // y = 450.0f
	playerEntity = buildPlayerEntity();
	PhysicsSystem::GetPhysicsSystem().SetPlayer(playerEntity);
	allEntities.push_back(playerEntity);
	allEntities.push_back(BuildHeightmapEntity());
	
	for(int i = 0; i < NO_PROJECTILES; ++i) {
		allEntities.push_back(projectiles[i]);
	}

	for(int i = 0; i < 10; ++i) {
		EnemyEntity* ee = buildEnemyEntity(Vector3(PlanePos.x + 150,PlanePos.y + 150, PlanePos.z + (i * 90) - 270));
		ee->SetY(100.0f + (100.0f * i));
		allEntities.push_back(ee);
		PhysicsSystem::GetPhysicsSystem().AddEnemy((ee));
	}


	
	//gameCamera = new Camera(-2.0f,270.0f,Vector3(-360.0f,450.0f,3408.0f));
	//gameCamera = new TPCamera();
	gameCamera = new CameraMan(playerEntity->circleT);
	gameCamera->toggleLock();
	Renderer::GetRenderer().SetCamera(gameCamera);

	ret = new Reticule(WIDTH,HEIGHT,FOV,ASPECT, gameCamera);
	//ret->c = gameCamera;
	Renderer::GetRenderer().SetReticule(ret);
	PhysicsSystem::GetPhysicsSystem().SetReticule(ret);

	//ret = new Reticule();
}