Exemplo n.º 1
0
void advanceLevel(){
        if ((currentTime-previousTime)>2000) {
        //explosives.generateExplosion(0, 45, 0, 0, 0, 0);
        previousTime = currentTime;
        ComputerPlane newFriend;
        newFriend.x = (rand()%400)-200;
        newFriend.y = (rand()%20)+75;
        newFriend.z = (rand()%400)-200;
        newFriend.manuverability=2.2;
        newFriend.explosives = &explosives;
        

        ComputerPlane newEnemy;
        //newEnemy.x = (rand()%400)-200;
        //newEnemy.y = (rand()%20)+45;
        //newEnemy.z = (rand()%400)-200;
        int g = (rand()%carriers.size());
        newEnemy.x = carriers[g].x;
        newEnemy.z = carriers[g].z+carriers[g].length/2.5;
        newEnemy.y = carriers[g].y+carriers[g].length/11;
        newEnemy.pitch = 0;
        newEnemy.planeYaw = 90;
        newEnemy.timer = 200;
        newEnemy.explosives = &explosives;
        //newEnemy.enemyPlane = &mainPlane;
        //newEnemy.huntEnemyPlane();
        //enemyPlanes.push_back(newEnemy);
        newEnemy.planeRed = 1;
        newFriend.planeBlue = 1;
        //Determine friends enemy
        int i;
        if (friendlyPlanes.size()<3||enemyPlanes.size()<3) {
            newEnemy.enemyPlane = &mainPlane;
            enemyPlanes.push_back(newEnemy);
            newFriend.enemyPlane = &newEnemy;
            friendlyPlanes.push_back(newFriend);
            friendlyPlanes[friendlyPlanes.size()-1].enemyPlane = &newEnemy;
            newFriend.huntEnemyPlane();
            advanceLevel();
        }else{
            i = rand()%(friendlyPlanes.size()-1);
            newEnemy.enemyPlane = &friendlyPlanes[i];
            if((rand()%5)>1){
                newEnemy.enemyPlane = &mainPlane;
            }
            i = rand()%(enemyPlanes.size()-1);
            newFriend.enemyPlane = &enemyPlanes[i];
            newFriend.huntEnemyPlane();
            newEnemy.huntEnemyPlane();
            enemyPlanes.push_back(newEnemy);
            if(rand()%5>3){
                friendlyPlanes.push_back(newFriend);
            }

        }
           }
    
}
Exemplo n.º 2
0
void ColumnsGame::reset()
{
	Pit.emptyPit();
	activeStone.start();
	iLevel=0;
	advanceLevel();
	iOldGameState=iGameState=COLUMNS_STONE_MOVE;
	iPoints=0;
	iAddPoints=0;
	iAddMultiplier=0;
	blnRunAdd=false;
}
Exemplo n.º 3
0
void BTPc::restoreLevel()
{
 BTJobList &jobList = BTGame::getGame()->getJobList();
 BTXpChartList &xpChartList = BTGame::getGame()->getXpChartList();
 if (jobList[job]->xpChart != -1)
 {
  if (level < maxLevel)
  {
   if (xp < xpChartList[jobList[job]->xpChart]->getXpNeeded(maxLevel))
    xp = xpChartList[jobList[job]->xpChart]->getXpNeeded(maxLevel);
   while (level < maxLevel)
    advanceLevel();
  }
 }
}
Exemplo n.º 4
0
void renderScene(void) {
    mainPlane.manageHealth();
    
    //GLfloat lightpos[] = {-x,-z,-y};
    //glTranslatef(lightpos[0], lightpos[1], lightpos[2]);
    glColor3f(1, 1, 1);
    //glutSolidSphere(30, 20, 20);
    //glTranslatef(-lightpos[0], -lightpos[1], -lightpos[2]);
    //glLightfv(GL_LIGHT0, GL_POSITION, lightpos);
	if (deltaMove)
		moveMeFlat(deltaMove);
	if (deltaAngle) {
		angle += deltaAngle;
		orientMe(angle);
        //rotateMe(angle);
	}
    if (rotationAngleDelta) {
        rotationAngle+=rotationAngleDelta;
        rotationAngleDelta=0;
        rotateMe(rotationAngle);
    }
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    // Draw ground
    glPushMatrix();
    //glLoadIdentity();
    //glTranslatef(x, y, z);
    //glRotatef(rotationAngle+90, 0, 1, 0);
    explosives.drawExplosions();
    //glTranslatef(-x, -y, -z);
    glPopMatrix();
	
    float minX=200000,maxX=0,minY=20000,maxY=0;
    glBegin(GL_QUADS);
    for (int i = 20; i <tiles.size()-20; i++) {
        for (int j = 20; j <tiles.size()-20; j++) {
            if(tiles[i][j].xMax>maxX) maxX = tiles[i][j].xMax;
            if(tiles[i][j].yMax>maxY) maxY = tiles[i][j].yMax;
            if(tiles[i][j].x<minX) minX = tiles[i][j].x;
            if(tiles[i][j].y<minY) minY = tiles[i][j].y;
            if (tiles[i][j].z>-.7) {
                tiles[i][j].drawTile();
            }
            
            
        }
    }
    drawWater(maxX*40,maxY*40,minX*40,minY*40);
	glEnd();
    
    drawTrees();
    drawBuildings();
    advanceLevel();
    drawPlane();
    
    
    //drawSilos();
    drawCarrierGroup();
    
    
    calculateFPS();
	glutSwapBuffers();
    //std::cout<<"hello";
    indexer++;
    if (loadBuildings) {
        loadBuildings = 0;
        cDetector.buildings = &buildings;
    }
    cDetector.detectCollisions();
    //glLoadIdentity();
    
    
}
Exemplo n.º 5
0
void drawPlane(){
    //Draw Enemy planes
    for (int i = 0; i<enemyPlanes.size(); i++) {
        if (enemyPlanes[i].y>0) {
            enemyPlanes[i].movePlane();
            enemyPlanes[i].drawPlane();
        }
        //enemyPlanes[i].movePlane();
        //enemyPlanes[i].drawPlane();
        //enemyPlanes[i].adjustAttitudeFacingPlane(mainPlane);
        if (!enemyPlanes[i].dead) {
            enemyPlanes[i].huntEnemyPlane();
        }
        enemyPlanes[i].drawBullets();
        if (enemyPlanes[i].enemyPlane->dead||enemyPlanes[i].enemyPlane==NULL) {
            if((rand()%10)>7){
                enemyPlanes[i].enemyPlane = &mainPlane;
                //mainPlane.dead= 0;
            }
            enemyPlanes[i].enemyPlane = &friendlyPlanes[(rand()%(friendlyPlanes.size()-1))];
        }
    }
    //Draw Friendly Planes
    for (int i = 1; i<friendlyPlanes.size(); i++) {
        if (friendlyPlanes[i].y>0) {
            friendlyPlanes[i].movePlane();
            friendlyPlanes[i].drawPlane();
        }else{
            friendlyPlanes.erase(friendlyPlanes.begin()+i);
            //continue;
        }
        //friendlyPlanes[i].adjustAttitudeFacingPlane(mainPlane);
        if (!friendlyPlanes[i].dead) {
            friendlyPlanes[i].huntEnemyPlane();
        }
        friendlyPlanes[i].drawBullets();
        if (friendlyPlanes[i].enemyPlane->dead||friendlyPlanes[i].enemyPlane==NULL) {
            if (enemyPlanes.size()<2) {
                advanceLevel();
            }else{
                friendlyPlanes[i].enemyPlane = &enemyPlanes[(rand()%(enemyPlanes.size()-1))];
            }
        }
    }
    //Chase View
    
    y = mainPlane.y+2;
    double planeYawRad = mainPlane.planeYaw*3.14159262/180;
    z = mainPlane.z+30*sin(planeYawRad);
    x = mainPlane.x-30*cos(planeYawRad);
    orientMe(1.57-planeYawRad);
    moveMeFlat(0);
    
    //Move and draw plane
    mainPlane.convertDesiredToActual();
    mainPlane.movePlane();
    mainPlane.drawPlane();
    //mainPlane.manageHealth();
    mainPlane.drawUserBullets(&enemyPlanes);
    
    
    
    
}
Exemplo n.º 6
0
int ColumnsGame::gameLogic()
{
// Here will be the Logic of the game: Stone Moving, and inserting into the Pit..
	int now=All2D_System::getTime();
	static int iReactionTime=0;		// How long to wait before next removing/searching..is at beginning 0, when gaps found it will be set to 500 ms
	static int iExplosionBrake=0;	// Timer for removing Gaps / Stones
	static int iCalculatedPoints=0;
	switch (iGameState)
	{
		case COLUMNS_REMOVE_JOKER:
		{
			if ((now-iExplosionBrake)>iReactionTime)
			{
				int iTmp=Pit.searchJoker();	// How many stones have to be removed?
				iCalculatedPoints+=(iTmp*10);
				iAddPoints+=(iTmp*10);	//damit man den Bonus auch schon hochzählen sieht...

				if (iTmp>0)						// if there are some stones, remove Gaps in next loop..
				{
					All2D_System::sound->playSample(SND_JOKER_MATCH);
					iAddMultiplier=0;
					iGameState=COLUMNS_REMOVE_GAP;
				} else
				{
					activeStone.start();		// neuer Stein..
					iGameState=COLUMNS_STONE_MOVE;
				}
				iExplosionBrake=now;
			}
		}
		break;
		case COLUMNS_REMOVE_STONE:
		{
			if ((now-iExplosionBrake)>iReactionTime)
			{
				int iTmp=Pit.searchSolution();	// How many stones have to be removed?
				iCalculatedPoints+=(iTmp*10);
				iAddPoints+=(iTmp*10);	//damit man den Bonus auch schon hochzählen sieht...

				if (iTmp>0)
				{						// if there are some stones, remove Gaps in next loop..
					static int iMatchSound=0;
					if (++iMatchSound>6) iMatchSound=0;
					switch (iMatchSound) {
						case 1:
							All2D_System::sound->playSample(SND_STONE_MATCH_2);
							break;
						case 2:
							All2D_System::sound->playSample(SND_STONE_MATCH_3);
							break;
						case 3:
							All2D_System::sound->playSample(SND_STONE_MATCH_4);
							break;
						case 4:
							All2D_System::sound->playSample(SND_STONE_MATCH_5);
							break;
						case 5:
							All2D_System::sound->playSample(SND_STONE_MATCH_6);
							break;
						case 6:
							All2D_System::sound->playSample(SND_STONE_MATCH_7);
							break;
						default:
							All2D_System::sound->playSample(SND_STONE_MATCH);
							break;
					}
					Pit.setFlames(true);
					iGameState=COLUMNS_REMOVE_GAP;

				}else{							// Keine 3er Gruppen mehr gefunden....

					activeStone.start();		// neuer Stein..
					iGameState=COLUMNS_STONE_MOVE;

					iReactionTime=0;			// WarteZeit wieder auf 0

					iAddPoints+=(iAddMultiplier-1)*iCalculatedPoints;	// Bonus ausrechnen (einmal ist der Bonus ja schon oben addiert worden..

					iAddMultiplier=0;
					iCalculatedPoints=0;	// for next Stone
					if (iAddPoints>0)
						blnRunAdd=true;

					Pit.setFlames(false);
				}
				iExplosionBrake=now;
			} else {
				Pit.setFlames(false);
			}
			break;
		}
		case COLUMNS_REMOVE_GAP:
		{
			if ((now-iExplosionBrake)>COLUMNS_REACTIONTIME)		// Wait 500 ms
			{
				if (Pit.deleteSolution())
				{
					iAddMultiplier++;
					iGameState=COLUMNS_REMOVE_STONE;	// look in the Pit if there are more stones to find...
					iReactionTime=COLUMNS_REACTIONTIME;					// warteZeit auf 500 ms
				}
				iExplosionBrake=now;
				//All2D_System::sound->playSample(SND_REMOVE_GAP);
			}
			break;
		}
		case COLUMNS_STONE_MOVE:
		{
			long test=All2D_System::getTime();
			if (test>iLevelTime)
				advanceLevel();

			iGameState=activeStone.gameLogic(iLevel);
			if ( iGameState==COLUMNS_GAME_OVER ) {
				All2D_System::sound->playSample(SND_GAME_OVER);
				iPoints+=iAddPoints;
				iAddPoints=0;
			}
		}
	}
	if ( blnRunAdd && iCalculatedPoints%10 == 0)
		All2D_System::sound->playSample(SND_ADD_POINT);

	return iPoints;
}
Exemplo n.º 7
0
static void updatePlayerPosition(float lag)
{
    if(levelAdvanceFalling)
    {
        float interHeight = (float)(_BRICK_HEIGHT * (_INTER_ROW_COUNT));

        voff += _PLAYER_FALL_SPEED * lag;

        if(voff >= interHeight)
        {
            voff = 0.0;
            levelAdvanceFalling = false;
            vy = 0;
            level++;

            bcg_Cleanup(&bcg);
            bcg = bcgNext;
            bcg_Relativize(&bcg);

            if((level + 1) < _LEVEL_COUNT)
                bcgNext = bcg_Create(level_GetOffset(level + 1) - (float)_MAP_OFFSET_Y, level + 1);
        }

        return;
    }

    if(player->sclass != scidLastDrill || player->aended)
        newAnimation = scidPlayerStand[playerDirection];

    bool hasSupport;
    Direction leanOutDirection;
    int i;

    goingUpTimer += lag;

    for(i = 0; i < DIR_COUNT; ++i)
        if(input_IsDirPressed(i))
            playerDirection = i;

    /* check if player has support */

    hasSupport = checkSupport(vx, vy, &leanOutDirection);

    if(!hasSupport)
    {
        voff += (float)_PLAYER_FALL_SPEED * lag;

        if(voff >= (float)_BRICK_HEIGHT)
        {
            vy++;
            voff -= (float)_BRICK_HEIGHT;

            if(checkSupport(vx, vy + 1, &leanOutDirection))
                /* if gained support reset voff */
                voff = 0.0;
        }

        newAnimation = scidPlayerFall;

        /* cancel slipping move if player lost his support */
        slipping = false;

        return;
    }

    /* process player slipping move */

    if(slipping)
    {
        /* What if player suddenly gains support or his way
           is blocked by a falling brick? Simple - it can't
           happen because that would mean he was smashed. */

        hoff += lag * _PLAYER_SLIP_SPEED * (float)directionDelta[slipDirection][0];

        if(hoff >= (float)_BRICK_WIDTH)
        {
            hoff -= (float)_BRICK_WIDTH;
            vx++;
        }

        if(hoff < 0.0)
        {
            hoff += (float)_BRICK_WIDTH;
            vx--;
        }

        return;
    }

    /* climbing bricks */

    if(goingUpTrigger && goingUpTimer >= _DELAY_BEFORE_CLIMB)
    {
        goingUpTrigger = false;
        goingUp = true;
    }

    if(!input_IsDirPressed(goingUpDirection))
        goingUp = false;

    if(goingUp)
    {
        int cvx = vx + directionDelta[goingUpDirection][0];

        if(level_IsSolid(cvx, vy - 1) || level_IsSolid(vx, vy - 1) || !level_IsSolid(cvx, vy))
            goingUp = false;
    }

    if(goingUp)
    {
        voff -= _PLAYER_FALL_SPEED * lag;

        if(voff <= -(float)_BRICK_HEIGHT)
        {
            goingUp = false;

            voff = 0.0;
            vy--;

            hoff += (float)directionDelta[goingUpDirection][0] * _PLAYER_SPEED * lag;
        }
    }
    else if(voff < 0.0)
    {
        voff += _PLAYER_FALL_SPEED * lag;

        if(voff > 0.0)
            voff = 0.0;
    }

    /* check keystates and update position/animation accordingly */


    if(input_IsKeyPressed(KEY_DRILL))
    {
        newAnimation = scidPlayerDrill[playerDirection];
        scidLastDrill = newAnimation;

        if(!drillSched)
        {
            drillSched = true;
            drillDelayTimer = 0.0;
            return;
        }
    }

    if(drillSched)
        drillDelayTimer += lag;

    if(drillSched && drillDelayTimer >= _PLAYER_DRILL_DELAY)
    {
        drillSched = false;

        if(vy == (mapHeight - 1) && voff == 0.0 && playerDirection == DIR_DOWN)
        {
            advanceLevel(vx);
            return;
        }

        /* exact point where the brick was hit */
        float hx, hy;
        bool destroyed = false;

        if(voff < _HIT_DISTANCE_THRESHOLD)
        {
            if(playerDirection > DIR_RIGHT)
            {
                destroyed = drillField(vx, vy + directionDelta[playerDirection][1]);

                hx = (float)(vx * _BRICK_WIDTH) + hoff;
                hy = (float)(vy * _BRICK_HEIGHT);

                if(playerDirection == DIR_DOWN)
                    hy += (float)_BRICK_HEIGHT;
            }

            if(playerDirection == DIR_LEFT && hoff < (float)(_HIT_DISTANCE_THRESHOLD + _PLAYER_WIDTH2))
            {
                destroyed = drillField(vx - 1, vy);

                hx = (float)(vx * _BRICK_WIDTH);
                hy = (float)(vy * _BRICK_HEIGHT + _BRICK_HEIGHT / 2);
            }

            if(playerDirection == DIR_RIGHT && ((float)(_BRICK_WIDTH - _PLAYER_WIDTH2) - hoff) < (float)(_HIT_DISTANCE_THRESHOLD))
            {
                destroyed = drillField(vx + 1, vy);

                hx = (float)((vx + 1) * _BRICK_WIDTH);
                hy = (float)(vy * _BRICK_HEIGHT + _BRICK_HEIGHT / 2);
            }

            if(destroyed)
            {
                addDrillParticles(hx, hy, playerDirection);

                /*
                    Cause player to slip off the brick he is standing off
                    if he is leaning out towards newly created empty space.
                    This will prevent those moments of confusion when
                    player destroys a brick beneath and doesn't fall because
                    he has additional support.
                */
                if(playerDirection == DIR_DOWN && leanOutDirection != DIR_NONE)
                {
                    slipping = true;

                    if(leanOutDirection == DIR_LEFT)
                        slipDirection = DIR_RIGHT;
                    else
                        slipDirection = DIR_LEFT;
                }
            }

        }

        return;
    }

    bool goUp = false;

    if(playerDirection == DIR_LEFT && input_IsDirPressed(DIR_LEFT))
    {
        hoff -= lag * _PLAYER_SPEED;

        if(hoff < (float)_PLAYER_WIDTH2 && level_IsSolid(vx - 1, vy))
        {
            hoff = (float)_PLAYER_WIDTH2;

            if(!level_IsSolid(vx - 1, vy - 1))
                goUp = true;
        }
        else
            newAnimation = scidPlayerWalk[DIR_LEFT];
    }

    if(playerDirection == DIR_RIGHT && input_IsDirPressed(DIR_RIGHT))
    {
        hoff += lag * _PLAYER_SPEED;

        if(hoff > (float)(_BRICK_WIDTH - _PLAYER_WIDTH2) && level_IsSolid(vx + 1, vy))
        {
            hoff = (float)(_BRICK_WIDTH - _PLAYER_WIDTH2);

            if(!level_IsSolid(vx + 1, vy - 1))
                goUp = true;
        }
        else
            newAnimation = scidPlayerWalk[DIR_RIGHT];
    }

    if(hoff < 0.0)
    {
        hoff += (float)_BRICK_WIDTH;
        vx--;
    }

    if(hoff >= (float)_BRICK_WIDTH)
    {
        hoff -= (float)_BRICK_WIDTH;
        vx++;
    }

    if(goUp && !level_IsSolid(vx, vy - 1) && !goingUp && !goingUpTrigger)
    {
        goingUp = false;
        goingUpTrigger = true;
        goingUpShift = 0.0;
        goingUpDirection = playerDirection;
        goingUpTimer = 0.0;
    }
}