Exemplo n.º 1
7
HLTSOUND CClientSoundMgr::PlaySoundLocal(const char *pName, SoundPriority ePriority,
	uint32 dwFlags, uint8 nVolume, float fPitchShift, uint8 nSoundClass )
{
    if (!pName) return LTNULL;
	if (!GetConsoleInt("SoundEnable",1)) return LTNULL;

	PlaySoundInfo psi;
	PLAYSOUNDINFO_INIT(psi);

	// See if the passed in name is really a sound bute...

	int nSoundBute = g_pSoundButeMgr->GetSoundSetFromName( pName );
	if( nSoundBute != INVALID_SOUND_BUTE )
	{
		// Ok, it's a soundBute, Get it...

		SoundBute sb = g_pSoundButeMgr->GetSoundBute( nSoundBute );

		// Check for the play chance
		
		if( sb.m_fPlayChance < 1.0f )
		{
			if( GetRandom(0.0f,1.0f) > sb.m_fPlayChance )
				return LTNULL;
		}

		// Get a random sound file from the SoundButes' play list...

		strncpy( psi.m_szSoundName, g_pSoundButeMgr->GetRandomSoundFileWeighted( nSoundBute ), _MAX_PATH );
		
		// Should we use passed in values or SoundBute values...

		psi.m_nPriority		= (ePriority == SOUNDPRIORITY_MISC_LOW ? SOUNDPRIORITY_MISC_LOW : sb.m_ePriority);
		psi.m_nVolume		= (nVolume == SMGR_DEFAULT_VOLUME ? SMGR_DEFAULT_VOLUME : sb.m_nVolume);
		psi.m_fPitchShift	= (fPitchShift >= 1.0f ? 1.0f : sb.m_fPitch);
		dwFlags				= sb.m_nFlags;
	}
	else
	{
		// Just a normal sound file, play it with the passed in values...

		strncpy(psi.m_szSoundName, pName, _MAX_PATH);
		psi.m_nPriority		= ePriority;
		psi.m_nVolume		= nVolume;
		psi.m_fPitchShift	= fPitchShift;
		psi.m_nSoundVolumeClass = nSoundClass;
	}

	psi.m_dwFlags = PLAYSOUND_LOCAL;
	psi.m_dwFlags |= dwFlags;

	// Make sure local sounds aren't 3d...
	psi.m_dwFlags &= ~PLAYSOUND_3D;

	if (nVolume < 100)
	{
		psi.m_dwFlags |= PLAYSOUND_CTRL_VOL;
	}

    return PlaySound(psi);
}
Exemplo n.º 2
0
void CChickenBoid::Think( float dt,SBoidContext &bc )
{
	Vec3 flockHeading(0,0,0);

	m_accel(0,0,0);
//	float height = m_pos.z - bc.terrainZ;

	if (m_bThrown)
	{
		m_accel.Set(0,0,-10.0f);
		//float z = bc.engine->GetTerrainElevation(m_pos.x,m_pos.y) + bc.fBoidRadius*0.5f;
		m_pos.z = bc.engine->GetTerrainElevation(m_pos.x,m_pos.y) + bc.fBoidRadius*0.5f;
		//pe_status_pos ppos;
		//m_pPhysics->GetStatus(&ppos);
		//if (m_pos.z < z)
		{
			m_physicsControlled = false;
			m_bThrown = false;
			m_heading.z = 0;
			if (m_heading.IsZero())
				m_heading = Vec3(1,0,0);
			m_heading.Normalize();
			m_accel.Set(0,0,0);
			m_speed = bc.MinSpeed;
			m_heading.z = 0;
		}
		return;
	}

	// Free will.
	// Continue accelerating in same dir untill target speed reached.
	// Try to maintain average speed of (maxspeed+minspeed)/2
	float targetSpeed = bc.MinSpeed;
	m_accel -= m_heading*(m_speed-targetSpeed)*0.4f;

	// Gaussian weight.
	m_accel.z = 0;

	m_bScared = false;

	if (bc.factorAlignment != 0)
	{
		//CalcCohesion();
		Vec3 alignmentAccel;
		Vec3 cohesionAccel;
		Vec3 separationAccel;
		CalcFlockBehavior(bc,alignmentAccel,cohesionAccel,separationAccel);

		//! Adjust for allignment,
		//m_accel += alignmentAccel.Normalized()*ALIGNMENT_FACTOR;
		m_accel += alignmentAccel*bc.factorAlignment;
		m_accel += cohesionAccel*bc.factorCohesion;
		m_accel += separationAccel;
	}

	/*
	// Avoid land.
	if (height < bc.MinHeight && !m_landing)
	{
		float v = (1.0f - height/bc.MinHeight);
		m_accel += Vec3(0,0,v*v)*bc.factorAvoidLand;
	}
	else if (height > bc.MaxHeight) // Avoid max height.
	{
		float v = (height - bc.MaxHeight)*0.1f;
		m_accel += Vec3(0,0,-v);
	}
	else
	{
		// Always try to accelerate in direction oposite to current in Z axis.
		m_accel.z = -(m_heading.z*m_heading.z*m_heading.z * 100.0f);
	}
	*/

	// Attract to origin point.
	if (bc.followPlayer)
	{
		m_accel += (bc.playerPos - m_pos) * bc.factorAttractToOrigin;
	}
	else
	{
		//m_accel += (m_birdOriginPos - m_pos) * bc.factorAttractToOrigin;
		if ((cry_rand()&31) == 1)
		{
			m_birdOriginPos = Vec3(	bc.flockPos.x+Boid::Frand()*bc.fSpawnRadius,bc.flockPos.y+Boid::Frand()*bc.fSpawnRadius,bc.flockPos.z+Boid::Frand()*bc.fSpawnRadius );
			if (m_birdOriginPos.z - bc.terrainZ < bc.MinHeight)
			{
				m_birdOriginPos.z = bc.terrainZ + bc.MinHeight;
			}
		}

		/*
		if (m_pos.x < bc.flockPos.x-bc.fSpawnRadius || m_pos.x > bc.flockPos.x+bc.fSpawnRadius ||
		m_pos.y < bc.flockPos.y-bc.fSpawnRadius || m_pos.y > bc.flockPos.y+bc.fSpawnRadius ||
		m_pos.z < bc.flockPos.z-bc.fSpawnRadius || m_pos.z > bc.flockPos.z+bc.fSpawnRadius)
		*/
		{
			m_accel += (m_birdOriginPos - m_pos) * bc.factorAttractToOrigin;
		}
	}


	// Avoid collision with Terrain and Static objects.
	float fCollisionAvoidanceWeight = 10.0f;

	// Do walk sounds.
	if ((cry_rand()&0xFF) == 0)
		PlaySound(CHICKEN_SOUND_CLUCK);

	//////////////////////////////////////////////////////////////////////////
	// Player must scare chickens off.
	//////////////////////////////////////////////////////////////////////////
	float fScareDist = 5.0f;
	float sqrPlayerDist = m_pos.GetSquaredDistance(bc.playerPos);
	if (sqrPlayerDist < fScareDist*fScareDist)
	{
		Vec3 retreatDir = (m_pos - bc.playerPos) + Vec3(Boid::Frand()*2.0f,Boid::Frand()*2.0f,0);
		retreatDir.NormalizeFast();
		float scareFactor = (1.0f - sqrPlayerDist/(fScareDist*fScareDist));
		m_accel.x += retreatDir.x*scareFactor*bc.factorAvoidLand;
		m_accel.y += retreatDir.y*scareFactor*bc.factorAvoidLand;

		m_bScared = true;
		if (m_landing) m_actionTime = m_maxIdleTime+1.0f; // Stop idle.
		// Do walk sounds.
		if ((cry_rand()&0xF) == 0)
			PlaySound(CHICKEN_SOUND_SCARED);
	}

	//////////////////////////////////////////////////////////////////////////
	// Scare points also scare chicken off.
	//////////////////////////////////////////////////////////////////////////
	if (bc.scareRatio > 0)
	{
		float sqrScareDist = m_pos.GetSquaredDistance(bc.scarePoint);
		if (sqrScareDist < bc.scareRadius*bc.scareRadius)
		{
			float fScareMultiplier = 10.0f;
			Vec3 retreatDir = m_pos - bc.scarePoint;
			retreatDir.NormalizeFast();
			float scareFactor = (1.0f - sqrScareDist/(bc.scareRadius*bc.scareRadius));
			m_accel.x += retreatDir.x*scareFactor*fScareMultiplier;
			m_accel.y += retreatDir.y*scareFactor*fScareMultiplier;

			if (m_landing) m_actionTime = m_maxIdleTime+1.0f; // Stop idle.

			m_bScared = true;

			// Do walk sounds.
			if ((cry_rand()&0xF) == 0)
				PlaySound(CHICKEN_SOUND_CLUCK);
		}
	}
	//////////////////////////////////////////////////////////////////////////

	const int frameID = gEnv->pRenderer->GetFrameID();
	if (bc.avoidObstacles && m_speed > 0.0f && (frameID-m_lastRayCastFrame) > 3)
	{
		// Avoid obstacles & terrain.
		IPhysicalWorld *physWorld = bc.physics;

		Vec3 vDir0 = m_heading*bc.fBoidRadius*0.5f;
		Vec3 vPos = m_pos + Vec3(0,0,bc.fBoidRadius*0.5f) + vDir0;
		Vec3 vDir = m_heading*(bc.fBoidRadius*2) + Vec3(0,0,bc.fBoidRadius*0.5f);
		// Add some random variation in probe ray.
		vDir.x += Boid::Frand()*0.5f;
		vDir.y += Boid::Frand()*0.5f;

		int objTypes = ent_all|ent_no_ondemand_activation;
		int flags = rwi_stop_at_pierceable|rwi_ignore_terrain_holes;
		ray_hit hit;
		int col = physWorld->RayWorldIntersection( vPos,vDir,objTypes,flags,&hit,1 );
		if (col != 0 && hit.dist > 0)
		{
			// Turn from collided surface.
			Vec3 normal = hit.n;
			float rayLen = vDir.GetLength();
			float w = (1.0f - hit.dist/rayLen);
			Vec3 R = m_heading - (2.0f*m_heading.Dot(normal))*normal;
			R.NormalizeFast();
			R += normal;
			//m_accel += R*(w*w)*bc.factorAvoidLand * fCollisionAvoidanceWeight;
			Vec3 accel = R*w*bc.factorAvoidLand * fCollisionAvoidanceWeight;
			m_avoidanceAccel = m_avoidanceAccel*bc.fSmoothFactor + accel*(1.0f-bc.fSmoothFactor);
		}

		m_lastRayCastFrame = frameID;
	}

	m_accel += m_avoidanceAccel;
	m_avoidanceAccel = m_avoidanceAccel*bc.fSmoothFactor;

	if (!m_landing)
	{
		m_actionTime += dt;
		if (m_actionTime > m_maxNonIdleTime && (m_pos.z > bc.waterLevel && bc.bAvoidWater))
		{
			// Play idle.
			PlayAnimationId( CHICKEN_IDLE_ANIM + (cry_rand()%CHICKEN_IDLE_ANIM_NUM),true );
			m_maxIdleTime = 2.0f + cry_frand()*MAX_REST_TIME;
			m_landing = true;
			m_actionTime = 0;
			
			m_accel.Set(0,0,0);
			m_speed = 0;
		}
	}
	else
	{
		m_accel = m_heading;
		m_speed = 0.1f;

		m_actionTime += dt;
		if (m_actionTime > m_maxIdleTime)
		{
			m_maxNonIdleTime = cry_frand()*MAX_WALK_TIME;
			PlayAnimationId( CHICKEN_WALK_ANIM,true );
			m_landing = false;
			m_actionTime = 0;
		}
	}

	// Limits birds to above water and land.
	m_pos.z = bc.engine->GetTerrainElevation(m_pos.x,m_pos.y) + bc.fBoidRadius*0.5f;
	m_accel.z = 0;

	//////////////////////////////////////////////////////////////////////////
	// Avoid water ocean..
	if (m_pos.z < bc.waterLevel && bc.bAvoidWater)
	{
		if (m_landing)
			m_actionTime = m_maxIdleTime;
		Vec3 nextpos = m_pos + m_heading;
		float farz = bc.engine->GetTerrainElevation(nextpos.x,nextpos.y) + bc.fBoidRadius*0.5f;
		if (farz > m_pos.z)
			m_accel += m_heading*bc.factorAvoidLand;
		else
			m_accel += -m_heading*bc.factorAvoidLand;
		m_accel.z = 0;
	}
	//////////////////////////////////////////////////////////////////////////
}
Exemplo n.º 3
0
void MiscModule_Impl::playSound(const CString& path)
{
	PlaySound(path, NULL, SND_FILENAME | SND_ASYNC);
}
Exemplo n.º 4
0
int daKoopaThrow::onCreate() {

	this->direction = this->settings & 0xF;
	this->Type = (this->settings >> 4) & 0xF;
	this->front = (this->settings >> 8) & 0xF;

	currentInfo = &types[Type];

	allocator.link(-1, GameHeaps[0], 0, 0x20);

	nw4r::g3d::ResFile rf(getResource(currentInfo->arcName, currentInfo->brresName));
	nw4r::g3d::ResMdl resMdl = rf.GetResMdl(currentInfo->modelName);

	bodyModel.setup(resMdl, &allocator, (Type == 4 ? 0x224 : 0), 1, 0);
	SetupTextures_Enemy(&bodyModel, 0);

	if (Type == 4) {
		// Thwomp
		playsAnim = true;

		nw4r::g3d::ResAnmChr anmChr = rf.GetResAnmChr("boss_throw");
		chrAnim.setup(resMdl, anmChr, &allocator, 0);
		chrAnim.bind(&bodyModel, anmChr, 1);
		bodyModel.bindAnim(&chrAnim, 0.0);
		chrAnim.setUpdateRate(1.0);
	}

	allocator.unlink();


	ActivePhysics::Info KoopaJunk;

	KoopaJunk.xDistToCenter = 0.0f;
	KoopaJunk.yDistToCenter = (Type == 4) ? currentInfo->size : 0.0;
	KoopaJunk.xDistToEdge = currentInfo->size;
	KoopaJunk.yDistToEdge = currentInfo->size;

	this->scale.x = currentInfo->scale;
	this->scale.y = currentInfo->scale;
	this->scale.z = currentInfo->scale;

	KoopaJunk.category1 = 0x3;
	KoopaJunk.category2 = 0x0;
	KoopaJunk.bitfield1 = 0x47;
	KoopaJunk.bitfield2 = 0xFFFFFFFF;
	KoopaJunk.unkShort1C = 0;
	KoopaJunk.callback = &dEn_c::collisionCallback;

	this->aPhysics.initWithStruct(this, &KoopaJunk);
	this->aPhysics.addToList();


	spriteSomeRectX = currentInfo->size;
	spriteSomeRectY = currentInfo->size;
	_320 = 0.0f;
	_324 = currentInfo->size;

	// These structs tell stupid collider what to collide with - these are from koopa troopa
	static const lineSensor_s below(12<<12, 4<<12, 0<<12);
	static const pointSensor_s above(0<<12, 12<<12);
	static const lineSensor_s adjacent(6<<12, 9<<12, 6<<12);

	collMgr.init(this, &below, &above, &adjacent);
	collMgr.calculateBelowCollisionWithSmokeEffect();

	cmgr_returnValue = collMgr.isOnTopOfTile();


	if (this->direction == 0) 	   { // Ground Facing Left
		this->pos.x -= 0.0; // -32 to +32
		this->pos.y += 36.0;
		// this->rot.z = 0x2000;
	}
	else if (this->direction == 1) { // Ground Facing Right
		this->pos.x += 0.0; // +32 to -32
		this->pos.y += 36.0;
		// this->rot.z = 0xE000;
	}
	if (this->front == 1) { this->pos.z = -1804.0; }
	else 				  { this->pos.z =  3300.0; }


	if (currentInfo->launchSound != 0) {
		PlaySound(this, currentInfo->launchSound);
	}

	if (Type == 3) {
		PlaySoundWithFunctionB4(SoundRelatedClass, &hammerSound, SE_EMY_MEGA_BROS_HAMMER, 1);
	}

	doStateChange(&StateID_Straight);

	this->onExecute();
	return true;
}
Exemplo n.º 5
0
/*
** Parses and executes the given command.
**
*/
void CommandHandler::ExecuteCommand(const WCHAR* command, MeterWindow* skin, bool multi)
{
	if (command[0] == L'!')	// Bang
	{
		++command;	// Skip "!"

		if (_wcsnicmp(L"Execute", command, 7) == 0)
		{
			command += 7;
			command = wcschr(command, L'[');
			if (!command) return;
		}
		else
		{
			if (_wcsnicmp(command, L"Rainmeter", 9) == 0)
			{
				// Skip "Rainmeter" for backwards compatibility
				command += 9;
			}

			std::wstring bang;
			std::vector<std::wstring> args;

			// Find the first space
			const WCHAR* pos = wcschr(command, L' ');
			if (pos)
			{
				bang.assign(command, 0, pos - command);
				args = ParseString(pos + 1, skin ? &skin->GetParser() : nullptr);
			}
			else
			{
				bang = command;
			}

			ExecuteBang(bang.c_str(), args, skin);
			return;
		}
	}

	if (multi && command[0] == L'[')	// Multi-bang
	{
		std::wstring bangs = command;
		std::wstring::size_type start = std::wstring::npos;
		int count = 0;
		for (size_t i = 0, isize = bangs.size(); i < isize; ++i)
		{
			if (bangs[i] == L'[')
			{
				if (count == 0)
				{
					start = i;
				}
				++count;
			}
			else if (bangs[i] == L']')
			{
				--count;

				if (count == 0 && start != std::wstring::npos)
				{
					// Change ] to nullptr
					bangs[i] = L'\0';

					// Skip whitespace
					start = bangs.find_first_not_of(L" \t\r\n", start + 1, 4);

					ExecuteCommand(bangs.c_str() + start, skin, false);
				}
			}
			else if (bangs[i] == L'"' && isize > (i + 2) && bangs[i + 1] == L'"' && bangs[i + 2] == L'"')
			{
				i += 3;

				std::wstring::size_type pos = bangs.find(L"\"\"\"", i);
				if (pos != std::wstring::npos)
				{
					i = pos + 2;	// Skip "", loop will skip last "
				}
			}
		}
	}
	else
	{
		// Check for built-ins
		if (_wcsnicmp(L"PLAY", command, 4) == 0)
		{
			if (command[4] == L' ' ||                      // PLAY
				_wcsnicmp(L"LOOP ", &command[4], 5) == 0)  // PLAYLOOP
			{
				command += 4;	// Skip PLAY

				DWORD flags = SND_FILENAME | SND_ASYNC;

				if (command[0] != L' ')
				{
					flags |= SND_LOOP | SND_NODEFAULT;
					command += 4;	// Skip LOOP
				}

				++command;	// Skip the space
				if (command[0] != L'\0')
				{
					std::wstring sound = command;

					// Strip the quotes
					std::wstring::size_type len = sound.length();
					if (len >= 2 && sound[0] == L'"' && sound[len - 1] == L'"')
					{
						len -= 2;
						sound.assign(sound, 1, len);
					}

					if (skin)
					{
						skin->GetParser().ReplaceMeasures(sound);
						skin->MakePathAbsolute(sound);
					}

					PlaySound(sound.c_str(), nullptr, flags);
				}
				return;
			}
			else if (_wcsnicmp(L"STOP", &command[4], 4) == 0)  // PLAYSTOP
			{
				PlaySound(nullptr, nullptr, SND_PURGE);
				return;
			}
		}

		// Run command
		std::wstring tmpSz = command;
		if (skin)
		{
			skin->GetParser().ReplaceMeasures(tmpSz);
		}
		RunCommand(tmpSz);
	}
}
Exemplo n.º 6
0
ManagedSoundWeak AudioManager::PlaySound(int soundID, const sf::Vector3f &pos, float maxVolumeDist, float attenuation)
	{
	return PlaySound(soundID, pos, 100.0f, 1.0f, maxVolumeDist, attenuation);
	}
