//
// Init GL
//
int InitGL(GLvoid)					// All Setup For OpenGL Goes Here
{
    // seed rand generator
    srand((unsigned int)time(NULL));

    // Load the key codes --
    LoadKeyCodes();

    // enable all the goodies
    Super_LoadGlobals();

    Load_ConfigFile();
    Super_FireAnts();

    Create_Col_List();
    Create_Wall_List();


    //
    // loading sound library
    printf("Loading sound library, make sure 'music apps' are closed\n");
    Load_Audio();


    glShadeModel(GL_SMOOTH);					// Enable Smooth Shading
    glClearColor(0.0f, 0.0f, 0.0f, 0.0f);				// Black Background
    glClearDepth(1.0f);						// Depth Buffer Setup


    glEnable(GL_NORMALIZE);
    glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);

    glShadeModel(GL_SMOOTH);


    glEnable(GL_DEPTH_TEST);				// Enables Depth Testing
    glDepthFunc(GL_LEQUAL);					// The Type Of Depth Testing To Do
    glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);	// Really Nice Perspective Calculations


    // have to load the quadrice to be used
    quadric=gluNewQuadric();			// Create A Pointer To The Quadric Object (NEW)
    gluQuadricNormals(quadric, GLU_SMOOTH);		// Create Smooth Normals (NEW)
    gluQuadricTexture(quadric, GL_TRUE);		// Create Texture Coords (NEW)


    GenerateFireAnts();

    CreateWorld();

    LoadCameras();

    // Load the objects
    InitObjects();
    GenerateLights();

    InitGlobals();

    Build_ParticleSet();
    Reset_FontID();

    // Load the title screen text
    Load_Titles();

    // load the text library
    Super_MainText();

    CreateWalls();

    //
    // Load the collsion test for the walll
    //

    // front wall
    InsertColSegment(world_ptr->x_min, world_ptr->y_max,
                     world_ptr->x_max, world_ptr->y_max);

    // right wall
    InsertColSegment(world_ptr->x_max, world_ptr->y_min,
                     world_ptr->x_max, world_ptr->y_max);

    // back wall
    InsertColSegment(world_ptr->x_min, world_ptr->y_min,
                     world_ptr->x_max, world_ptr->y_min);

    // left wall
    InsertColSegment(world_ptr->x_min, world_ptr->y_min,
                     world_ptr->x_min, world_ptr->y_max);

    //
    // for the network save
    // the number of bots incase it is changed
    MAX_SAVED_BOTS = MAX_FIRE_ANTS;


    // end of insertion

    Super_InitNetwork();

    //
    // begin in paused mode
    //
    Super_BeginPaused();

    mSuper_Loaded = LOADED_TRUE;


    return true;			// Initialization Went OK

} // end of the function
// Creates a physics world and lays outt he
void LiquidFunScene::LayoutLevel(int level) {
  // Scale the dimensions of the world to fit the view.
  const CCSize viewSize = CCDirector::sharedDirector()->getVisibleSize();
  const float aspectRatio = viewSize.width / viewSize.height;
  m_worldExtents.x = k_worldWidth;
  m_worldExtents.y = k_worldWidth / aspectRatio;
  m_worldExtentMin = b2Vec2Min(m_worldExtents);
  m_worldExtentMax = b2Vec2Max(m_worldExtents);
  m_worldExtentsInWalls = m_worldExtents;
  m_worldOffsetInWalls.Set(0.0f, 0.0f);

  // Create a world.
  m_world = new b2World(k_gravity);
  m_world->SetParticleRadius(m_worldExtentMin * k_particleSize);
  m_world->SetParticleDamping(0.2f);

  // Enable the Box2D rendering layer.
  Box2DGLESDebugDrawLayer* box2dLayer = new Box2DGLESDebugDrawLayer(
    m_world, b2Vec2Min(b2Vec2(viewSize.width / m_worldExtents.x,
                              viewSize.height / m_worldExtents.y)));
  box2dLayer->init();
  addChild(box2dLayer);
  GLESDebugDraw* const debugDraw = box2dLayer->GetGLESDebugDraw();
  // Turn off AABB drawing.
  debugDraw->SetFlags(debugDraw->GetFlags() & ~b2Draw::e_aabbBit);
  // Render particles as solid circles.
  debugDraw->SetSolidParticlesEnable(true);

  // Create boundaries
  CreateWalls();
  CreateBalls(5, 0.075f);
  CreateBlockOfParticles();

  // Define map-specific stuff
  switch (level) {
    case 0: {
      // Add an emitter in the middle
      static const float k_colorCycleRate = 5.0f;
      std::vector<b2ParticleColor> colors;
      colors.push_back(b2ParticleColor(0xff, 0x00, 0x00, 0xff));
      colors.push_back(b2ParticleColor(0xff, 0xff, 0xff, 0xff));
      colors.push_back(b2ParticleColor(0x00, 0x00, 0xff, 0xff));
      colors.push_back(b2ParticleColor(0x00, 0xff, 0x00, 0xff));
      colors.push_back(b2ParticleColor(0x22, 0xff, 0x44, 0xff));
      AddEmitter(ConvertRelativePositionToWorld(b2Vec2(0.5f, 0.1f)),
                 colors, k_colorCycleRate);

      // Add a kill field to the bottom right of the screen.
      b2CircleShape circle;
      circle.m_radius = m_worldExtentMax * 0.025f;
      b2Transform circleLocationSize;
      circleLocationSize.SetIdentity();
      circleLocationSize.Set(ConvertRelativePositionToWorld(
          b2Vec2(0.8f, 0.9f)), 0.0f);
      AddParticleKillField(circleLocationSize, circle, sizeof(circle));
      break;
    }
    default:
      CCLOG("ERROR: Invalid level %d defined.", level);
      break;
  }
}
Beispiel #3
0
	Environment::Environment(ID3D10Device* device, Model::Level level)
		: mDevice(device), mBuffer(NULL), mEffect(NULL), mWallObject(device, "wallSegment.obj")
	{
		CreateGround(level.GetWidth(), level.GetHeight());
		CreateWalls(level);
	}
