Exemple #1
0
//Update functions
void World::updateWorld() {
	//Check if player is dead
	b2Vec2 playerPos = playerBody->GetPosition();
	playerPos *= M2P;
	int circleRadius = 34;

	if (playerPos.x - circleRadius < DEATH_WALL_SPACE) {
		lost = true;
	}

	//If not game over
	if (!lost) {
		//Update platforms
		updatePlatforms();

		//Update charcter
		updateChar();

		//Clean old walls
		cleanWalls();

		//Clean old particles
		cleanParticles();
	}
}
Exemple #2
0
void World::update(float deltaTime, float accelX)
{
	updateBob(deltaTime, accelX);
	updatePlatforms(deltaTime);
	updateSquirrels(deltaTime);
	updateCoins(deltaTime);
	if(bob.state != Bob::BOB_STATE_HIT) 
		checkCollisions();
	checkGameOver();
}
Exemple #3
0
   void PlayScene::update(Engine& ctx)
   {
      if(m_status == Playing)
      {
         if(m_player -> reachedExit())
         {
            endGame(ctx);
            m_status = Playing;
            ctx.setScene("end");
            return;
         }

         m_player -> update(ctx);

         if(m_player -> x() - m_threat -> x() > 512)
         {
            m_threat -> setX(m_player -> x() - 512);
         }
         m_threat -> update(ctx);
         m_threat->setY(m_player->y()); // Just to make sure it can always hit the player
         
         updateCamera(ctx);   
         m_player->setMinX(m_cam -> x()); // Player can't walk past the left edge of the screen

         // The youngling eater follows the camera. If any younglings go off-screen, they'll get omnomnommed.
         m_eater->setX(m_cam -> x());
         m_eater->setY(m_cam -> y());

         // Update objects on platforms
         updatePlatforms(ctx);
         
         // Do collision detection
         detectCollisions(ctx);

         // Game over if the player has lost all the lifes
         if(m_player -> lives() <= 0)
            die("THE MEANIES GOT YOU!", true);
      }
      if(m_status == GameEnding && !m_gameOverSound -> isPlaying())
      {
         endGame(ctx);
      }
   } 
Exemple #4
0
static inline void render1(void)
{
	scanKeys();
	
	// cpuEndSlice();
	playerControls(NULL);
	updateControls();
	// iprintf("controls : %d  \n",cpuEndSlice());
	
		updatePlayer(NULL);
	// iprintf("player : %d  \n",cpuEndSlice());
	
		updatePortals();
		updateTurrets();
		updateBigButtons();
		updateTimedButtons();
		updateEnergyDevices();
		updateEnergyBalls();
		updatePlatforms();
		updateCubeDispensers();
		updateEmancipators();
		updateEmancipationGrids();
		updateDoors();
		updateWallDoors();
	// iprintf("updates : %d  \n",cpuEndSlice());
	
	// if(currentPortal)GFX_CLEAR_COLOR=currentPortal->color|(31<<16);
	// else GFX_CLEAR_COLOR=0;
	u16 color=getCurrentPortalColor(getPlayer()->object->position);
	// NOGBA("col %d",color);
	// GFX_CLEAR_COLOR=color|(31<<16);
	GFX_CLEAR_COLOR=RGB15(0,0,0)|(31<<16);
	
	#ifdef DEBUG_GAME
		if(fifoCheckValue32(FIFO_USER_08))iprintf("\x1b[0J");
		while(fifoCheckValue32(FIFO_USER_08)){int32 cnt=fifoGetValue32(FIFO_USER_08);iprintf("ALERT %d      \n",cnt);NOGBA("ALERT %d      \n",cnt);}
	#else
		while(fifoCheckValue32(FIFO_USER_08)){int32 cnt=fifoGetValue32(FIFO_USER_08);NOGBA("ALERT %d      \n",cnt);}
	#endif
	
	projectCamera(NULL);

	glPushMatrix();
		
		glScalef32(SCALEFACT,SCALEFACT,SCALEFACT);
		
		renderGun(NULL);
		
		transformCamera(NULL);
		
		cpuEndSlice();
			// drawRoomsGame(128, color);
			drawRoomsGame(0, color);
			// drawCell(getCurrentCell(getPlayer()->currentRoom,getPlayerCamera()->position));
		// iprintf("room : %d  \n",cpuEndSlice());
		
		updateParticles();
		drawParticles();
		// iprintf("particles : %d  \n",cpuEndSlice());
		
			drawOBBs();
		// iprintf("OBBs : %d  \n",cpuEndSlice());
			drawBigButtons();
			drawTimedButtons();
			drawEnergyDevices();
			drawEnergyBalls();
			drawPlatforms();
			drawCubeDispensers();
			drawTurretsStuff();
			drawEmancipators();
			drawEmancipationGrids();
			drawDoors();
			drawWallDoors(NULL);
			drawSludge(&gameRoom);
		// iprintf("stuff : %d  \n",cpuEndSlice());
		
		drawPortal(&portal1);
		drawPortal(&portal2);
			
	glPopMatrix(1);

	//HUD TEST
	if(levelInfoCounter>0 && (levelTitle || levelAuthor))
	{
		levelInfoCounter--;
		glMatrixMode(GL_PROJECTION);
		glPushMatrix();
			glLoadIdentity();
			glOrthof32(inttof32(0), inttof32(255), inttof32(191), inttof32(0), -inttof32(1), inttof32(1));
			
			glMatrixMode(GL_MODELVIEW);
			glPushMatrix();
				glLoadIdentity();

				if(levelTitle)drawCenteredString(levelTitle, inttof32(17)/10, (82));
				if(levelAuthor)drawCenteredString(levelAuthor, inttof32(1), (100));

			glPopMatrix(1);
			glMatrixMode(GL_PROJECTION);
		glPopMatrix(1);
	}
	
	glFlush(0);
}