コード例 #1
0
ファイル: EffectsGame.cpp プロジェクト: rein4ce/VoidEngine
void CEffectsGame::Update( float frametime, float realtime )
{
	CGame::Update(frametime, realtime);

	// checking if hit rays
	DoPicking();
	//FadeOutBoxes();
	UpdateBullets(frametime);

	pLight->SetPosition( Vector3( sin(realtime)*20 + 12, 1, cos(realtime)*20 + 12));
	//pLight->SetPosition(pCamera->GetWorldPosition());
	
	// car movement
	if (car)
	{
		car->moveForward = Keydown('w');
		car->moveBackward = Keydown('s');
		car->moveLeft = Keydown('a');
		car->moveRight = Keydown('d');
	}
	

	
/*
	if (HasFileChanged("level.json")) 
	{
		ReloadGeometry();
	}


	// shooting of the balls
	static float strength = 10;

	if (gInput.IsKeydown(K_MOUSE2))
	{
		strength += frametime * 20.0f;
	}	

	if (gInput.WasKeyReleased(K_MOUSE2))
	{
		static float rot = 0;
		rot += 45;
		//NewtonBody *box = AddSphere(pScene, pWorld, pCamera->GetPosition() + pCamera->forward, 0.5f, 5000);//AddBox(pScene, pWorld, pCamera->GetPosition() + pCamera->forward, Vector3(0.5,0.5,0.5), Vector3(0,rot,0), 2000);
		//NewtonBodyAddImpulse(box, &(pCamera->forward*strength)[0], &(pCamera->GetPosition() + pCamera->forward)[0]);
		//NewtonBodySetContinuousCollisionMode(box, 1);
		strength = 10;
	}

	string s = "";
	for (int i=0; i<(int)strength; i++)	s += "|";	
	//gVGUI.AddTextMessage(gEngine.width - 100, 20, WHITE, s.c_str());
	*/

}
コード例 #2
0
ファイル: GameManager.cpp プロジェクト: pedert/PG430
void GameManager::PlayGame() 
{
	while (!doExit) //Main Game Loop
	{	
		RunGameOverCheck();

		UpdateGameTimers();

		UpdatePlayerInput();

		UpdateEnemySpawner();

		UpdateEnemies();

		UpdatePlayer();

		UpdateBullets();

		RunCollisionCheck();

		Render(); //Render everyting
	}
	QuitGame();
}
コード例 #3
0
ファイル: game.cpp プロジェクト: SpaceManiac/Lunatic
byte LunaticRun(int *lastTime)
{
	numRunsToMakeUp = 0;
	if (*lastTime > TIME_PER_FRAME * 30)
		*lastTime = TIME_PER_FRAME * 30;

	while (*lastTime >= TIME_PER_FRAME)
	{
		if (!gamemgl->Process())
		{
			mapToGoTo = 255;
			return LEVEL_ABORT;
		}

		if (gameMode == GAMEMODE_PLAY)
		{
			// update everything here
			if (!windingDown)
			{
				if (windingUp)
				{
					curMap->Update(UPDATE_FADEIN, &curWorld);
					EditorUpdateGuys(curMap);
					windingUp--;
				}
				else
				{
					curMap->Update(UPDATE_GAME, &curWorld);
					UpdateGuys(curMap, &curWorld);
					UpdateBullets(curMap, &curWorld);
					SpecialAnytimeCheck(curMap);
				}
			}
			else
			{
				curMap->Update(UPDATE_FADE, &curWorld);
				EditorUpdateGuys(curMap);
			}
			UpdateParticles(curMap);
			UpdateMessage();

			if (curMap->flags & MAP_SNOWING)
				MakeItSnow(curMap);

			if (windingDown)
			{
				windingDown--;
				if (!windingDown)
					return windDownReason;
			}
		}
		else if (gameMode == GAMEMODE_MENU)
		{
			switch (UpdatePauseMenu(gamemgl)) {
				case 0:
					lastKey = 0;
					gameMode = GAMEMODE_PLAY;
					break;
				case 1:
					break;
				case 2:
					if (mapNum)
						mapToGoTo = 0;
					else
						mapToGoTo = 255;
					lastKey = 0;
					return LEVEL_ABORT;
					break;
				case 3:
					mapToGoTo = 255;
					lastKey = 0;
					return WORLD_QUITGAME; // dump out altogether
					break;
			}
		}
		else if (gameMode == GAMEMODE_PIC) // gamemode_pic
		{
			if (GetTaps()&(CONTROL_B1 | CONTROL_B2))
			{
				gameMode = GAMEMODE_PLAY;
				// restore the palette
				gamemgl->LoadBMP("graphics\\title.bmp");
			}
		}
		else // gamemode_rage
		{
			UpdateRage(gamemgl);
			if (player.rageClock)
				player.rageClock--;
			else
			{
				gameMode = GAMEMODE_PLAY;
				StartRaging();
			}
			if (goodguy)
				goodguy->facing = (goodguy->facing + 1)&7;
		}

		if (msgFromOtherModules == MSG_NEWFEATURE)
		{
			NewMessage("** NEW FEATURE ADDED!! **", 120, 1);
			msgFromOtherModules = MSG_NONE;
		}
		else if (msgFromOtherModules == MSG_GOTOMAP)
		{
			mapToGoTo = msgContent;
			windingDown = 30;
			windDownReason = LEVEL_ABORT;
			msgFromOtherModules = MSG_NONE;
		}
		else if (msgFromOtherModules == MSG_WINLEVEL)
		{
			mapToGoTo = msgContent;
			windingDown = 40;
			windDownReason = LEVEL_WIN;
			msgFromOtherModules = MSG_NONE;
			if (player.worldNum == 4 && player.levelNum == 6)
			{

				ShowVictoryAnim(4); // you killed him.
				SendMessageToGame(MSG_WINGAME, 0);
			}
			player.boredom = 0;
		}
		else if (msgFromOtherModules == MSG_RESET)
		{
			if (opt.youSuck)
				NewBigMessage("You Suck", 30);
			else
				NewBigMessage("Try Again!", 30);
			windingDown = 30;
			windDownReason = LEVEL_RESET;
			msgFromOtherModules = MSG_NONE;
		}
		else if (msgFromOtherModules == MSG_LOADGAME)
		{
			NewBigMessage("Loading Game", 30);
			windingDown = 30;
			windDownReason = LEVEL_LOADING;
			msgFromOtherModules = MSG_NONE;
		}
		else if (msgFromOtherModules == MSG_WINGAME)
		{
			dword CDtime;

			mapToGoTo = 0;
			windingDown = 1;
			windDownReason = LEVEL_WIN;
			msgFromOtherModules = MSG_NONE;
			CDtime = timeGetTime();
			VictoryText(gamemgl);
			Credits(gamemgl);
			garbageTime += timeGetTime() - CDtime;
			player.boredom = 0;
		}
		*lastTime -= TIME_PER_FRAME;
		numRunsToMakeUp++;
		updFrameCount++;
	}
	HandleCDMusic();
	garbageTime = 0;
	JamulSoundUpdate();

	return LEVEL_PLAYING;
}
コード例 #4
0
ファイル: Enemy.cpp プロジェクト: Themperror/ThempX
void Enemy::Update(float dT)
{
	UpdateBullets(dT);
	obj->Update(dT);
	if(!isDead)
	{
		currentMoveTime += dT;
		if(currentMoveTime > movementSwitchTime)
		{
			currentMoveTime = 0;
			float xspeed = rand()% (int)ceil(movementSpeed); //getal van 0 tot 10
			float xfSpeed = xspeed - (int)ceil(movementSpeed)/2; // getal van -5 tot 5
			float zspeed = rand()%(int)ceil(movementSpeed); //getal van 0 tot 10
			float zfSpeed = zspeed -(int)ceil( movementSpeed)/2; // getal van -5 tot 5
			
			moveDir = D3DXVECTOR3(xfSpeed, 0, zfSpeed);
		}
		PxVec3 pos = actor->getGlobalPose().p;
		PxVec3 pDir = (playerPos - pos);
		pDir.y = 0;
		pDir.normalize();
		PxVec3 target = PxVec3(moveDir.x,0,moveDir.z);
		float angle = 90 - (90 * pDir.dot(target.getNormalized())) - 90; //mapping range 1 to -1 into 0-180 if desirable
		playerRight.y = 0;
		float direction = playerRight.dot(target.getNormalized());
		if(direction < 0 && angle > -45 && angle < 45)
		{
			angle = -angle;		
		}
		Object2D::Animation* cAnim = obj->GetCurrentAnim();
		Object2D::Animation anim;
		if(angle < -45)
		{
			cMState = MovementState::Forward; 
			anim = obj->GetAnimation("WalkForward");
			if(anim.isFinished || cAnim->AnimationName.compare(anim.AnimationName) != 0)
			{
				obj->PlayAnimation("WalkForward");
			}	
		}
		if(angle > -45 && angle < 0 && direction < 0)
		{
			cMState = MovementState::Left;
			anim = obj->GetAnimation("WalkLeft");
			if(anim.isFinished || cAnim->AnimationName.compare(anim.AnimationName) != 0)
			{
				obj->PlayAnimation("WalkLeft");
			}
		}
		else if(angle > 0 && angle < 45 && direction > 0)
		{
			cMState = MovementState::Right; 
			anim = obj->GetAnimation("WalkRight");
			if(anim.isFinished || cAnim->AnimationName.compare(anim.AnimationName) != 0)
			{
				obj->PlayAnimation("WalkRight");
			}
		}
		if(angle > -45 && angle < 0 && direction > 0)
		{
			cMState = MovementState::Right; 
			anim = obj->GetAnimation("WalkRight");
			if(anim.isFinished || cAnim->AnimationName.compare(anim.AnimationName) != 0)
			{
				obj->PlayAnimation("WalkRight");
			}
		}
		else if(angle > 0 && angle < 45 && direction < 0)
		{
			cMState = MovementState::Left;
			anim = obj->GetAnimation("WalkLeft");
			if(anim.isFinished || cAnim->AnimationName.compare(anim.AnimationName) != 0)
			{
				obj->PlayAnimation("WalkLeft");
			}
		}
		if(angle > 45)
		{
			cMState = MovementState::Back;
			anim = obj->GetAnimation("WalkBack");
			if(anim.isFinished || cAnim->AnimationName.compare(anim.AnimationName) != 0)
			{
				obj->PlayAnimation("WalkBack");
			}		
		}
		CheckShooting(30,dT*1.2f);
		if(sawPlayer)
		{
			cState = Enemy::Moving;
			int i = 0;
			CheckFutureCollision(i);
			Move(moveDir,dT*movementSpeed);
		}
	}
}