Exemplo n.º 7
0
AREXPORT bool ArSoundPlayer::playWavFile(const char* filename, const char* params) 
{
  return (PlaySound(filename, NULL, SND_FILENAME) == TRUE);
}
Exemplo n.º 8
0
inline void Rubiks3LL::AudioKey(uint data) {
	if (data == 1) {
		PlaySound(TEXT("Front.wav"), NULL, SND_SYNC);
	}
	else if (data == 2) {
		PlaySound(TEXT("Inverted_Front.wav"), NULL, SND_SYNC);
	}
	else if (data == 3) {
		PlaySound(TEXT("Left.wav"), NULL, SND_SYNC);
	}
	else if (data == 4) {
		PlaySound(TEXT("Inverted_Left.wav"), NULL, SND_SYNC);
	}
	else if (data == 5) {
		PlaySound(TEXT("Back.wav"), NULL, SND_SYNC);
	}
	else if (data == 6) {
		PlaySound(TEXT("Inverted_Back.wav"), NULL, SND_SYNC);
	}
	else if (data == 7) {
		PlaySound(TEXT("Right.wav"), NULL, SND_SYNC);
	}
	else if (data == 8) {
		PlaySound(TEXT("Inverted_Right.wav"), NULL, SND_SYNC);
	}
	else if (data == 9) {
		PlaySound(TEXT("Top.wav"), NULL, SND_SYNC);
	}
	else if (data == 10) {
		PlaySound(TEXT("Inverted_Top.wav"), NULL, SND_SYNC);
	}
	else if (data == 11) {
		PlaySound(TEXT("Bottom.wav"), NULL, SND_SYNC);
	}
	else if (data == 12) {
		PlaySound(TEXT("Inverted_Bottom.wav"), NULL, SND_SYNC);
	}
}
Exemplo n.º 9
0
LRESULT CALLBACK StandButtonProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
{
	if (msg == WM_LBUTTONDOWN) {

		GameEngine* gameEngine = GameEngine::getInstance();
		
		User* user = gameEngine->getUser();
		Table* table = gameEngine->getTable();

		table->setState(TABLE_STATE_STANDING);
		Hand* dealerHand = table->getDealerHand();
		Hand* playerHand = table->getPlayerHand();

		//
		// Flip over the first card. 
		//
		dealerHand->GetCards()->at(0)->setFacedown(false);
		PlaySound(L"sound-flipcard.wav", NULL, SND_FILENAME | SND_ASYNC);

		RedrawWindow(gameEngine->getHWnd(), NULL, NULL,
			RDW_INVALIDATE | RDW_UPDATENOW);

		Sleep(500);

		//
		// See if we need additional cards.
		//
		while (true) {
			std::vector<int>* vals = dealerHand->GetValues();

			bool done = false;

			for (int i = 0; i < vals->size(); i++) {
				// Dealer must stop taking cards
				// if he has a value of 17 or higher.
				if (vals->at(i) >= 17) {
					done = true;
					break;
				}
			}

			if (done) {
				break;
			}

			PlaySound(L"sound-flipcard.wav", NULL, SND_FILENAME | SND_ASYNC);

			dealerHand->dealCard(false);

			RedrawWindow(gameEngine->getHWnd(), NULL, NULL,
				RDW_INVALIDATE | RDW_UPDATENOW);
			
			Sleep(500);
		}

		//
		// Determine winner. Update balance amounts.
		//

		// table->setState(TABLE_STATE_READY);

		std::vector<int>* dealerValues = dealerHand->GetValues();
		std::vector<int>* playerValues = playerHand->GetValues();
		int dealerFinal = 0;
		int playerFinal = 0;

		for (int i = 0; i < dealerValues->size(); i++) {
			if (dealerValues->at(i) > dealerFinal &&
				dealerValues->at(i) < 22) {
				dealerFinal = dealerValues->at(i);
			}
		}

		for (int i = 0; i < playerValues->size(); i++) {
			if (playerValues->at(i) > playerFinal &&
				playerValues->at(i) < 22) {
				playerFinal = playerValues->at(i);
			}
		}

		table->setState(TABLE_STATE_FINISHED);

		// If values are same, this is a push. 
		if (dealerFinal == playerFinal) {

			updateTextarea(hStaticTableMiddleMessage, "Push");

			// Return player's bet money.
			int bet = playerHand->getBetAmount();

			user->setBalance(user->getBalance() + bet);

		} else if (dealerFinal < playerFinal) {

			// Player wins, return bet and winning.

			updateTextarea(hStaticTableMiddleMessage, "Player Wins!");

			int bet = playerHand->getBetAmount();

			user->setBalance(user->getBalance() + (bet*2) );

		}
		else if (dealerFinal > playerFinal) {

			// No need to update cash. Has already been deducted
			// at time of bet. Update the middle message area.
			updateTextarea(hStaticTableMiddleMessage, "Dealer Wins.");

		}

		RedrawWindow(gameEngine->getHWnd(), NULL, NULL,
			RDW_INVALIDATE | RDW_UPDATENOW);

	}

	return CallWindowProc(oldStandButtonProc, hwnd, msg, wp, lp);
}
Exemplo n.º 10
0
LRESULT CALLBACK DealButtonProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
{

	if (msg == WM_LBUTTONDOWN) {

		TCHAR buff[64];
		GetWindowText(hTextboxBetAmount, buff, 20);

		int bet = _ttoi(buff);

		/*
		for (int i = 0; buff[i] != NULL; i++) {
			if (! std::isdigit(buff[i]) ) {
				MessageBox(
					GameEngine::getInstance()->getHWnd(),
					L"Invalid bet amount.",
					L"Error",
					NULL);

				return 0;
			}
		}
		*/

		// int bet = atoi(buff);

		Table* table = GameEngine::getInstance()->getTable();
		User* user = GameEngine::getInstance()->getUser();

		// Can player bet this much?
		if (bet > user->getBalance()) {
			MessageBox(
				GameEngine::getInstance()->getHWnd(),
				L"Insufficient funds available to place this bet.",
				L"Error",
				NULL);
			return 0;
		}

		if (bet == 0) {
			MessageBox(
				GameEngine::getInstance()->getHWnd(),
				L"Must bet more than $0.",
				L"Error",
				NULL);
			return 0;
		}

		Hand* dealerHand = new Hand();
		Hand* playerHand = new Hand();

		playerHand->setBetAmount(bet);
		user->setBalance(user->getBalance() - bet);

		dealerHand->dealCard(true);
		dealerHand->dealCard(false);

		playerHand->dealCard(false);
		playerHand->dealCard(false);

		table->setDealerHand(dealerHand);
		table->setPlayerHand(playerHand);

		GameEngine::getInstance()->setState(GameEngine::STATE_PLAYING);

		PlaySound(L"sound-chips.wav", NULL, SND_FILENAME | SND_ASYNC);

		//
		// Check if we have blackjack, if so player
		// wins right away. Otherwise move to substate 
		// "playing"
		//
		if (playerHand->isBlackjack()) {
			table->setState(TABLE_STATE_FINISHED);
			updateTextarea(hStaticTableMiddleMessage, "Blackjack! Player Wins.");
			
			// Play YAY sound
			PlaySound(L"sound-yay.wav", NULL, SND_FILENAME | SND_ASYNC);

			// Update user balance.
			user->setBalance(user->getBalance() + (bet*2));

		} else {
			table->setState(TABLE_STATE_PLAYING);
		}	

		//
		// Force redraw of window, which should now render the new
		// card data. 
		//
		// https://msdn.microsoft.com/en-us/library/dd162911%28VS.85%29.aspx
		// http://stackoverflow.com/questions/2325894/difference-between-invalidaterect-and-redrawwindow
		//
		RedrawWindow(GameEngine::getInstance()->getHWnd(), NULL, NULL,
			RDW_INVALIDATE | RDW_UPDATENOW);


		return 0;

	}

	return CallWindowProc(oldDealButtonProc, hwnd, msg, wp, lp);
}
task main()
{
  StartTask(balancing);
  while(starting_balancing_task){}
  //It's that simple - now go program something cool below!

  /*Here's how to control the Segway.

  MOVING AROUND
  - Adjust <steering> to steer.
  	   steering = 0  ; //Go Straight
  	   steering = 10 ; //Turn Right
       steering = 17;  //Turn Right quicklier
  	   steering = -10; //Turn Left
       etc...

   - Adjust <speed> for moving forward and backwards.
       Its value is the motor power that the robot will attempt to maintain

  	   speed = 0;     //Stand still
  	   speed = -20 ; //Go backward at 20% of motor power
       speed = 50;   //Go forward at half of maximum motor power (recommended)
       etc...

    - Adjust <acceleration> to change how quickly your robot will reach a certain speed.

       acceleration = 60; means that if your current speed is -20 and you change it
       to 40, it will take 1 seconds to get to that speed. You don't need to change this
       in your program, just set it once. Setting <acceleration = 60;> is recommended.

  TIPS & TRICKS
  - Don't mess with motor B and C!
  - You can read the motor encoders like you would normally do. Just don't reset them.
  - 'speed' sets the segway motor speed - This means you go faster if you use bigger wheels.
  - If you use those big RCX/Motorcycle wheels, say, greater than 60 mm in diameter, consider
    building a slightly bigger Segway, with better supported wheels and a greater wheelspan.
    That improves balancing a great deal!
   */

   //////////////////////////////////////////////
   //
   // EXAMPLE #1: Wall avoidance



   const tSensors Sonar = S4;
   SensorType[Sonar] = sensorSONAR;

   acceleration = 60;
   steering = 0;
   wait1Msec(3000);//We wait three seconds just to be sure we're up and running
   PlaySound(soundBeepBeep);

   speed = 50;

   //Every 100 ms, we check if the sensor has spotted anything closer than 60 cm.
   //When so, the robot goes backwards, turns, and continues its way. Note how the
   //speed and steering variables are used to manipulate the robot's movement.

   while(true)
   {
     if(SensorValue[Sonar] < 60)
     {
       speed = -50;
       wait1Msec(2000);
       speed = 0;
       wait1Msec(500);
       steering = 10;
       wait1Msec(1000);
       steering = 0;
       speed = 50;
     }
     wait1Msec(100);
   }
}
Exemplo n.º 12
0
void Game::playSound(void)
{
	PlaySound((LPCSTR) "pacman_chomp.wav", NULL, SND_FILENAME | SND_ASYNC | SND_LOOP);
}
//=========================================
// Main Program
//=========================================
task main()
{
	disableDiagnosticsDisplay();
	alive();
	initializeRobot();

	StartTask(sensors);
	StartTask(sonarSensors);
	StartTask(selector);

	waitForStart();

	StartTask(display);

	constHeading = 0;
	relHeading = 0;

	if(calibrate != 2)
	{
		gyroCalTime = 3;
		calibrate = 1;
		while(calibrate != 2)
		{
			EndTimeSlice();
		}
	}
	constHeading = 0;
	relHeading = 0;

	wait1Msec(time_selector*1000);
	PlaySound(soundBeepBeep);

	switch(MissionNumber)
	{
	case 1:

		GyroSonar_moveV2(0, SIDE_BACK, sonarLive, 110, -60,true, true, CONSTANT);
		Gyro_TurnV2(42,-15,CONSTANT);
		wait1Msec(1000);
		GyroTime_moveV2(1200,-30,true,false,false);
		motor[motorA] = -50;
		wait1Msec(1000);
		motor[motorA] = -3;
		GyroTimeS_moveV2(8000,-15,true,true,false,false);

		if(currDir >= 4 && currDir <= 6) column = 2;
		if(currDir < 4) column = 1;
		if(currDir > 6) column = 3;

		if(column == 1)
		{
			GyroTimeS_moveV2(300,15,true,false,true,false);
			GyroTimeS_moveV2(8000,15,true,true,true,false);
		}
		if(column == 3)
		{
			GyroTimeS_moveV2(300,-15,true,false,true,false);
			GyroTimeS_moveV2(8000,-15,true,true,true,false);
		}

		break;
	case 2:

		while(true)
		{
			nxtDisplayBigTextLine(1, "%3d", sonarLive);
			nxtDisplayBigTextLine(3, "%3d", sonarLive2);
		}

		break;
	case 8:

		while(true)
		{
			//nxtDisplayBigTextLine(1, "S: %3d", sonarLive);
			//nxtDisplayBigTextLine(3, "S2: %3d", sonarLive2);
			//nxtDisplayBigTextLine(5, "G: %3f", relHeading);
		}

		break;
	}
}
//====================================================
// Selector
//====================================================
task selector()
{
	wait1Msec(1000);
	while((nNxtButtonPressed != kEnterButton))
	{
		if (nNxtButtonPressed == kLeftButton)
		{
			while(nNxtButtonPressed ==kLeftButton){};
			MissionNumber = MissionNumber-1;
			PlaySoundFile("! Click.rso");
		}
		if (MissionNumber < 1)
		{
			MissionNumber = 1;
		}
		if (MissionNumber > 20)
		{
			MissionNumber = 20;
		}
		if (nNxtButtonPressed == kRightButton)
		{
			while(nNxtButtonPressed ==kRightButton){};
			MissionNumber = MissionNumber+1;
			PlaySoundFile("! Click.rso");
		}
		nxtDisplayBigTextLine(2, "Mission");
		nxtDisplayBigTextLine(5, "%2d", MissionNumber);
	}

	eraseDisplay();

	string tmp = "";

	StringFormat(tmp, "%3d", MissionNumber);

	nxtDisplayBigStringAt(20,18,tmp);

	while(nNxtButtonPressed == kEnterButton)
	{}

	eraseDisplay();

	while(nNxtButtonPressed != kEnterButton)
	{
		nxtDisplayBigTextLine(6, "SecDelay");
		nxtDisplayBigTextLine(4, "%3d", time_selector);

		if (nNxtButtonPressed == kLeftButton)
		{
			while(nNxtButtonPressed ==kLeftButton){};
			time_selector = time_selector-1;
			PlaySoundFile("! Click.rso");
		}
		if (nNxtButtonPressed == kRightButton)
		{
			while(nNxtButtonPressed ==kRightButton){}
			time_selector = time_selector+1;
			PlaySoundFile("! Click.rso");
		}
		if(time_selector > 30) time_selector = 30;
		if(time_selector < 0) time_selector = 0;
	}
	PlaySound(soundException);
	wait1Msec(200);
	eraseDisplay();
	while(nNxtButtonPressed == kEnterButton){}
	while(nNxtButtonPressed != kEnterButton)
	{
		nxtDisplayBigTextLine(6, "gyro_cal");
		nxtDisplayBigTextLine(4, "%2d", gyroCalTime);

		if(nNxtButtonPressed == kLeftButton)
		{
			while(nNxtButtonPressed == kLeftButton){}
			gyroCalTime = gyroCalTime-1;
			PlaySoundFile("! Click.rso");
		}
		if(nNxtButtonPressed == kRightButton)
		{
			while(nNxtButtonPressed == kRightButton){}
			gyroCalTime = gyroCalTime+1;
			PlaySoundFile("! Click.rso");
		}
		if(gyroCalTime > 15) gyroCalTime = 15;
		if(gyroCalTime < 0) gyroCalTime = 0;
	}
	if(gyroCalTime > 0) calibrate = 1;
	PlaySound(soundException);
	eraseDisplay();
}
Exemplo n.º 15
0
Arquivo: main.cpp Projeto: Gxsghsn/xy2
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
	WNDCLASSEX wndClass = { 0 };							//用WINDCLASSEX定义了一个窗口类
	wndClass.cbSize = sizeof(WNDCLASSEX);			//设置结构体的字节数大小
	wndClass.style = CS_HREDRAW | CS_VREDRAW;	//设置窗口的样式
	wndClass.lpfnWndProc = WndProc;					//设置指向窗口过程函数的指针
	wndClass.cbClsExtra = 0;								//窗口类的附加内存,取0就可以了
	wndClass.cbWndExtra = 0;							//窗口的附加内存,依然取0就行了
	wndClass.hInstance = hInstance;						//指定包含窗口过程的程序的实例句柄。
	wndClass.hIcon = (HICON)::LoadImage(NULL, L"icon.ico", IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_LOADFROMFILE);  //本地加载自定义ico图标
	wndClass.hCursor = (HICON)::LoadImage(NULL, L"icon.ico", IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_LOADFROMFILE);    //指定窗口类的光标句柄。
	wndClass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);  //为hbrBackground成员指定一个白色画刷句柄	
	wndClass.lpszMenuName = NULL;						//用一个以空终止的字符串,指定菜单资源的名字。
	wndClass.lpszClassName = L"ForTheDreamOfGameDevelop";		//用一个以空终止的字符串,指定窗口类的名字。

	if (!RegisterClassEx(&wndClass))				//设计完窗口后,需要对窗口类进行注册,这样才能创建该类型的窗口
		return -1;

	HWND hwnd = CreateWindow(L"ForTheDreamOfGameDevelop", WINDOW_TITLE,				//喜闻乐见的创建窗口函数CreateWindow
		WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, WINDOW_WIDTH,
		WINDOW_HEIGHT, NULL, NULL, hInstance, NULL);

	MoveWindow(hwnd, 250, 80, WINDOW_WIDTH, WINDOW_HEIGHT, true);		//调整窗口显示时的位置,使窗口左上角位于(250,80)处
	ShowWindow(hwnd, nShowCmd);    //调用ShowWindow函数来显示窗口
	UpdateWindow(hwnd);						//对窗口进行更新,就像我们买了新房子要装修一样

	//游戏资源的初始化,若初始化失败,弹出一个消息框,并返回FALSE
	if (!Game_Init(hwnd))
	{
		MessageBox(hwnd, L"资源初始化失败", L"消息窗口", 0); //使用MessageBox函数,创建一个消息窗口
		return FALSE;
	}
	PlaySound(L"GameMedia\\梦幻西游原声-战斗1-森林.wav", NULL, SND_FILENAME | SND_ASYNC | SND_LOOP); //循环播放背景音乐 

	hMenu = LoadMenu(hInstance, MAKEINTRESOURCE(123));
	SetMenu(hwnd, hMenu);

	MSG msg = { 0 };				//定义并初始化msg
	while (msg.message != WM_QUIT)		//使用while循环,如果消息不是WM_QUIT消息,就继续循环
	{
		if (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))   //查看应用程序消息队列,有消息时将队列中的消息派发出去。
		{
			TranslateMessage(&msg);		//将虚拟键消息转换为字符消息
			DispatchMessage(&msg);			//分发一个消息给窗口程序。
		}
		else
		{
			g_tNow = GetTickCount();   //获取当前系统时间
			if (g_tNow - g_tPre >= 60){
				if (nowscen == 1)
					Game_Fight(hwnd);
				else{
					Game_Paint(hwnd);
				}
			}
		}
	}

	UnregisterClass(L"ForTheDreamOfGameDevelop", wndClass.hInstance);  //程序准备结束,注销窗口类
	return 0;
}
Exemplo n.º 16
0
INT_PTR CALLBACK CClassicCopyFile::DialogProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
	if (uMsg==WM_INITDIALOG)
	{
		SetWindowText(hwndDlg,FindTranslation(L"Copy.Title",L"Confirm File Replace"));
		CClassicCopyFile *pThis=(CClassicCopyFile*)lParam;
		wchar_t text[_MAX_PATH*2];
		if (pThis->m_bSystem)
		{
			Sprintf(text,_countof(text),FindTranslation(L"Copy.SubtitleSys",L"This folder already contains a system file named '%s'."),pThis->m_FileName);
			if (GetSettingInt(L"OverwriteAlertLevel")>=1)
				PlaySound(L".Default",NULL,SND_APPLICATION|SND_ALIAS|SND_ASYNC|SND_NODEFAULT|SND_SYSTEM);
		}
		else if (pThis->m_bReadOnly)
		{
			Sprintf(text,_countof(text),FindTranslation(L"Copy.SubtitleRO",L"This folder already contains a read-only file named '%s'."),pThis->m_FileName);
			if (GetSettingInt(L"OverwriteAlertLevel")>=2)
				PlaySound(L".Default",NULL,SND_APPLICATION|SND_ALIAS|SND_ASYNC|SND_NODEFAULT|SND_SYSTEM);
		}
		else
			Sprintf(text,_countof(text),FindTranslation(L"Copy.Subtitle",L"This folder already contains a file named '%s'."),pThis->m_FileName);
		SetDlgItemText(hwndDlg,IDC_STATICFNAME,text);

		// load icon for file conflict (146) from Shell32.dll
		HMODULE hShell32=GetModuleHandle(L"Shell32.dll");
		pThis->m_Icon=LoadIcon(hShell32,MAKEINTRESOURCE(146));
		if (pThis->m_Icon)
			SendDlgItemMessage(hwndDlg,IDC_STATICICON1,STM_SETICON,(LPARAM)pThis->m_Icon,0);

		// set the localized text
		SetDlgItemText(hwndDlg,IDC_STATICPROMPT1,FindTranslation(L"Copy.Prompt1",L"Do you want to replace the existing file:"));
		SetDlgItemText(hwndDlg,IDC_STATICDSTSIZE,pThis->m_DstSize);
		SetDlgItemText(hwndDlg,IDC_STATICDSTTIME,pThis->m_DstTime);
		SetDlgItemText(hwndDlg,IDC_STATICPROMPT2,FindTranslation(L"Copy.Prompt2",L"with this one?"));
		SendDlgItemMessage(hwndDlg,IDC_STATICDSTICON,STM_SETICON,(LPARAM)pThis->m_DstIcon,0);
		SetDlgItemText(hwndDlg,IDC_STATICSRCSIZE,pThis->m_SrcSize);
		SetDlgItemText(hwndDlg,IDC_STATICSRCTIME,pThis->m_SrcTime);
		SendDlgItemMessage(hwndDlg,IDC_STATICSRCICON,STM_SETICON,(LPARAM)pThis->m_SrcIcon,0);
		SetDlgItemText(hwndDlg,IDOK,FindTranslation(L"Copy.Yes",L"&Yes"));
		SetDlgItemText(hwndDlg,IDNO,FindTranslation(L"Copy.No",L"&No"));
		if (GetDlgItem(hwndDlg,IDYES))
			SetDlgItemText(hwndDlg,IDYES,FindTranslation(L"Copy.YesAll",L"Yes to &All"));
		if (GetDlgItem(hwndDlg,IDCANCEL))
			SetDlgItemText(hwndDlg,IDCANCEL,FindTranslation(L"Copy.Cancel",L"Cancel"));
		Sprintf(text,_countof(text),L"<a>%s</a>",FindTranslation(L"Copy.More",L"&More..."));
		SetDlgItemText(hwndDlg,IDC_LINKMORE,text);
		PostMessage(hwndDlg,WM_BRINGFOREGROUND,0,0);
		return TRUE;
	}
	if (uMsg==WM_BRINGFOREGROUND)
	{
		// bring window to front (sometimes on Windows7 it shows up behind Explorer)
		SetForegroundWindow(hwndDlg);
		return TRUE;
	}
	if (uMsg==WM_COMMAND && (wParam==IDOK || wParam==IDYES || wParam==IDNO || wParam==IDCANCEL))
	{
		EndDialog(hwndDlg,wParam);
		return TRUE;
	}
	if (uMsg==WM_NOTIFY)
	{
		NMHDR *pHdr=(NMHDR*)lParam;
		if (pHdr->idFrom==IDC_LINKMORE && (pHdr->code==NM_CLICK || pHdr->code==NM_RETURN))
		{
			EndDialog(hwndDlg,IDC_LINKMORE);
			return TRUE;
		}
	}
	return FALSE;
}
Exemplo n.º 17
0
bool COptionsWnd::GeneralOnStopFile()
{
	// Остановим проигрывание музыки
	PlaySound(NULL, NULL, 0);
	return true;
}
Exemplo n.º 18
0
void UpdateDrawOneFrame(void)
{
    // Update
    //----------------------------------------------------------------------------------
    if (!onTransition)
    {
        switch(currentScreen) 
        {
            case LOADING: 
            {
                // Update LOADING screen variables
                framesCounter++;    // Count frames

                if ((loadBarWidth < loadBarMaxWidth) && ((framesCounter%30) == 0)) loadBarWidth++;

                if (IsKeyDown(KEY_SPACE) && (loadBarWidth < loadBarMaxWidth)) loadBarWidth += 4;

                if (IsKeyPressed(KEY_ENTER) && (loadBarWidth >= loadBarMaxWidth)) TransitionToScreen(LOGO);

            } break;
            case LOGO:
            {
                // Update LOGO screen variables
                if (logoScreenState == 0)                 // State 0: Small box blinking
                {
                    framesCounter++;

                    if (framesCounter == 120)
                    {
                        logoScreenState = 1;
                        framesCounter = 0;      // Reset counter... will be used later...
                    }
                }
                else if (logoScreenState == 1)            // State 1: Top and left bars growing
                {
                    topSideRecWidth += 4;
                    leftSideRecHeight += 4;

                    if (topSideRecWidth == 256) logoScreenState = 2;
                }
                else if (logoScreenState == 2)            // State 2: Bottom and right bars growing
                {
                    bottomSideRecWidth += 4;
                    rightSideRecHeight += 4;

                    if (bottomSideRecWidth == 256)
                    {
                        lettersCounter = 0;
                        for (int i = 0; i < strlen(msgBuffer); i++) msgBuffer[i] = ' ';

                        logoScreenState = 3;
                    }
                }
                else if (logoScreenState == 3)            // State 3: Letters appearing (one by one)
                {
                    framesCounter++;

                    // Every 12 frames, one more letter!
                    if ((framesCounter%12) == 0) raylibLettersCount++;

                    switch (raylibLettersCount)
                    {
                        case 1: raylib[0] = 'r'; break;
                        case 2: raylib[1] = 'a'; break;
                        case 3: raylib[2] = 'y'; break;
                        case 4: raylib[3] = 'l'; break;
                        case 5: raylib[4] = 'i'; break;
                        case 6: raylib[5] = 'b'; break;
                        default: break;
                    }

                    if (raylibLettersCount >= 10)
                    {
                        // Write raylib description messages
                        if ((framesCounter%2) == 0) lettersCounter++;

                        if (!msgLogoADone)
                        {
                            if (lettersCounter <= strlen(msgLogoA)) strncpy(msgBuffer, msgLogoA, lettersCounter);
                            else
                            {
                                for (int i = 0; i < strlen(msgBuffer); i++) msgBuffer[i] = ' ';

                                lettersCounter = 0;
                                msgLogoADone = true;
                            }
                        }
                        else if (!msgLogoBDone)
                        {
                            if (lettersCounter <= strlen(msgLogoB)) strncpy(msgBuffer, msgLogoB, lettersCounter);
                            else
                            {
                                msgLogoBDone = true;
                                framesCounter = 0;
                            }
                        }
                    }
                }

                // Press enter to change to MODULES screen
                if (IsKeyPressed(KEY_ENTER) && msgLogoBDone) TransitionToScreen(MODULES);
                else if (IsKeyPressed(KEY_BACKSPACE)) TransitionToScreen(LOGO);

            } break;
            case MODULES:
            {
                // Update MODULES screen variables here!
                framesCounter++;

                if (IsKeyPressed(KEY_RIGHT) && (selectedModule < 5))
                {
                    selectedModule++;
                    framesCounter = 0;
                }
                else if (IsKeyPressed(KEY_LEFT) && (selectedModule > 0))
                {
                    selectedModule--;
                    framesCounter = 0;
                }

                if (selectedModule == CORE)
                {
                    if ((framesCounter > 60) && (windowOffset < 40))
                    {
                        windowOffset++;
                        ballPosition.x++;
                        ballPosition.y++;
                    }

                    if (framesCounter > 140)
                    {
                        if (IsKeyDown('A')) ballPosition.x -= 5;
                        if (IsKeyDown('D')) ballPosition.x += 5;
                        if (IsKeyDown('W')) ballPosition.y -= 5;
                        if (IsKeyDown('S')) ballPosition.y += 5;

                        if (IsKeyPressed('1')) coreWindow = 1;
                        if (IsKeyPressed('2')) coreWindow = 2;
                        if (IsKeyPressed('3')) coreWindow = 3;
                        if (IsKeyPressed('4')) coreWindow = 4;
                    }
                }

                if (selectedModule == TEXTURES) scaleFactor = (sinf(2*PI/240*framesCounter) + 1.0f)/2;

                if (selectedModule == AUDIO)
                {
                    if (IsKeyPressed(KEY_SPACE) && !MusicIsPlaying()) PlayMusicStream("resources/audio/guitar_noodling.ogg");         // Play music stream

                    if (IsKeyPressed('S'))
                    {
                        StopMusicStream();
                        timePlayed = 0.0f;

                        for (int i = 0; i < MAX_BALLS; i++)
                        {
                            soundBallsPosition[i] = (Vector2){ 650 + 560/2 + GetRandomValue(-280, 280), 220 + 200 + GetRandomValue(-200, 200) };
                            soundBallsColor[i] = (Color){ GetRandomValue(0, 255), GetRandomValue(0, 255), GetRandomValue(0, 255), 255 };
                            soundBallsRadius[i] = GetRandomValue(2, 50);
                            soundBallsAlpha[i] = 1.0f;

                            soundBallsActive[i] = false;
                        }
                    }

                    if (MusicIsPlaying())
                    {
                        timePlayed = GetMusicTimePlayed() / GetMusicTimeLength() * 100 * 4;

                        if ((framesCounter%10) == 0)
                        {
                            for (int i = 0; i < MAX_BALLS; i++)
                            {
                                if (!soundBallsActive[i])
                                {
                                    soundBallsActive[i] = true;
                                    break;
                                }
                            }
                        }

                        for (int i = 0; i < MAX_BALLS; i++)
                        {
                            if (soundBallsActive[i]) soundBallsAlpha[i] -= 0.005f;

                            if (soundBallsAlpha[i] <= 0)
                            {
                                soundBallsActive[i] = false;

                                // Reset ball random
                                soundBallsPosition[i] = (Vector2){ 650 + 560/2 + GetRandomValue(-280, 280), 220 + 200 + GetRandomValue(-200, 200) };
                                soundBallsColor[i] = (Color){ GetRandomValue(0, 255), GetRandomValue(0, 255), GetRandomValue(0, 255), 255 };
                                soundBallsRadius[i] = GetRandomValue(2, 60);
                                soundBallsAlpha[i] = 1.0f;
                            }
                        }
                    }

                    if (IsKeyPressed('N')) PlaySound(fxWav);
                    //if (IsKeyPressed('M')) PlaySound(fxOgg);
                }

                // Press enter to change to ENDING screen
                if (IsKeyPressed(KEY_ENTER)) TransitionToScreen(ENDING);
                else if (IsKeyPressed(KEY_BACKSPACE)) TransitionToScreen(LOGO);

            } break;
            case PONG:
            {
                // Update SECRET screen variables here!
                framesCounter++;

                if (IsKeyPressed('P')) pongPaused = !pongPaused;
                
                if (!pongPaused)
                {
                    pongBallPosition.x += pongBallSpeed.x;
                    pongBallPosition.y += pongBallSpeed.y;

                    if ((pongBallPosition.x >= screenWidth - 5) || (pongBallPosition.x <= 5)) pongBallSpeed.x *= -1;
                    if ((pongBallPosition.y >= screenHeight - 5) || (pongBallPosition.y <= 5)) pongBallSpeed.y *= -1;

                    if (IsKeyDown(KEY_UP) || IsKeyDown('W'))
                    {
                        pongPlayerRec.y -= 5;
                        pongAutoMode = false;
                        pongAutoCounter = 180;
                    }
                    else if (IsKeyDown(KEY_DOWN) || IsKeyDown('S'))
                    {
                        pongPlayerRec.y += 5;
                        pongAutoMode = false;
                        pongAutoCounter = 180;
                    }
                    else if (pongAutoCounter > 0)
                    {
                        pongAutoCounter--;
                        
                        if (pongAutoCounter == 0) pongAutoMode = true;
                    }

                    if ((pongBallPosition.x < 600) && pongAutoMode)
                    {
                        if (pongBallPosition.y > (pongPlayerRec.y + pongPlayerRec.height/2)) pongPlayerRec.y += 5;
                        else if (pongBallPosition.y < (pongPlayerRec.y + pongPlayerRec.height/2)) pongPlayerRec.y -= 5;
                    }

                    if (pongPlayerRec.y <= 0) pongPlayerRec.y = 0;
                    else if ((pongPlayerRec.y + pongPlayerRec.height) >= screenHeight) pongPlayerRec.y = screenHeight - pongPlayerRec.height;
                    
                    if (pongBallPosition.x > screenWidth - 600)
                    {
                        if (pongBallPosition.y > (pongEnemyRec.y + pongEnemyRec.height/2)) pongEnemyRec.y += 5;
                        else if (pongBallPosition.y < (pongEnemyRec.y + pongEnemyRec.height/2)) pongEnemyRec.y -= 5;

                        if (pongEnemyRec.y <= 0) pongEnemyRec.y = 0;
                        else if ((pongEnemyRec.y + pongEnemyRec.height) >= screenHeight) pongEnemyRec.y = screenHeight - pongEnemyRec.height;
                    }

                    if ((CheckCollisionCircleRec(pongBallPosition, 10, pongPlayerRec)) || (CheckCollisionCircleRec(pongBallPosition, 10, pongEnemyRec))) pongBallSpeed.x *= -1;
                    
                    if (pongBallPosition.x >= screenWidth - 5) pongScorePlayer++;
                    else if (pongBallPosition.x <= 5) pongScoreEnemy++;
                }

                // Press enter to move back to MODULES screen
                if (IsKeyPressed(KEY_ENTER)) TransitionToScreen(ENDING);
                if (IsKeyPressed(KEY_BACKSPACE)) TransitionToScreen(ENDING);
            } break;
            case ENDING:
            {
                // Update ENDING screen
                framesCounter++;

                // Press enter to move back to MODULES screen
                if (IsKeyPressed(KEY_ENTER)) TransitionToScreen(PONG);
                if (IsKeyPressed(KEY_BACKSPACE)) TransitionToScreen(MODULES);

            } break;
            default: break;
        }

        if ((currentScreen != LOADING) && (timeCounter < totalTime)) timeCounter++;
    }
    else UpdateTransition(); // Update transition (fade-in, fade-out)
    //----------------------------------------------------------------------------------

    // Draw
    //----------------------------------------------------------------------------------
    BeginDrawing();

        ClearBackground(RAYWHITE);

        switch(currentScreen)
        {
            case LOADING:
            {
                // Draw LOADING screen
                if ((loadBarWidth < loadBarMaxWidth) && ((framesCounter/40)%2)) DrawText(msgLoading, 360, 240, 40, DARKGRAY);

                DrawRectangle(360 - 4, 300 - 4, loadBarMaxWidth + 8, 60 + 8, LIGHTGRAY);
                DrawRectangle(360, 300, loadBarWidth - 1, 60, DARKGRAY);
                DrawRectangleLines(360 - 4, 300 - 5, loadBarMaxWidth + 8, 60 + 8, DARKGRAY);

                if (loadBarWidth >= loadBarMaxWidth)
                {
                    //DrawText(msgLoading, 360, 240, 40, DARKGRAY);
                    if ((framesCounter/30)%2) DrawText(msgPressEnter, screenWidth/2 - MeasureText(msgPressEnter, 40)/2 + 20, 400, 40, DARKGRAY);
                }
                else DrawText("PRESS SPACE to ACCELERATE LOADING! ;)", screenWidth/2 - 200, 400, 20, LIGHTGRAY);

            } break;
            case LOGO:
            {
                // Draw LOGO screen
                if (logoScreenState == 0)
                {
                    if ((framesCounter/15)%2) DrawRectangle(logoPositionX, logoPositionY - 60, 16, 16, BLACK);
                }
                else if (logoScreenState == 1)
                {
                    DrawRectangle(logoPositionX, logoPositionY - 60, topSideRecWidth, 16, BLACK);
                    DrawRectangle(logoPositionX, logoPositionY - 60, 16, leftSideRecHeight, BLACK);
                }
                else if (logoScreenState == 2)
                {
                    DrawRectangle(logoPositionX, logoPositionY - 60, topSideRecWidth, 16, BLACK);
                    DrawRectangle(logoPositionX, logoPositionY - 60, 16, leftSideRecHeight, BLACK);

                    DrawRectangle(logoPositionX + 240, logoPositionY - 60, 16, rightSideRecHeight, BLACK);
                    DrawRectangle(logoPositionX, logoPositionY + 240 - 60, bottomSideRecWidth, 16, BLACK);
                }
                else if (logoScreenState == 3)
                {
                    DrawRectangle(logoPositionX, logoPositionY - 60, topSideRecWidth, 16, BLACK);
                    DrawRectangle(logoPositionX, logoPositionY + 16 - 60, 16, leftSideRecHeight - 32, BLACK);

                    DrawRectangle(logoPositionX + 240, logoPositionY + 16 - 60, 16, rightSideRecHeight - 32, BLACK);
                    DrawRectangle(logoPositionX, logoPositionY + 240 - 60, bottomSideRecWidth, 16, BLACK);

                    DrawRectangle(screenWidth/2 - 112, screenHeight/2 - 112 - 60, 224, 224, RAYWHITE);

                    DrawText(raylib, screenWidth/2 - 44, screenHeight/2 + 48 - 60, 50, BLACK);

                    if (!msgLogoADone) DrawText(msgBuffer, screenWidth/2 - MeasureText(msgLogoA, 30)/2, 460, 30, GRAY);
                    else
                    {
                        DrawText(msgLogoA, screenWidth/2 - MeasureText(msgLogoA, 30)/2, 460, 30, GRAY);

                        if (!msgLogoBDone) DrawText(msgBuffer, screenWidth/2 - MeasureText(msgLogoB, 30)/2, 510, 30, GRAY);
                        else
                        {
                            DrawText(msgLogoB, screenWidth/2 - MeasureText(msgLogoA, 30)/2, 510, 30, GRAY);

                            if ((framesCounter > 90) && ((framesCounter/30)%2)) DrawText("PRESS ENTER to CONTINUE", 930, 650, 20, GRAY);
                        }
                    }
                }
            } break;
            case MODULES:
            {
                // Draw MODULES screen
                DrawTexture(raylibLogoB, 40, 40, WHITE);
                DrawText("raylib is composed of 6 main modules:", 128 + 40 + 30, 50, 20, GRAY);

                if (framesCounter < 120)
                {
                    if (((framesCounter/30)%2) == 0) DrawRectangle(128 + 40 + 30 - 4 + 175*selectedModule, 128 + 40 - 70 - 8 - 4, 158, 78, RED);
                }
                else DrawRectangle(128 + 40 + 30 - 4 + 175*selectedModule, 128 + 40 - 70 - 8 - 4, 158, 78, RED);
                
                if (selectedModule != AUDIO)
                {
                    DrawTriangle((Vector2){950 - 40, 685 - 10}, (Vector2){950 - 60, 685}, (Vector2){950 - 40, 685 + 10}, GRAY);
                    DrawTriangle((Vector2){950 - 30, 685 - 10}, (Vector2){950 - 30, 685 + 10}, (Vector2){950 - 10, 685}, GRAY);
                    DrawText("PRESS RIGHT or LEFT to EXPLORE MODULES", 960, 680, 10, GRAY);
                }

                switch (selectedModule)
                {
                    case CORE:
                    {
                        DrawText("This module give you functions to:", 48, 200, 10, GetColor(0x5c5a5aff));
                    
                        DrawTextEx(fontRomulus, "Open-Close Window", (Vector2){ 48, 230 }, GetFontBaseSize(fontRomulus)*2, 4, GetColor(0x5c5a5aff));
                        DrawTextEx(fontRomulus, "Manage Drawing Area", (Vector2){ 48, 260 }, GetFontBaseSize(fontRomulus)*2, 4, GetColor(0x5c5a5aff));
                        DrawTextEx(fontRomulus, "Manage Inputs", (Vector2){ 48, 290 }, GetFontBaseSize(fontRomulus)*2, 4, GetColor(0x5c5a5aff));
                        DrawTextEx(fontRomulus, "Manage Timming", (Vector2){ 48, 320 }, GetFontBaseSize(fontRomulus)*2, 4, GetColor(0x5c5a5aff));
                        DrawTextEx(fontRomulus, "Auxiliar Functions", (Vector2){ 48, 350 }, GetFontBaseSize(fontRomulus)*2, 4, GetColor(0x5c5a5aff));

                        switch (coreWindow)
                        {
                            case 1: DrawTexture(raylibWindow, 520, 220, WHITE); break;
                            case 2: DrawTextureEx(raylibWindow01, (Vector2){ 450, 220 - 45 }, 0.0f, 4.0f, WHITE); break;
                            case 3: DrawTextureEx(raylibWindow02, (Vector2){ 430, 220 - 40 }, 0.0f, 4.0f, WHITE); break;
                            case 4: DrawTextureEx(raylibWindow03, (Vector2){ 470, 220 - 65 }, 0.0f, 4.0f, WHITE); break;
                            default: DrawTexture(raylibWindow, 520, 220, WHITE); break;
                        }
                        
                        if (framesCounter > 140) DrawText("Check the possible windows raylib can run on. PRESS KEY: 1, 2, 3 or 4", 520 + 8 + windowOffset + 160, 220 + windowOffset + 10, 10, LIGHTGRAY);                        
                        
                        DrawText("Compile raylib C code for the folowing platforms:", 48, 400, 10, MAROON);
                        
                        DrawTextureRec(platforms, (Rectangle){ 0, 0, platforms.width, platforms.height}, (Vector2){ 75, 420 }, WHITE);

                        DrawRectangle(520 + 8 + windowOffset, 220 + 31 + windowOffset, 640, 360, RAYWHITE);
                        DrawRectangleLines(520 + 8 + windowOffset - 1, 220 + 31 + windowOffset - 2, 640 + 2, 360 + 2, GRAY);
                        DrawFPS(520 + 8 + windowOffset + 10, 220 + 31 + windowOffset + 10);
                        
                        DrawRectangle(ballPosition.x - 50, ballPosition.y - 50, 100, 100, Fade(MAROON, 0.5f));
                        DrawRectangleRec(GetCollisionRec((Rectangle){ 520 + 8 + windowOffset - 1, 220 + 31 + windowOffset - 1, 640 + 2, 360 + 2 }, (Rectangle){ (int)ballPosition.x - 50, (int)ballPosition.y - 50, 100, 100 }), MAROON);
                        
                        if (framesCounter > 140)
                        {
                            DrawTextEx(fontMecha, "MOVE ME", (Vector2){ ballPosition.x - 26, ballPosition.y - 20 }, GetFontBaseSize(fontMecha), 2, BLACK);
                            DrawTextEx(fontMecha, "[ W A S D ]", (Vector2){ ballPosition.x - 36, ballPosition.y }, GetFontBaseSize(fontMecha), 2, BLACK);
                        }
                    } break;
                    case SHAPES:
                    {
                        DrawText("This module give you functions to:", 48, 200, 10, GetColor(0xcd5757ff));
                    
                        DrawTextEx(fontRomulus, "Draw Basic Shapes", (Vector2){ 48, 230 }, GetFontBaseSize(fontRomulus)*2, 4, GetColor(0xcd5757ff));
                        DrawTextEx(fontRomulus, "Basic Collision Detection", (Vector2){ 48, 260 }, GetFontBaseSize(fontRomulus)*2, 4, GetColor(0xcd5757ff));

                        DrawCircle(screenWidth/4, 120 + 240, 35, DARKBLUE);
                        DrawCircleGradient(screenWidth/4, 220 + 240, 60, GREEN, SKYBLUE);
                        DrawCircleLines(screenWidth/4, 340 + 240, 80, DARKBLUE);

                        DrawRectangle(screenWidth/4*2 - 110, 100 + 180, 220, 100, LIME);
                        DrawRectangleGradient(screenWidth/4*2 - 90, 170 + 240, 180, 130, MAROON, GOLD);
                        DrawRectangleLines(screenWidth/4*2 - 80, 320 + 240, 160, 80, ORANGE);

                        DrawTriangle((Vector2){screenWidth/4*3, 60 + 220}, (Vector2){screenWidth/4*3 - 60, 160 + 220}, (Vector2){screenWidth/4*3 + 60, 160 + 220}, VIOLET);

                        DrawTriangleLines((Vector2){screenWidth/4*3, 140 + 220}, (Vector2){screenWidth/4*3 - 60, 210 + 260}, (Vector2){screenWidth/4*3 + 60, 210 + 260}, SKYBLUE);

                        DrawPoly((Vector2){screenWidth/4*3, 320 + 240}, 6, 80, 0, BROWN);

                    } break;
                    case TEXTURES:
                    {
                        DrawText("This module give you functions to:", 48, 200, 10, GetColor(0x60815aff));
                    
                        DrawTextEx(fontRomulus, "Load Images and Textures", (Vector2){ 48, 230 }, GetFontBaseSize(fontRomulus)*2, 4, GetColor(0x60815aff));
                        DrawTextEx(fontRomulus, "Draw Textures", (Vector2){ 48, 260 }, GetFontBaseSize(fontRomulus)*2, 4, GetColor(0x60815aff));

                        DrawRectangle(138, 348, 260, 260, GRAY);
                        DrawTexturePro(lena, (Rectangle){ 0, 0, lena.width, lena.height }, (Rectangle){ 140 + 128, 350 + 128, lena.width/2*scaleFactor, lena.height/2*scaleFactor }, (Vector2){ lena.width/4*scaleFactor, lena.height/4*scaleFactor }, 0.0f, WHITE);

                        DrawTexture(lena, 600, 180, Fade(WHITE, 0.3f));
                        DrawTextureRec(lena, (Rectangle){ 225, 240, 155, 50 }, (Vector2){ 600 + 256 - 82 + 50, 180 + 241 }, PINK);

                        DrawTexturePro(mandrill, (Rectangle){ 0, 0, mandrill.width, mandrill.height }, (Rectangle){ screenWidth/2 - 40, 350 + 128, mandrill.width/2, mandrill.height/2 },
                                        (Vector2){ mandrill.width/4, mandrill.height/4 }, framesCounter, GOLD);

                    } break;
                    case TEXT:
                    {
                        DrawText("This module give you functions to:", 48, 200, 10, GetColor(0x377764ff));
                    
                        DrawTextEx(fontRomulus, "Load SpriteFonts", (Vector2){ 48, 230 }, GetFontBaseSize(fontRomulus)*2, 4, GetColor(0x377764ff));
                        DrawTextEx(fontRomulus, "Draw Text", (Vector2){ 48, 260 }, GetFontBaseSize(fontRomulus)*2, 4, GetColor(0x377764ff));
                        DrawTextEx(fontRomulus, "Text Formatting", (Vector2){ 48, 290 }, GetFontBaseSize(fontRomulus)*2, 4, GetColor(0x377764ff));

                        DrawTexture(texAlagard, 60, 360, WHITE);

                        DrawTextEx(fontMechaC, msg1, (Vector2){ 540 + 168, 210 }, GetFontBaseSize(fontMechaC), -3, WHITE);
                        DrawTextEx(fontAlagardC, msg2, (Vector2){ 460 + 140, 260 }, GetFontBaseSize(fontAlagardC), -2, WHITE);
                        DrawTextEx(fontJupiterC, msg3, (Vector2){ 640 + 70, 300 }, GetFontBaseSize(fontJupiterC), 2, WHITE);

                        DrawTextEx(fontAlagard, "It also includes some...", (Vector2){ 650 + 70, 400 }, GetFontBaseSize(fontAlagard)*2, 2, MAROON);
                        DrawTextEx(fontPixelplay, "...free fonts in rBMF format...", (Vector2){ 705 - 26, 450 }, GetFontBaseSize(fontPixelplay)*2, 4, ORANGE);
                        DrawTextEx(fontMecha, "...to be used even in...", (Vector2){ 700 + 40, 500 }, GetFontBaseSize(fontMecha)*2, 4, DARKGREEN);
                        DrawTextEx(fontSetback, "...comercial projects...", (Vector2){ 710, 550 }, GetFontBaseSize(fontSetback)*2, 4, DARKBLUE);
                        DrawTextEx(fontRomulus, "...completely for free!", (Vector2){ 710 + 17, 600 }, GetFontBaseSize(fontRomulus)*2, 3, DARKPURPLE);
                        
                        DrawText("This is a custom font spritesheet, raylib can load it automatically!", 228, 360 + 295, 10, GRAY);

                    } break;
                    case MODELS:
                    {
                        DrawText("This module give you functions to:", 48, 200, 10, GetColor(0x417794ff));
                        
                        DrawTextEx(fontRomulus, "Draw Geometric Models", (Vector2){ 48, 230 }, GetFontBaseSize(fontRomulus)*2, 4, GetColor(0x417794ff));
                        DrawTextEx(fontRomulus, "Load 3D Models", (Vector2){ 48, 260 }, GetFontBaseSize(fontRomulus)*2, 4, GetColor(0x417794ff));
                        DrawTextEx(fontRomulus, "Draw 3D Models", (Vector2){ 48, 290 }, GetFontBaseSize(fontRomulus)*2, 4, GetColor(0x417794ff));

                        Begin3dMode(camera);

                            DrawCube((Vector3){-4, 0, 2}, 2, 5, 2, RED);
                            DrawCubeWires((Vector3){-4, 0, 2}, 2, 5, 2, GOLD);
                            DrawCubeWires((Vector3){-4, 0, -2}, 3, 6, 2, MAROON);

                            DrawSphere((Vector3){-1, 0, -2}, 1, GREEN);
                            DrawSphereWires((Vector3){1, 0, 2}, 2, 16, 16, LIME);

                            DrawCylinder((Vector3){4, 0, -2}, 1, 2, 3, 4, SKYBLUE);
                            DrawCylinderWires((Vector3){4, 0, -2}, 1, 2, 3, 4, DARKBLUE);
                            DrawCylinderWires((Vector3){4.5, -1, 2}, 1, 1, 2, 6, BROWN);

                            DrawCylinder((Vector3){1, 0, -4}, 0, 1.5, 3, 8, GOLD);
                            DrawCylinderWires((Vector3){1, 0, -4}, 0, 1.5, 3, 8, PINK);

                            DrawModelEx(cat, (Vector3){ 8.0f, 0.0f, 2.0f }, (Vector3){ 0.0f, 0.5f*framesCounter, 0.0f }, (Vector3){ 0.1f, 0.1f, 0.1f }, WHITE);
                            DrawGizmo((Vector3){ 8.0f, 0.0f, 2.0f });

                            DrawGrid(10.0, 1.0);        // Draw a grid

                        End3dMode();

                        DrawFPS(900, 220);

                    } break;
                    case AUDIO:
                    {
                        DrawText("This module give you functions to:", 48, 200, 10, GetColor(0x8c7539ff));
                        
                        DrawTextEx(fontRomulus, "Load and Play Sounds", (Vector2){ 48, 230 }, GetFontBaseSize(fontRomulus)*2, 4, GetColor(0x8c7539ff));
                        DrawTextEx(fontRomulus, "Play Music (streaming)", (Vector2){ 48, 260 }, GetFontBaseSize(fontRomulus)*2, 4, GetColor(0x8c7539ff));

                        DrawText("PRESS SPACE to START PLAYING MUSIC", 135, 350, 20, GRAY);
                        DrawRectangle(150, 390, 400, 12, LIGHTGRAY);
                        DrawRectangle(150, 390, (int)timePlayed, 12, MAROON);

                        if (MusicIsPlaying())
                        {
                            DrawText("PRESS 'S' to STOP PLAYING MUSIC", 165, 425, 20, GRAY);

                            for (int i = 0; i < MAX_BALLS; i++)
                            {
                                if (soundBallsActive[i]) DrawPoly(soundBallsPosition[i], 18, soundBallsRadius[i], 0.0f, Fade(soundBallsColor[i], soundBallsAlpha[i]));
                            }
                        }

                        DrawText("PRESS 'N' to PLAY a SOUND", 200, 540, 20, VIOLET);

                        if ((framesCounter/30)%2) DrawText("PRESS ENTER to CONTINUE", 930, 650, 20, GRAY);

                    } break;
                    default: break;
                }

                // Draw modules menu
                DrawRectangle(128 + 40 + 30, 128 + 40 - 70 - 8, 150, 70, GetColor(0x898888ff));
                DrawRectangle(128 + 40 + 30 + 8, 128 + 40 - 70, 150 - 16, 70 - 16, GetColor(0xe1e1e1ff));
                DrawText("CORE", 128 + 40 + 30 + 8 + 38, 128 + 40 - 50, 20, GetColor(0x5c5a5aff));

                DrawRectangle(128 + 40 + 30 + 175, 128 + 40 - 70 - 8, 150, 70, GetColor(0xe66666ff));
                DrawRectangle(128 + 40 + 30 + 8 + 175, 128 + 40 - 70, 150 - 16, 70 - 16, GetColor(0xf0d6d6ff));
                DrawText("SHAPES", 128 + 40 + 30 + 8 + 175 + 28, 128 + 40 - 50, 20, GetColor(0xcd5757ff));

                DrawRectangle(128 + 40 + 30 + 175*2, 128 + 40 - 70 - 8, 150, 70, GetColor(0x75a06dff));
                DrawRectangle(128 + 40 + 30 + 8 + 175*2, 128 + 40 - 70, 150 - 16, 70 - 16, GetColor(0xc8eabfff));
                DrawText("TEXTURES", 128 + 40 + 30 + 175*2 + 8 + 9, 128 + 40 - 50, 20, GetColor(0x60815aff));

                DrawRectangle(128 + 40 + 30 + 175*3, 128 + 40 - 70 - 8, 150, 70, GetColor(0x52b296ff));
                DrawRectangle(128 + 40 + 30 + 8 + 175*3, 128 + 40 - 70, 150 - 16, 70 - 16, GetColor(0xbef0ddff));
                DrawText("TEXT", 128 + 40 + 30 + 8 + 175*3 + 38, 128 + 40 - 50, 20, GetColor(0x377764ff));

                DrawRectangle(128 + 40 + 30 + 175*4, 128 + 40 - 70 - 8, 150, 70, GetColor(0x5d9cbdff));
                DrawRectangle(128 + 40 + 30 + 8 + 175*4, 128 + 40 - 70, 150 - 16, 70 - 16, GetColor(0xbedce8ff));
                DrawText("MODELS", 128 + 40 + 30 + 8 + 175*4 + 28, 128 + 40 - 50, 20, GetColor(0x417794ff));

                DrawRectangle(128 + 40 + 30 + 175*5, 128 + 40 - 70 - 8, 150, 70, GetColor(0xd3b157ff));
                DrawRectangle(128 + 40 + 30 + 8 + 175*5, 128 + 40 - 70, 150 - 16, 70 - 16, GetColor(0xebddaeff));
                DrawText("AUDIO", 128 + 40 + 30 + 8 + 175*5 + 36, 128 + 40 - 50, 20, GetColor(0x8c7539ff));

            } break;
            case ENDING:
            {
                // Draw ENDING screen
                DrawTextEx(fontAlagard, "LEARN VIDEOGAMES PROGRAMMING", (Vector2){ screenWidth/2 - MeasureTextEx(fontAlagard, "LEARN VIDEOGAMES PROGRAMMING", GetFontBaseSize(fontAlagard)*4, 4).x/2, 80 }, GetFontBaseSize(fontAlagard)*4, 4, MAROON);

                DrawTexture(raylibLogoA, logoPositionX, logoPositionY - 40, WHITE);

                DrawText(msgWeb, screenWidth/2 - MeasureText(msgWeb, 40)/2, 470, 40, DARKGRAY);

                if (framesCounter > 60) DrawText(msgCredits, screenWidth/2 - MeasureText(msgCredits, 30)/2, 550, 30, GRAY);

                if (framesCounter > 120) if ((framesCounter/30)%2) DrawText("PRESS ENTER to CONTINUE", screenWidth/2 - MeasureText("PRESS ENTER to CONTINUE", 20)/2, 640, 20, LIGHTGRAY);

            } break;
            case PONG:
            {
                // Pong
                DrawCircleV(pongBallPosition, 10, LIGHTGRAY);
                DrawRectangleRec(pongPlayerRec, GRAY);
                DrawRectangleRec(pongEnemyRec, GRAY);

                DrawText(FormatText("%02i", pongScorePlayer), 150, 10, 80, LIGHTGRAY);
                DrawText(FormatText("%02i", pongScoreEnemy), screenWidth - MeasureText("00", 80) - 150, 10, 80, LIGHTGRAY);

                if (pongPaused) if ((framesCounter/30)%2) DrawText("GAME PAUSED [P]", screenWidth/2 - 100, 40, 20, MAROON);
            } break;
            default: break;
        }

        if (currentScreen != LOADING) DrawRectangle(0, screenHeight - 10, ((float)timeCounter/(float)totalTime)*screenWidth, 10, LIGHTGRAY);

        if (onTransition) DrawTransition();

    EndDrawing();
    //----------------------------------------------------------------------------------
}
Exemplo n.º 19
0
void keyboard_handler(int keycode, int press)
{
	UpdateKeys(keycode, press);

	if (RSJ) {
#if 0	
		if (press == 0) {
			int i;
			
			for (i = 0; i < CheatCount; i++) {
				char *key = XKeysymToString(keycode);
				if (key == NULL)
					break;
				if (strlen(key) != 1)
					break;
				if (CheatCodes[i].code[CheatIndex] == toupper(key[0])) {
					CheatIndex++;
					if (CheatCodes[i].code[CheatIndex] == 0) {
						PlaySound(SND_BONUS);
						switch (i) {
						case 0:
						case 4:
							GiveKey(0);
							GiveKey(1);
							gamestate.godmode = TRUE;
							break;
						case 1:
							gamestate.godmode^=TRUE;
							break;
						case 2:
							gamestate.machinegun = TRUE;
							gamestate.chaingun = TRUE;
							gamestate.flamethrower = TRUE;
							gamestate.missile = TRUE;
							GiveAmmo(gamestate.maxammo);
							GiveGas(99);
							GiveMissile(99);
							break;
						case 3:
							gamestate.maxammo = 999;
							GiveAmmo(999);
							break;
						case 5:
							GiveKey(0);
							GiveKey(1);
							break;
						case 6:
							playstate=EX_WARPED;
							nextmap = gamestate.mapon+1;
							if (MapListPtr->MaxMap<=nextmap) 
								nextmap = 0;
							break;
						case 7:
							ShowPush ^= TRUE;
							break;
						}
						CheatIndex = 0;
					}
					break;
				} 
			}	
			if (i == CheatCount) 
				CheatIndex = 0;
		}
#endif
				
		joystick1 = 0;

#if 0		
		if (press == 0) {
			switch(keycode) {
			case XK_1:
				gamestate.pendingweapon = WP_KNIFE;
				break;
			case XK_2:
				if (gamestate.ammo) {
					gamestate.pendingweapon = WP_PISTOL;
				}	
				break;
			case XK_3:
				if (gamestate.ammo && gamestate.machinegun) {
					gamestate.pendingweapon = WP_MACHINEGUN;
				}
				break;
			case XK_4:
				if (gamestate.ammo && gamestate.chaingun) {
					gamestate.pendingweapon = WP_CHAINGUN;
				}
				break;
			case XK_5:
				if (gamestate.gas && gamestate.flamethrower) {
					gamestate.pendingweapon = WP_FLAMETHROWER;
				}
				break;
			case XK_6:
				if (gamestate.missiles && gamestate.missile) {
					gamestate.pendingweapon = WP_MISSILE;
				}
				break;
			case XK_period:
			case XK_slash:
				joystick1 = JOYPAD_START;
				break;
			case XK_Escape:
				Quit(NULL); /* fast way out */
			}
		}
#endif		
		if (keys[SC_CURSORUPLEFT])
			joystick1 |= (JOYPAD_UP|JOYPAD_LFT);
		if (keys[SC_CURSORUP])
			joystick1 |= JOYPAD_UP;
		if (keys[SC_CURSORUPRIGHT])
			joystick1 |= (JOYPAD_UP|JOYPAD_RGT);
		if (keys[SC_CURSORRIGHT])
			joystick1 |= JOYPAD_RGT;
		if (keys[SC_CURSORDOWNRIGHT])
			joystick1 |= (JOYPAD_DN|JOYPAD_RGT);
		if (keys[SC_CURSORDOWN])
			joystick1 |= JOYPAD_DN;
		if (keys[SC_CURSORDOWNLEFT])
			joystick1 |= (JOYPAD_DN|JOYPAD_LFT);
		if (keys[SC_CURSORLEFT])
			joystick1 |= JOYPAD_LFT;	
		
		if (keys[SC_CURSORBLOCKLEFT]) 
			joystick1 |= JOYPAD_LFT;
		if (keys[SC_CURSORBLOCKRIGHT])
			joystick1 |= JOYPAD_RGT;
		if (keys[SC_CURSORBLOCKUP])
			joystick1 |= JOYPAD_UP;
		if (keys[SC_CURSORBLOCKDOWN])
			joystick1 |= JOYPAD_DN;
		
		if (keys[SC_KEYPADENTER])
			joystick1 |= JOYPAD_A;	
		if (keys[SC_ENTER])
			joystick1 |= JOYPAD_A;
		if (keys[SC_SPACE])
			joystick1 |= JOYPAD_A;
		
		if (keys[SC_LEFTALT]) 
			joystick1 |= JOYPAD_TR;
		if (keys[SC_RIGHTALT])
			joystick1 |= JOYPAD_TR;
			
		if (keys[SC_LEFTCONTROL])
			joystick1 |= JOYPAD_B;
		if (keys[SC_RIGHTCONTROL])
			joystick1 |= JOYPAD_B;
		
		if (keys[SC_LEFTSHIFT])
			joystick1 |= (JOYPAD_X|JOYPAD_Y);
		if (keys[SC_RIGHTSHIFT])
			joystick1 |= (JOYPAD_X|JOYPAD_Y);
	}
	
	if ((joystick1 & (JOYPAD_LFT|JOYPAD_RGT)) == (JOYPAD_LFT|JOYPAD_RGT))
		joystick1 &= ~(JOYPAD_LFT|JOYPAD_RGT);
	if ((joystick1 & (JOYPAD_UP|JOYPAD_DN)) == (JOYPAD_UP|JOYPAD_DN))
		joystick1 &= ~(JOYPAD_UP|JOYPAD_DN);
		
	if (joystick1 & JOYPAD_TR) {
		if (joystick1 & JOYPAD_LFT) {
			joystick1 = (joystick1 & ~(JOYPAD_TR|JOYPAD_LFT)) | JOYPAD_TL;
		} else if (joystick1 & JOYPAD_RGT) {
			joystick1 = joystick1 & ~JOYPAD_RGT;
		} else {
			joystick1 &= ~JOYPAD_TR;
		}
	}
							
}
Exemplo n.º 20
0
// MEMBER FUNCTIONS
void Sound::introMusic()
{
	PlaySound("possession.wav", NULL, SND_LOOP | SND_ASYNC); // INTRO MUSIC
}
Exemplo n.º 21
0
AREXPORT void ArSoundPlayer::stopPlaying()
{
  PlaySound(NULL, NULL, NULL);
}
Exemplo n.º 22
0
void Sound::backGroundMusic()
{
	PlaySound("Paranoia.wav", NULL, SND_LOOP | SND_ASYNC); // BACKGROUND MUSIC
}
Exemplo n.º 23
0
ManagedSoundWeak AudioManager::PlaySound(int soundID, const sf::Vector3f &pos)
	{
	return PlaySound(soundID, pos, 100.0f, 1.0f, 1.0f, 1.0f);
	}
