Example #1
0
void TileOverlay::build( CityPtr city, const TilePos& pos )
{
  Tilemap &tilemap = city->getTilemap();

  _d->city = city;
  _d->masterTile = &tilemap.at( pos );

  for (int dj = 0; dj < _d->size.getWidth(); ++dj)
  {
    for (int di = 0; di < _d->size.getHeight(); ++di)
    {
      Tile& tile = tilemap.at( pos + TilePos( di, dj ) );
      tile.setMasterTile( _d->masterTile );
      tile.setPicture( &_d->picture );

      if( tile.getOverlay().isValid() && tile.getOverlay() != this )
      {
        tile.getOverlay()->deleteLater();
      }

      tile.setOverlay( this );
      initTerrain( tile );
    }
  }
}
Example #2
0
void Init(){

	glClearColor(0.5, 0.5, 0.5, 1);
	glClearDepth(1);
	glEnable(GL_DEPTH_TEST);

	for (size_t i = 0; i < 256; i++)
	{
		vecSpecialKeyPressed[i] = false;
		vecKeyPressed[i] = false;
	}

	initShaders();

	initTextures();

	initMouseMovements();

	initVectors();

	initCubeMap();

	initTerrain();

	initVegetation();

	glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);

	GLint MaxPatchVertices = 0;
	glGetIntegerv(GL_MAX_PATCH_VERTICES, &MaxPatchVertices);
	printf("Max supported patch vertices %d\n", MaxPatchVertices);
}
TerrainEditTool::TerrainEditTool(EditScene *editScene, QObject *parent)
    : EditTool(editScene, parent),
      _item(0)
{
    QAction *newPolygonAction = new QAction(this);
    newPolygonAction->setText(tr("New Polygon"));
    connect(newPolygonAction, SIGNAL(triggered()), this, SLOT(startNewPolygon()));
    _actions.append(newPolygonAction);
    initTerrain(editScene->getLevel()->getTerrain());
}
Example #4
0
 Terrain(const std::string &name, int sizeX, int sizeY, int factor, float smoothFactor = 1.f, int seed = 3):
   Geode(name, true, false),
 _sizeX(sizeX),
 _sizeY(sizeY),
   _smoothFactor(smoothFactor),
   _seed(seed),
   _factor(factor)
 {
   _nbVertex = (int)pow(2, factor) + 1;
   _randMod = _nbVertex * 10000;
   initTerrain();
   initBuffers();
 }
Example #5
0
	//## Initalization ##
	void Terrain::init()
	{
		glClearColor(0.0f, 1.0f, 0.0f, 0.0f);		// clear to black

		glShadeModel(GL_SMOOTH);					   // use smooth shading
		glEnable(GL_DEPTH_TEST);					   // hidden surface removal
		glEnable(GL_CULL_FACE);						   // do not calculate inside of poly's
		glFrontFace(GL_CCW);						      // counter clock-wise polygons are out

		glEnable(GL_TEXTURE_2D);					   // enable 2D texturing

		imageData = loadBitmapFile("Terrain2.bmp", &bitmapInfoHeader); //Loads the source height map from which the terrain is generated

		//## Initialize the cubes
		//TODO: Modify cube constructor, moving these up to constructor
		startCube->setSize(MAP_SCALE*1.5);
		startCube->setColor(1.0f, 0.0f, 0.0f);
		startCube->setText("Start");

		roiCube->setSize(MAP_SCALE*1.5);
		roiCube->setColor(1.0f, 0.0f, 1.0f);

		poiCube->setSize(MAP_SCALE*1.5);
		poiCube->setColor(1.0f, 1.0f, 0.0f);

		endCube->setSize(MAP_SCALE*1.5);
		endCube->setColor(0.0f, 0.0f, 1.0f);
		endCube->setText("End");

		fingerCube->setSize(MAP_SCALE* 1.5f);
		fingerCube->setColor(1.0f, 1.0f, 0.0f);

		lightingCube->setSize(MAP_SCALE*1.5f);
		lightingCube->setColor(1.0f, 1.0f, 1.0f);

		// initialize the terrain data, load the textures, and set up clipping planes
		initTerrain();
		loadTextures();
		initClipPlanes();
	}