Beispiel #4
0
void Level::Generate(int w, int h, int numRooms) {
	m_width = w;
	m_height = h;
	m_grid = new GridSquare**[m_width];
	for(int x = 0; x < m_width; x++) {
		m_grid[x] = new GridSquare*[m_height];
		for(int y = 0; y < m_height; y++) {
			m_grid[x][y] = new GridSquare();
			m_grid[x][y]->type = ST_VOID;
			m_grid[x][y]->entity = NULL;
			m_grid[x][y]->debugFlag = false;
			m_grid[x][y]->hasBeenSeen = false;
			m_grid[x][y]->inView = false;
		}
	}

	// Create the initial boxes
	Room** rooms = GenerateInitialRooms(numRooms);

	// Merge the boxes into compound rooms
	CompoundRoomVector* crs = MergeBasicRooms(numRooms, rooms);

	// clean up the inital boxes
	for(int i = 0; i < numRooms; i++) {
		delete rooms[i];
	}
	delete [] rooms;

	// Plot the compound rooms
	for(unsigned int i = 0; i < crs->size(); i++) {
		CompoundRoom* cr = (*crs)[i];
		cr->GenerateItems();
		cr->GenerateMonsters();
		for(int x = cr->GetX(); x < cr->GetX() + cr->GetWidth(); x++) {
			for(int y = cr->GetY(); y < cr->GetY() + cr->GetHeight(); y++) {
				if(cr->IsFilled(x, y)) {
					m_grid[x][y]->type = ST_EMPTY;
					if(cr->EntityAt(x, y)) {
						m_grid[x][y]->entity = cr->EntityAt(x, y);
						m_entities.push_back(cr->EntityAt(x, y));
					}
				}
			}
		}
	}

	// If we've got more than one room, make cooridors
	m_numRooms = crs->size();
	if(crs->size() > 1) {
		for(unsigned int i = 0; i < crs->size() - 1; i++) {
			CompoundRoom* first = (*crs)[i];
			CompoundRoom* second = (*crs)[i+1];
			CreateCooridor(first, second);
		}
	}

	// Plot the walls around the rooms and cooridors
	CreateWalls();

	// Create the basic openings in the level
	CompoundRoom* first = crs->front();
	CompoundRoom* last = crs->back();
	CreateExits(first, last);
}
//
// Init GL
//
int InitGL(GLvoid)										// All Setup For OpenGL Goes Here
{
	// seed rand generator
	srand(getclock());

#if 0
	QueryPerformanceFrequency(&timerFrequency);
	QueryPerformanceCounter(&lastTime);
#endif

	// use the mouse only
	// for camera movement
	// disable the cursor 
	ShowCursor(FALSE);

	Super_LoadGlobals();

	Load_ConfigFile();

	// Now load main variables
	Super_LoadBots();	
	Super_FireAnts();
	
	Create_Col_List();

	Create_Wall_List();

	// enable all the goodies
	//glEnable(GL_TEXTURE_2D);		   // enable texture mapping
	
	glShadeModel(GL_SMOOTH);							// Enable Smooth Shading
	glClearColor(0.0f, 0.0f, 0.0f, 0.5f);				// Black Background
	glClearDepth(1.0f);									// Depth Buffer Setup


	glEnable(GL_NORMALIZE);
	glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);

	glShadeModel(GL_SMOOTH);


	glEnable(GL_DEPTH_TEST);							// Enables Depth Testing
	glDepthFunc(GL_LEQUAL);								// The Type Of Depth Testing To Do
	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);	// Really Nice Perspective Calculations


	// have to load the quadrice to be used
	quadric=gluNewQuadric();							// Create A Pointer To The Quadric Object (Return 0 If No Memory) (NEW)
	gluQuadricNormals(quadric, GLU_SMOOTH);			// Create Smooth Normals (NEW)
	gluQuadricTexture(quadric, GL_TRUE);				// Create Texture Coords (NEW)