Exemplo n.º 24
0
void Sound::outroMusic()
{
	PlaySound("trickOrTreat.wav", NULL, SND_LOOP | SND_ASYNC); // OUTRO MUSIC
}
task main () {
  int X = 0;

  memset(data, 0, sizeof(data));
  TIRresetSensor(TIR);
  nxtDisplayCenteredTextLine(0, "Dexter Industries");
  nxtDisplayCenteredTextLine(1, "Thermal Infrared");
  nxtDisplayCenteredTextLine(3, "Test 1");
  nxtDisplayCenteredTextLine(5, "Connect sensor");
  nxtDisplayCenteredTextLine(6, "to S1");
  wait1Msec(2000);

	eraseDisplay();

  // set emissivity for light skin
  TIRsetEmissivity(TIR, TIR_EM_SKIN_LIGHT);

  nMotorEncoderTarget[VERTICAL] = 200;
	motor[VERTICAL] = -20;
	while((nMotorRunState[VERTICAL] != runStateIdle) && (nMotorRunState[VERTICAL] != runStateHoldPosition)) EndTimeSlice();
	nMotorEncoderTarget[HORIZONTAL] = 360;
	motor[HORIZONTAL] = 20;
	while((nMotorRunState[HORIZONTAL] != runStateIdle) && (nMotorRunState[HORIZONTAL] != runStateHoldPosition)) EndTimeSlice();
	wait1Msec(500);
	nMotorEncoder[HORIZONTAL] = 0;
	nMotorEncoder[VERTICAL] = 0;
	PlaySound(soundBeepBeep);
	while(bSoundActive) EndTimeSlice();
  for (int i = 0; i < 80; i++) {
    wait1Msec(500);
    X = 0;
    memset(data, 0, sizeof(data));
	  nMotorEncoderTarget[HORIZONTAL] = 720;
	  motor[HORIZONTAL] = -40;
	  time1[T1] = 0;
	  while((nMotorRunState[HORIZONTAL] != runStateIdle) && (nMotorRunState[HORIZONTAL] != runStateHoldPosition)) {
	    data[X] = TIRreadObjectTemp(TIR);
	    X++;
	    wait1Msec(20);
	  }
    nxtDisplayBigTextLine(1, "X: %d", X);
	  nxtDisplayBigTextLine(3, "T: %d", time1[T1]);
	  nMotorEncoderTarget[VERTICAL] = 5;
	  motor[VERTICAL] = 20;

	  nMotorEncoderTarget[HORIZONTAL] = 720;
	  motor[HORIZONTAL] = 60;

	  for (int j = 0; j < 200; j++) {
	    if (data[j] != 0) {
	      writeDebugStream("%3.2f,", data[j]);
	      wait1Msec(5);
	    }
	  }
	  writeDebugStreamLine("");

	  while((nMotorRunState[HORIZONTAL] != runStateIdle) && (nMotorRunState[HORIZONTAL] != runStateHoldPosition))
	    EndTimeSlice();
	}
  bFloatDuringInactiveMotorPWM = true;
  wait1Msec(10);
}
Exemplo n.º 26
0
int main()
{
  SoundInit();
  printf("start of pt_test\n");

  printf("PlayTone(TONE_A4, MS_500)\n");
  PlayTone(TONE_A4, MS_500);
  Wait(SEC_1);

  printf("PlaySound(SOUND_FAST_UP)\n");
  PlaySound(SOUND_FAST_UP);
  Wait(SEC_1);

  printf("PlayTones(sweepUp)\n");
  PlayTones(sweepUp);
  Wait(SEC_1);

  printf("PlayFile('/media/card/piano.rmd')\n");
  PlayFile("/media/card/piano.rmd");
  Wait(SEC_2);

  printf("PlayFile('/media/card/1.rsf')\n");
  PlayFile("/media/card/1.rsf");
  Wait(SEC_2);

  printf("PlayFile('/media/card/2.rsf') clapping\n");
  PlayFile("/media/card/2.rsf");
  Wait(SEC_2);

  printf("PlayFile('/media/card/3.rsf') eating\n");
  PlayFile("/media/card/3.rsf");
  Wait(SEC_2);

  printf("PlayFile('/media/card/4.rsf') laugh\n");
  PlayFile("/media/card/4.rsf");
  Wait(SEC_2);

  printf("PlayFile('/media/card/5.rsf') growl\n");
  PlayFile("/media/card/5.rsf");
  Wait(SEC_2);

  printf("PlayFile('/media/card/6.rsf') whine\n");
  PlayFile("/media/card/6.rsf");
  Wait(SEC_2);

  printf("PlayFile('/media/card/7.rsf') elephant\n");
  PlayFile("/media/card/7.rsf");
  Wait(SEC_2);

  printf("PlayFile('/media/card/8.rsf') ratchet\n");
  PlayFile("/media/card/8.rsf");
  Wait(SEC_2);

  printf("PlayFile('/media/card/9.rsf')\n");
  PlayFile("/media/card/9.rsf");
  Wait(SEC_2);

  printf("PlayFile('/media/card/10.rsf')\n");
  PlayFile("/media/card/10.rsf");
  Wait(SEC_2);

  printf("PlayFile('/media/card/11.rsf')\n");
  PlayFile("/media/card/11.rsf");
  Wait(SEC_2);

  printf("PlayFile('/media/card/12.rsf') tada\n");
  PlayFile("/media/card/12.rsf");
  Wait(SEC_2);

  printf("PlayFile('/media/card/13.rsf')\n");
  PlayFile("/media/card/13.rsf");
  Wait(SEC_2);

  printf("PlayFile('/media/card/14.rsf') snore\n");
  PlayFile("/media/card/14.rsf");
  Wait(SEC_2);

  printf("PlayFile('/media/card/15.rsf')\n");
  PlayFile("/media/card/15.rsf");
  Wait(SEC_2);

  printf("PlayFile('/media/card/16.rsf')\n");
  PlayFile("/media/card/16.rsf");
  Wait(SEC_2);

  printf("PlayFile('/media/card/17.rsf')\n");
  PlayFile("/media/card/17.rsf");
  Wait(SEC_2);

  printf("PlayFile('/media/card/test3.wav') (evil laugh)\n");
  PlayFile("/media/card/test3.wav");
  Wait(SEC_2);

  printf("PlayFile('/media/card/test1.wav') (> 64k)\n");
  PlayFile("/media/card/test1.wav");
  Wait(SEC_2);

  printf("end of pt_test\n");
}
Exemplo n.º 27
0
/*
	This is where all game physics starts each frame. It is called each frame 
	by the game statem manager after player input and AI have been processed. It
	updates the physical state of all dynamic objects in the game and
	moves all objects to their end of frame positions, updates all necessary
	object velocities, and calls all collision event handlers.
*/
void Physics::update(Game *game)
{

	GameStateManager *gsm = game->getGSM();
	SpriteManager *spm = gsm->getSpriteManager();
	AnimatedSprite *player = spm->getPlayer();

	if (once == 0) {

	
	/*	b2PolygonShape groundBox;
		groundBox.SetAsBox(50.0f, 10.0f);

		groundBody->CreateFixture(&groundBox, 0.0f);
*/
		b2BodyDef bodyDef;
		bodyDef.type = b2_dynamicBody;
		bodyDef.position.Set(600, 9280);
		body = world->CreateBody(&bodyDef);

		b2PolygonShape dynamicBox;
		dynamicBox.SetAsBox(32.0f, 32.0f);

		b2FixtureDef fixtureDef;
		fixtureDef.shape = &dynamicBox;


		// Set the box density to be non-zero, so it will be dynamic.
		fixtureDef.density = 1.0f;

		// Override the default friction.
		fixtureDef.friction = 0.3f;

		// Add the shape to the body.
		body->CreateFixture(&fixtureDef);
		//body->SetLinearVelocity(b2Vec2(0,-1000));

		//body->SetUserData(player);
		player->setBody(body);
		// This is our little game loop.

		


		once += 1;
	}

	body->ApplyForce( world->GetGravity(), body->GetWorldCenter(), true );

			float32 timeStep = 1.0f / 60.0f;
			int32 velocityIterations = 6;
			int32 positionIterations = 2;

			world->Step(timeStep, velocityIterations, positionIterations);

			// Now print the position and angle of the body.
			b2Vec2 position = body->GetPosition();
			//b2Vec2 position2 = body2->GetPosition();

			float32 angle = body->GetAngle();

			printf("%4.2f %4.2f %4.2f\n", position.x, position.y, angle);
		
			if (f == 0) {
				World *woorld = gsm->getWorld();
				vector<WorldLayer*> *layers = woorld->getLayers();
				CollidableObject *sprite = NULL;
				for (int i = 0; i < woorld->getNumLayers(); i++)
				{
					WorldLayer *layer = layers->at(i);
					if (layer->hasCollidableTiles())
					{
						layer->findTileCollisionsForSprite(this,sprite);
					}
				}
				f++;
			}
			
			if (player->getinvincible() == true) {
				if (invincibletimer == 0) {
					invincibletimer = 100;
				}
				invincibletimer -= 1;
				if (invincibletimer == 0) {
					player->setinvincible(false);
				}
			}
			
				 
			if (z!=0)z--;
			if (z==0)
			if (player->getinvincible() == false)
			for (b2ContactEdge* edge = body->GetContactList(); edge; edge = edge->next)
				if (edge->contact->IsTouching()) {
					z=50;

					if(game->getPlayerLife() > 0)
						{game->decreasePlayerLife();
					PlaySound(L"data/sounds/explosion.wav", NULL, SND_FILENAME|SND_SYNC);}
					else 
					{
					if(game->getLives() > 1) {
						game->decreaseLives();
					}						
					else if(game->getLives() == 1 && game->getPlayerLife() == 0)
					{
						GameStateManager *gsm = game->getGSM();
						once = 0;
						//body->SetTransform(b2Vec2((600-position.x),(9280-position.y)),body->GetAngle());
						Viewport *viewport = game->getGUI()->getViewport();
						viewport->setViewportX(0);
						viewport->setViewportY(8880);

						gsm->gameOver();
						PlaySound(L"data/sounds/end.wav", NULL, SND_FILENAME|SND_SYNC);
					}
	
					game->setPlayerLife();
				}

			}

			/*if (f > 0)
			{
				if(game->getPlayerLife() > 0)
				game->decreasePlayerLife();
		
				else 
				{
					if(game->getLives() > 1)
						game->decreaseLives();
					else if(game->getLives() == 1 && game->getPlayerLife() == 0)
					{
						GameStateManager *gsm = game->getGSM();
						gsm->setCurrentGameState(GS_GAME_OVER);
					}
	
					game->setPlayerLife();
				}	
			}*/
			//OutputDebug(L"My output string.");


	//		activatedForSingleUpdate = false;

	//// WE'LL NEED THE WORLD TO ACCESS THE SPRITES AND WORLD LAYERS
	//World *woorld = gsm->getWorld();

	//currentCollisionTime = 0.0f;


	//// FOR ALL SPRITES, INCLUDING THE BOTS AND PLAYER
	//vector<CollidableObject*>::iterator spritesIt = sortedSweptShapes[LEFT_EDGE]->begin();
	//while (spritesIt != sortedSweptShapes[LEFT_EDGE]->end())
	//{
	//	CollidableObject *sprite = (*spritesIt);
	//	prepSpriteForCollisionTesting(woorld, sprite);
	//	getAllTileCollisionsForAGivenSprite(woorld, sprite, 1.0f);
	//	spritesIt++;
	//}

	//// PREPARE FOR SPRITE-SPRITE COLLISION TESTING

	//	// SWEEP AND PRUNE DATA STRUCTURES PREP WORK
	//		// SORT S_AND_P VECTOR SORTED BY START X OF SWEPT SHAPE
	//		// SORT S_AND_P VECTOR SORTED BY END X OF SWEPT SHAPE
	//		// WE DON'T NEED THE Y-AXIS SORTED, BUT WOULD IF THIS
	//		// WERE A 3D SYSTEM TO SAVE ON COMPARISONS.

	//// WE'RE USING C++'s STL sort METHOD AND ARE PROVIDING
	//// A CUSTOM MEANS FOR COMPARISON
	//sort(sortedSweptShapes[LEFT_EDGE]->begin(),		sortedSweptShapes[LEFT_EDGE]->end(),	SweptShapesComparitorByLeft());
	//sort(sortedSweptShapes[RIGHT_EDGE]->begin(),	sortedSweptShapes[RIGHT_EDGE]->end(),	SweptShapesComparitorByRight());
	//	
	//// RECORD SORTED POSITIONS WITH EACH SPRITE. THEY NEED TO KNOW WHERE
	//// THEY ARE IN THOSE DATA STRUCTURES SUCH THAT WE CAN JUMP INTO
	//// THOSE DATA STRUCTURES TO TEST COLLISIONS WITH NEIGHBORS
	//updateSweptShapeIndices();

	//// YOU'LL NEED TO TEST FOR SPRITE-TO-SPRITE COLLISIONS HERE

	//// *** LOOP STARTS HERE. WE'LL DO THIS UNTIL THERE ARE NO
	//// MORE COLLISIONS TO RESOLVE FOR THIS FRAME
	//while (activeCollisions.size() > 0)
	//{
	//	// SORT COLLISION OBJECTS BY TIME OF COLLISION
	//	// NOTE THAT I'M JUST EMPLOYING THE STL'S List
	//	// CLASS' SORT METHOD BY PROVIDING MY OWN
	//	// MEANS FOR COMPARING Collision OBJECTS
	//	activeCollisions.sort(CollisionComparitor());

	//	// GET FIRST COLLISION - NOTE THAT WE HAVE THE COLLISIONS SORTED
	//	// IN DESCENDING ORDER, SO TO TAKE THE EARLIEST ONE, WE REMOVE IT
	//	// FOM THE BACK OF THE SORTED LIST
	//	Collision *earliestCollision = activeCollisions.back();
	//	activeCollisions.pop_back();
	//	float collisionTime = earliestCollision->getTimeOfCollision();

	//	// MOVE ALL SPRITES UP TO TIME OF FIRST COLLISION USING
	//	// APPROPRIATELY SCALED VELOCITIES
	//	moveAllSpritesUpToBufferedTimeOfCollision(earliestCollision);

	//	// AND ADVANCE COLLISION TIME
	//	currentCollisionTime = collisionTime;

	//	// AND UPDATE THE VELOCITIES OF THE SPRITE(S) INVOLVED IN THE COLLISION
	//	performCollisionResponse(earliestCollision);

	//	// EXECUTE COLLISION EVENT CODE
	//	// TEST TO SEE TYPES OF OBJECTS AND APPROPRIATE RESPONSE
	//	// ACCORDING TO CUSTOMIZED COLLISION EVENT HANDLER
	//	collisionListener->respondToCollision(game, earliestCollision);

	//	CollidableObject *co1 = earliestCollision->getCO1();
	//	CollidableObject *co2 = earliestCollision->getCO2();
	//	removeActiveCOCollisions(co1);
 //		co1->updateSweptShape(1.0f - currentCollisionTime);
	//	getAllTileCollisionsForAGivenSprite(woorld, co1, 1.0f - currentCollisionTime);

	//	// ONLY DO IT FOR THE SECOND ONE IF IT'S NOT A TILE
	//	if (!earliestCollision->isCollisionWithTile())
	//	{
	//		removeActiveCOCollisions(co2);
	//		co2->updateSweptShape(1.0f - currentCollisionTime);
	//		getAllTileCollisionsForAGivenSprite(woorld, co2, 1.0f - currentCollisionTime);
	//	}
	//	else
	//	{
	//		spriteToTileCollisionsThisFrame[co1].insert(earliestCollision->getTile());
	//		recycledCollidableObjectsList.push_back(co2);
	//	}
	//	
	//	// IF IT WAS ONLY ONE SPRITE WITH A TILE THIS IS EASY TO DO
	//	if (earliestCollision->isCollisionWithTile())
	//	{
	//		reorderCollidableObject(co1);
	//	}
	//	// YOU'LL HAVE TO WORRY ABOUT REORDERING STUFF FOR COLLISIONS
	//	// BETWEEN TWO SPRITES
	//	
	//	// NOW TEST NEIGHBORS OF SPRITES INVOLVED IN RESOLVED COLLISION
	//	// AGAINST NEIGHBORS IN SWEPT SHAPE DATA STRUCTURES. YOU'LL HAVE
	//	// TO FIGURE OUT HOW TO DO THIS AND HOW TO RESOLVE SUCH COLLISIONS
	//		
	//	// RECYCLE THE COLLISION SINCE WE'RE NOW DONE WITH IT
	//	recycledCollisions.push_back(earliestCollision);
	//}

	//// APPLY THE REMAINING TIME TO MOVE THE SPRITES. NOTE THAT
	//// THIS IS ACTUALLY A VERY RISKY, TRICKY STEP BECAUSE IT COULD
	//// MOVE OBJECTS ALMOST TO THE POINT OF COLLISION, WHICH MAY THEN
	//// BE DETECTED ALMOST AT TIME 0 NEXT FRAME. THERE ARE OTHER TRICKY
	//// ISSUES RELATED TO OUR BUFFER AS WELL, SO WE CHEAT A LITTLE HERE
	//// AND SCALE THE TIME REMAINING DOWN A LITTE
	//if (currentCollisionTime < 1.0f)
	//	moveAllSpritesToEndOfFrame();

	//// INIT TILE COLLISION INFO
	//// SET ON TILE LAST FRAME USING ON TILE THIS FRAME
	//// SET ON TILE THIS FRAME TO FALSE
	//spritesIt = sortedSweptShapes[LEFT_EDGE]->begin();
	//while (spritesIt != sortedSweptShapes[LEFT_EDGE]->end())
	//{
	//	CollidableObject *sprite = (*spritesIt);
	//	sprite->advanceOnTileStatus();
	//	spritesIt++;
	//}

	//// WE'RE NOT GOING TO ALLOW MULTIPLE COLLISIONS TO HAPPEN IN A FRAME
	//// BETWEEN THE SAME TWO OBJECTS
	//spriteToTileCollisionsThisFrame.clear();
	//


}
//-----------------------------------------------------------------------------
// Purpose: Input handler that begins playing the sound.
//-----------------------------------------------------------------------------
void CAmbientGenericFMOD::InputPlaySound( inputdata_t &inputdata )
{
	PlaySound();
}
Exemplo n.º 29
0
void
ship_death (ELEMENT *ShipPtr)
{
	STARSHIP *StarShipPtr;
	STARSHIP *VictoriousStarShipPtr;
	HELEMENT hElement, hNextElement;
	ELEMENT *ElementPtr;

	StopDitty ();
	StopMusic ();

	GetElementStarShip (ShipPtr, &StarShipPtr);
	
	// JMS: Make sure the Foon-foon's spinning blade sound ends when the ship dies.
	if (StarShipPtr->SpeciesID == FOONFOON_ID)
	{
		COUNT i;
		
		for (i = FIRST_SFX_CHANNEL; i <= LAST_SFX_CHANNEL; ++i)
		{
			ELEMENT *posobj;
			if (!ChannelPlaying(i))
				continue;
			
			posobj = GetPositionalObject (i);
			
			if (posobj)
				StopSource (i);
		}
	}

	if (ShipPtr->mass_points <= MAX_SHIP_MASS)
	{	// Not running away and not reincarnating (Pkunk)
		// When a ship tries to run away, it is (dis)counted in DoRunAway(),
		// so when it dies while running away, we will not count it again
		assert (StarShipPtr->playerNr >= 0);
		battle_counter[StarShipPtr->playerNr]--;
	}

	VictoriousStarShipPtr = NULL;
	for (hElement = GetHeadElement (); hElement; hElement = hNextElement)
	{
		LockElement (hElement, &ElementPtr);
		if ((ElementPtr->state_flags & PLAYER_SHIP)
				&& ElementPtr != ShipPtr
						/* and not running away */
				&& ElementPtr->mass_points <= MAX_SHIP_MASS)
		{
			GetElementStarShip (ElementPtr, &VictoriousStarShipPtr);
			if (VictoriousStarShipPtr->RaceDescPtr->ship_info.crew_level == 0)
				VictoriousStarShipPtr = NULL;

			UnlockElement (hElement);
			break;
		}
		hNextElement = GetSuccElement (ElementPtr);
		UnlockElement (hElement);
	}

	StarShipPtr->cur_status_flags &= ~PLAY_VICTORY_DITTY;

	DeltaEnergy (ShipPtr,
			-(SIZE)StarShipPtr->RaceDescPtr->ship_info.energy_level);

	ShipPtr->life_span = NUM_EXPLOSION_FRAMES * 3;
	ShipPtr->state_flags &= ~DISAPPEARING;
	ShipPtr->state_flags |= FINITE_LIFE | NONSOLID;
	ShipPtr->postprocess_func = PostProcessStatus;
	ShipPtr->death_func = cleanup_dead_ship;
	ShipPtr->hTarget = 0;
	ZeroVelocityComponents (&ShipPtr->velocity);
	if (ShipPtr->crew_level) /* only happens for shofixti self-destruct */
	{
		PlaySound (SetAbsSoundIndex (
				StarShipPtr->RaceDescPtr->ship_data.ship_sounds, 1),
				CalcSoundPosition (ShipPtr), ShipPtr,
				GAME_SOUND_PRIORITY + 1);

		DeltaCrew (ShipPtr, -(SIZE)ShipPtr->crew_level);
		if (VictoriousStarShipPtr == NULL)
		{	// No ships left alive after a Shofixti Glory device,
			// thus Shofixti wins
			VictoriousStarShipPtr = StarShipPtr;
		}
	}
	else
	{
		ShipPtr->preprocess_func = explosion_preprocess;

		PlaySound (SetAbsSoundIndex (GameSounds, SHIP_EXPLODES),
				CalcSoundPosition (ShipPtr), ShipPtr, GAME_SOUND_PRIORITY + 1);
	}

	if (VictoriousStarShipPtr != NULL)
		VictoriousStarShipPtr->cur_status_flags |= PLAY_VICTORY_DITTY;

	// The winner is set once per battle. If both ships die, this function is
	// called twice, once for each ship. We need to preserve the winner
	// determined on the first call.
	if (winnerStarShip == NULL)
		winnerStarShip = VictoriousStarShipPtr;

	if (LOBYTE (GLOBAL (CurrentActivity)) == SUPER_MELEE)
		MeleeShipDeath (StarShipPtr);
}
Exemplo n.º 30
0
void CChickenBoid::Kill( const Vec3 &hitPoint,const Vec3 &force )
{
	CBoidBird::Kill(hitPoint,force);
	PlaySound(CHICKEN_SOUND_DIE);
}