void PTGScene::init()
{
	for (int i = 0; i < 255; i++)
		keys[i] = false;
	mb.lb = 0;
	mb.rb = 0;

	pEng->init();
	initCams();
	initMaterias();
	initTerrain();
	initSky();
	initTrees();
	initBots();
	
	INITBATMOBILE(); //!!!!!!!!!!! OLOLOL
	
	pPlayer = new PTGPlayer(this);

	dt = timeGetTime();
	tt = dt;

}
Example #7
0
int main(int argc, char**argv)
{
	srand(0);
	
	glutInit(&argc,argv);
	
	glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGBA|GLUT_DEPTH);
	glutInitWindowSize(500,500);
	glutInitWindowPosition(100,100);
	glutCreateWindow("Terrain");
	
	 //Initialize GLEW 
	GLenum glewError = glewInit(); 
	if( glewError != GLEW_OK ) 
	{ 
		printf( "Error initializing GLEW! %s\n", glewGetErrorString( glewError ) ); 
		while (1);
	}
	if (!GL_EXT_framebuffer_object )
	{
		printf("Framebuffer not implimented\n");
		while(1);
	}


	glEnable(GL_DEPTH_TEST);
	glDepthFunc(GL_LESS);

	glEnable ( GL_COLOR_MATERIAL ) ;
	glEnable( GL_TEXTURE_2D );
	glEnable( GL_BLEND );
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	
    glAlphaFunc ( GL_GREATER, (GLclampf)0.1 ) ;
    glEnable ( GL_ALPHA_TEST ) ;
	
	glShadeModel(GL_SMOOTH);

	glutDisplayFunc(display);
	glutIdleFunc(display);
	glutReshapeFunc(reshape);
	glutKeyboardFunc(keyPressed);
	glutKeyboardUpFunc(keyUp);

	initTerrain();

	camera = new CCamera();
	camera->SetX(WORLD_SIZE/2.0);
	camera->SetZ(WORLD_SIZE/2.0);
	//camera->SetY(800);
	//camera->RotateY(-90);
	//camera->RotateX(-90);
	for (int i = 0;i<256;i++)
		keyStates[i] = false;
	
	Island = new World(WORLD_SIZE);

	glFogi(GL_FOG_MODE,GL_LINEAR);
	glFogfv(GL_FOG_COLOR,skyColor);
	glFogf(GL_FOG_DENSITY,0.05f);
	glHint(GL_FOG_HINT, GL_DONT_CARE);          // Fog Hint Value
	glFogf(GL_FOG_START, 300.f);             // Fog Start Depth
	glFogf(GL_FOG_END, 500.0f); 

	glEnable(GL_FOG); 
	glutMainLoop();
}
Example #8
0
int main()
{
	arr = (unsigned int**)malloc(4377 * sizeof(unsigned int));
	psController ps;
	int velocity = 0;
	int angle = 0;
	long ii = 0;
	int** collisionMatrix;
	int ee;
	int numfiles;
	char * filenames[MAXFILES];

	//init_VGA_Pixel();
	initVGA(); //pixel
	init_VGA_Char();
	av_config_setup();
	numfiles = init_sd(filenames);
	init_wav(arr);
	printf("timing audio\n");
	//time_of_sound = time_audio(arr);
	printf("looping audio\n");

	audio_isr_k = 0;
	alt_irq_register(AUDIO_IRQ, NULL, &audio_isr);
	alt_up_audio_enable_write_interrupt(audio);


	//====INITIALIZE AND DRAW TERRAIN USING BMP ===========================//
		short int fd;

		terrain background;
		fd = alt_up_sd_card_fopen("bg.bmp", false);
		initTerrain(fd, &background);
		drawBackground(background);
		alt_up_sd_card_fclose(fd);


		terrain terrain;
		fd = alt_up_sd_card_fopen("tr.bmp", false);
		initTerrain(fd, &terrain);
		drawTerrain(terrain);
		alt_up_sd_card_fclose(fd);

	//====INITIALIZE AND DRAW USER TANK USING BMP ===========================//
		fd = alt_up_sd_card_fopen("tank.bmp", false);
		tank user;
		initUserTank(&user, fd);
		drawTank(&user, background);
		alt_up_sd_card_fclose(fd);
	//====INITIALIZE AND DRAW ENEMY TANK USING BMP ===========================//
		tank enemy;
		fd = alt_up_sd_card_fopen("tk.bmp", false);
		initEnemyTank1(&enemy, fd);
		drawTank(&enemy,background);
		alt_up_sd_card_fclose(fd);
	//====SWAP BUFFERS =======================================================//
		updateVGA();
		drawBackground(background);
		drawTerrain(terrain);
		drawTank(&enemy, background);
		for(ee=0;ee < 20;ee++)
		{
			moveTank(&user, RIGHT, 1);
			drawTank(&user,background);
			updateVGA();
			drawTank(&user,background);
			//delay();
		}
	//for(ii = 0; ii < 300000; ii++);

	collisionMatrix = init_CollisionMatrix(XMAXSCREEN_RESOLUTION + 1, XMAXSCREEN_RESOLUTION + 1);

	//alt_up_pixel_buffer_dma_draw_box(pixel_buffer, 0, 120, 340, 240, 0x7E0 , 0); //draw terrain

	set_CollisionAtRectArea(collisionMatrix, 0 , 0, 340, 240, EMPTY);
	set_CollisionAtRectArea(collisionMatrix, 0 , 161, 340, 240, TERRAIN_COLOR);//set the rectangular area drawn by terrain to filled with terrain
	while(1){
		//angle = 0;
		velocity = 0;
		set_UserTank(&angle, &velocity, ps, &user, &enemy, background); //reads controller to set angle, power, and shoot
		shoot_Missile(angle, velocity,( user.x + user.t_VGA.width) - 1 , (240 - user.y + user.t_VGA.height) - 7, collisionMatrix, background);

	}
	clean_audio(arr);
	return 0;
}
Example #9
0
 void setFactor(int f) {_factor = f; _nbVertex = (int)pow(2, f) + 1; initTerrain(); initBuffers();}
/**
 * Hier findet die komplette Initialisierung des kompletten SPIEeles statt.
 * Inklusive der Datenhaltung und des SPIEelfeldes.
 */
void initGame ()
{   
    initCameraPosition();
    initTerrain();
    initWater();
}