コード例 #1
0
ファイル: main.cpp プロジェクト: spaded06543/GP_homework
/*-------------------------------------------------------------
Play background music && loop
--------------------------------------------------------------*/
void PlaySound(int skip){
	FnAudio sd;
	sd.ID(OM.BGMid);
	if (now_mode == 5 && pre_mode == 0){
		sd.Stop();
		if (sd.Load("Bgm/bgm002") == FALSE){
			exit(3);
		}
		//sd.SetVolume(OM.volume);
		OM.Movement(FY_RIGHT, TRUE);
		OM.Movement(FY_LEFT, TRUE);
		pre_mode = 1;
	}
	else if (pre_mode == 1 && now_mode == 1){
		sd.Stop();
		if (sd.Load("Bgm/bgm001") == FALSE){
			exit(3);
		}
		//sd.SetVolume(OM.volume);
		OM.Movement(FY_RIGHT, TRUE);
		OM.Movement(FY_LEFT, TRUE);
		pre_mode = 0;
	}
	if (!(sd.IsPlaying())){
		sd.Play(LOOP);
		//sd.SetVolume(OM.volume);
		OM.Movement(FY_RIGHT, TRUE);
		OM.Movement(FY_LEFT, TRUE);
	}
}
コード例 #2
0
bool OurActor::playActionAudio()
{
	if( current_OurAction->numOfAudioFrames > 0 )
	{
		FnAudio audio;
		for( int i=0 ; i<current_OurAction->numOfAudioFrames ; i++ )
		{
			if( current_OurAction->audioFrames[i]->frameNO <= current_frame && 
				current_OurAction->audioFrames[i]->frameNO >= current_frame - current_OurAction->play_speed ){
					audio.Object(current_OurAction->audioFrames[i]->audioID);
					audio.Play(ONCE);
					return true;
			}
		}
	}
	return false;
}
コード例 #3
0
void ActorStateMachine::TakeDamage(int damage, SHOT_CODE shot_code, float *attackerPos ){
	FnActor actor;
	actor.Object(character);
	float pos[3];
	float dir[3];
	actor.GetWorldPosition(pos);
	actor.GetWorldDirection(dir, NULL);
	if ( shot_code != STUCK_SHOT && attackerPos !=NULL){
		float newDir[3];
		newDir[0] = attackerPos[0] - pos[0];
		newDir[1] = attackerPos[1] - pos[1];
		newDir[2] = 0.0f;
		actor.SetWorldDirection(newDir,NULL);
		if (shot_code == BIG_SHOT){
			actor.MoveForward(-OUTSHOT_DIS,TRUE, FALSE, 0.0, TRUE);
			//sprintf(debug, "%s OUTSHOT_DIS\n", debug);
		}else if (shot_code == SMALL_SHOT){
			actor.MoveForward(-SMALL_OUTSHOT_DIS,TRUE, FALSE, 0.0, TRUE);
			//sprintf(debug, "%s SMALL_OUTSHOT_DIS\n", debug);
		}
		actor.SetWorldDirection(dir,NULL);
	}

	if (this->state == STATEGUARD){
		FnAudio audio;
		audio.Object(audioG);
		audio.Play(ONCE);
		return; // no damage
	}else{
		FnAudio audio;
		audio.Object(audioD);
		//if (audio.IsPlaying() == FALSE){
			audio.Play(ONCE);
		//}
		

	}
	this->life -= damage;
	//sprintf(debug, "%s life=%d\n", debug, this->life);
	if (this->life <= 0) {
		this->ChangeState(STATEDIE, TRUE);
	}else {
		this->ChangeState(STATEDAMAGE, TRUE);
	}
	this->UpdateLifeBillboard();
}