#if ENABLE_LIGHTS
//	InitMaterial();
#endif


	GenerateBots();

	GenerateFireAnts();			// a new breed of warrior

	CreateWorld();

	LoadCameras();

	BuildFont();										// Build The Font

	// Load the objects
	InitObjects();

	GenerateLights();

	InitGlobals();		// for printing data, etc

	// generate the nest objects
	nest.generate();
	garden.generate();

	trail_set.generate();

	// give the ant food
	InitFood();

	Build_ParticleSet();

	Reset_FontID();


	// load the title screen text
	Load_Titles();

	// the text library
	Super_MainText();

	CreateWalls();

	//
	// Load the collision test for the wall
	// very easy test
	// 4 different walls
	//

	// front wall
	InsertColSegment(world_ptr->x_min, world_ptr->y_max, 
		world_ptr->x_max, world_ptr->y_max);

	// right wall
	InsertColSegment(world_ptr->x_max, world_ptr->y_min, 
		world_ptr->x_max, world_ptr->y_max);

	// back wall (top)
	InsertColSegment(world_ptr->x_min, world_ptr->y_min, 
		world_ptr->x_max, world_ptr->y_min);

	// left wall 
	InsertColSegment(world_ptr->x_min, world_ptr->y_min, 
		world_ptr->x_min, world_ptr->y_max);

	// end insertion --


	//
	// The first thing to do is begin in paused mode
	//
	Super_BeginPaused();



	mSuper_Loaded  = LOADED_TRUE;

	return TRUE;			// Initialization Went OK

} // end of the function