Ejemplo n.º 1
0
int MoveChara()
{
	int ret;
	float posstep = 100.0f;
	float degstep = 5.0f;
	//keybuf は、GetKeyboardState 命令で、セットされます。

	if( keybuf[VK_UP] == 1 ){
		ret = E3DPosForward( hsid1, posstep );//矢印上
		_ASSERT( !ret );
	}
	if( keybuf[VK_DOWN] == 1 ){
		ret = E3DPosForward( hsid1, -posstep );//矢印下
		_ASSERT( !ret );
	}
	if( keybuf[VK_LEFT] == 1 ){
		ret = E3DRotateY( hsid1, -degstep );//矢印左
		_ASSERT( !ret );
	}
	if( keybuf[VK_RIGHT] == 1 ){
		ret = E3DRotateY( hsid1, degstep );//矢印右
		_ASSERT( !ret );
	}



	return 0;
}
Ejemplo n.º 2
0
int MoveCamera()
{
	int ret;
	D3DXVECTOR3 savepos, backpos;

	ret = E3DGetPos( hsid1, &savepos );
	_ASSERT( !ret );
	ret = E3DPosForward( hsid1, -2500.0f );
	_ASSERT( !ret );
	ret = E3DGetPos( hsid1, &backpos );
	_ASSERT( !ret );
	ret = E3DSetPos( hsid1, savepos );
	_ASSERT( !ret );

	D3DXVECTOR3 campos, camtarget, camup;
	campos = D3DXVECTOR3( backpos.x, backpos.y + 2000.0f, backpos.z );
	camtarget = D3DXVECTOR3( savepos.x, savepos.y + 800.0f, savepos.z );
	camup = D3DXVECTOR3( 0.0f, 1.0f, 0.0f );

	ret = E3DSetCameraPos( campos );
	_ASSERT( !ret );
	ret = E3DSetCameraTarget( camtarget, camup );
	_ASSERT( !ret );

	return 0;
}
Ejemplo n.º 3
0
int MoveChara()
{
	float movestep = 100.0f;
	float degstep = 5.0f;

	if( keybuf[VK_SHIFT] == 0 ){
		//シフトキーを押していないときキャラクターを動かす
		//シフトキーを押しているときはカメラを動かす(MoveCamera)
		if( keybuf[VK_UP] != 0 ){
			E3DPosForward( hsid1, movestep );
		}
		if( keybuf[VK_DOWN] != 0 ){
			E3DPosForward( hsid1, -movestep );
		}
		if( keybuf[VK_LEFT] != 0 ){
			E3DRotateY( hsid1, -degstep );
		}
		if( keybuf[VK_RIGHT] != 0 ){
			E3DRotateY( hsid1, degstep );
		}
	}

	return 0;
}
Ejemplo n.º 4
0
int MoveChara( int chara1, int chara2, char key1, char key2, char key3, char key4, 
	char key5, char key6, char key7 )
{
	int ret;

	int eventno;

	if( ci[chara1].nagerare == 0 ){
		eventno = 0;
		if( keybuf[key5] == 1 )
			eventno = 2;
		if( keybuf[key6] == 1 )
			eventno = 4;
		if( keybuf[key7] == 1 )
			eventno = 8;
		if( (keybuf[key5] != 0) || (keybuf[key6] != 0) ){
			ret = E3DPosForward( ci[chara1].hsid, 5.0f );
			if( ret ){
				_ASSERT( 0 );
				return 1;
			}
			ret = E3DGetPos( ci[chara1].hsid, &(ci[chara1].pos) );
			if( ret ){
				_ASSERT( 0 );
				return 1;
			}
		}
		if( eventno == 0 ){
			if( keybuf[key1] != 0 ){
				ret = E3DPosForward( ci[chara1].hsid, 16.0f );
				if( ret ){
					_ASSERT( 0 );
					return 1;
				}

				ret = E3DGetPos( ci[chara1].hsid, &(ci[chara1].pos) );
				if( ret ){
					_ASSERT( 0 );
					return 1;
				}

				eventno = 1;
			}
			if( keybuf[key2] != 0 ){
				ret = E3DPosForward( ci[chara1].hsid, -16.0f );
				if( ret ){
					_ASSERT( 0 );
					return 1;
				}

				ret = E3DGetPos( ci[chara1].hsid, &(ci[chara1].pos) );
				if( ret ){
					_ASSERT( 0 );
					return 1;
				}

				eventno = 1;
			}
			if( keybuf[key3] != 0 ){
				ret = E3DRotateY( ci[chara1].hsid, 2.0f );
				if( ret ){
					_ASSERT( 0 );
					return 1;
				}

				eventno = 1;
			}
			if( keybuf[key4] != 0 ){
				ret = E3DRotateY( ci[chara1].hsid, -2.0f );
				if( ret ){
					_ASSERT( 0 );
					return 1;
				}

				eventno = 1;
			}
		}
		if( (ci[chara1].motid == *(motionidptr + MOT_MOCHIAGE)) && (ci[chara1].nage == 0) && 
			(ci[chara2].nagerare == 0) ){
			ret = E3DDirToTheOther( ci[chara1].hsid, ci[chara2].hsid );
			if( ret ){
				_ASSERT( 0 );
				return 1;
			}

			D3DXVECTOR3 diff;
			diff = ci[chara1].pos - ci[chara2].pos;
			float mag;
			mag = diff.x * diff.x + diff.y * diff.y + diff.z * diff.z;
			if( mag < 900000.0f ){
				ci[chara1].nage = 1;
				ci[chara2].nagerare = 1;
				ci[chara2].nagevy = NAGEY;
				D3DXVECTOR3 bonepos;
				ret = E3DGetBonePos( ci[chara1].hsid, 18, 1, ci[chara1].motid, ci[chara1].frameno, &bonepos );
				if( ret ){
					_ASSERT( 0 );
					return 1;
				}

				ret = E3DGetDirQ2( ci[chara1].hsid, ci[chara1].qid );
				if( ret ){
					_ASSERT( 0 );
					return 1;
				}
				D3DXVECTOR3 befvec( 0.0f, 0.0f, -1.0f );
				D3DXVECTOR3 dir;
				ret = E3DMultQVec( ci[chara1].qid, befvec, &dir );
				if( ret ){
					_ASSERT( 0 );
					return 1;
				}

				ci[chara2].pos.x = bonepos.x + dir.x * 300.0f;
				ci[chara2].pos.y = bonepos.y - 300.0f;
				ci[chara2].pos.z = bonepos.z + dir.z * 300.0f;
				ret = E3DSetPos( ci[chara2].hsid, ci[chara2].pos );
				if( ret ){
					_ASSERT( 0 );
					return 1;
				}

				ret = E3DGetBoneQ( ci[chara1].hsid, 18, ci[chara1].motid, ci[chara1].frameno, 2, ci[chara2].qid );
				if( ret ){
					_ASSERT( 0 );
					return 1;
				}
				ret = E3DSetDirQ2( ci[chara2].hsid, ci[chara2].qid );
				if( ret ){
					_ASSERT( 0 );
					return 1;
				}
				ret = E3DSetNewPoseByMOA( ci[chara2].hsid, 16 );
				if( ret ){
					_ASSERT( 0 );
					return 1;
				}

			}
		}
		ret = E3DSetNewPoseByMOA( ci[chara1].hsid, eventno );
		if( ret ){
			_ASSERT( 0 );
			return 1;
		}

	}else{

		ci[chara1].nagerare += 1;

		if( ci[chara1].nagerare < 50 ){	
			ret = E3DSetNewPoseByMOA( ci[chara1].hsid, 16 );
			if( ret ){
				_ASSERT( 0 );
				return 1;
			}

		}else{
			if( ci[chara1].nagerare < 120 ){
				ret = E3DGetDirQ2( ci[chara2].hsid, ci[chara2].qid );
				if( ret ){
					_ASSERT( 0 );
					return 1;
				}

				D3DXVECTOR3 befvec2( 0.0f, 0.0f, -1.0f );
				D3DXVECTOR3 dir2;
				ret = E3DMultQVec( ci[chara2].qid, befvec2, &dir2 );
				if( ret ){
					_ASSERT( 0 );
					return 1;
				}

				ci[chara1].pos.x += dir2.x * 20.0f;
				ci[chara1].pos.z += dir2.z * 20.0f;
				ci[chara1].nagevy += GRAVITY;
				ci[chara1].pos.y += ci[chara1].nagevy;

				if( ci[chara1].pos.y < GROUND_HEIGHT )
					ci[chara1].pos.y = GROUND_HEIGHT;
				ret = E3DSetPos( ci[chara1].hsid, ci[chara1].pos );
				if( ret ){
					_ASSERT( 0 );
					return 1;
				}

				ret = E3DSetNewPoseByMOA( ci[chara1].hsid, 32 );
				if( ret ){
					_ASSERT( 0 );
					return 1;
				}

			}else{
				ci[chara1].nagerare = 0;
				ci[chara2].nage = 0;
				ci[chara1].pos.y = GROUND_HEIGHT;
				ret = E3DCopyQ( ci[chara1].qid, ci[chara2].qid );
				if( ret ){
					_ASSERT( 0 );
					return 1;
				}

				ret = E3DSetDirQ2( ci[chara1].hsid, ci[chara1].qid );
				if( ret ){
					_ASSERT( 0 );
					return 1;
				}

				ret = E3DSetPos( ci[chara1].hsid, ci[chara1].pos );
				if( ret ){
					_ASSERT( 0 );
					return 1;
				}

				ret = E3DSetNewPoseByMOA( ci[chara1].hsid, 0 );
				if( ret ){
					_ASSERT( 0 );
					return 1;
				}

 			}	
		}
	}

	int tempframeno;
	ret = E3DGetMotionFrameNo( ci[chara1].hsid, &(ci[chara1].motid), &(ci[chara1].frameno) );
	if( ret ){
		_ASSERT( 0 );
		return 1;
	}

	if( ci[chara1].motid == 0 ){
		ret = E3DGetNextMotionFrameNo( ci[chara1].hsid, 0, &(ci[chara1].motid), &tempframeno );
		if( ret ){
			_ASSERT( 0 );
			return 1;
		}

 	}







	return 0;
}
Ejemplo n.º 5
0
/*キャラを動かします、前後左右に動けます*/
int PlayerChara::MoveChara(){

	/*変数の初期化*/
	int ech = 0;//エラー確認変数
	int KeyMov = 0;//キーを押してどの方向に動くかの変数
	int MovOn = 0;//動いていいかのフラグ
	int keyin[20];//キー情報配列を作成 
	float WantDeg = 0;//向きたい方向の変数
	float FixedMoveSpeed = 0.0f;//それぞれの状態の固定速度
	D3DXVECTOR3 SubPos( 0.0, 0.0, 0.0);//キャラクターを置く場所の座標
	D3DXVECTOR3 PCPos( 0.0, 0.0, 0.0);//プレイヤーキャラクターの位置の座標

	/*ダッシュ操作がオンになっていないかチェック*/


	/*キーによる分岐*/

	System::GetKeyData(keyin);//キー情報を格納

	if( keyin[0] == 1){//左
				KeyMov = KeyMov +1;
	}
	if( keyin[1] == 1){//上
				KeyMov = KeyMov +2;
	}
	if( keyin[2] == 1){//右
				KeyMov = KeyMov +4;
	}
	if( keyin[3] == 1){//下
				KeyMov = KeyMov +8;
	}

	/*キーから取得した情報を変換*/
	if(KeyMov == 1){//左
				WantDeg = -90.0f + Get_PC_Deg_XZ();
				MovOn = 1;

				/*モーションを「左歩き」にする*/
				Set_UnderMotion(3);
	}
	if(KeyMov == 3){//左上
				WantDeg = -45.0f + Get_PC_Deg_XZ(); 
				MovOn = 1;

				/*モーションを「左前進」にする*/
				Set_UnderMotion(4);
	}
	if(KeyMov == 2){//上
				WantDeg = Get_PC_Deg_XZ(); 
				MovOn = 1;

				/*モーションを「歩行」にする*/
				Set_UnderMotion(1);//通常

	}
	if(KeyMov == 6){//右上
				WantDeg = 45.0f + Get_PC_Deg_XZ(); 
				MovOn = 1;

				/*モーションを「左前進」にする*/
				Set_UnderMotion(5);
	}
	if(KeyMov == 4){//右
				WantDeg = 90.0f + Get_PC_Deg_XZ(); 
				MovOn = 1;

				/*モーションを「右歩き」にする*/
				Set_UnderMotion(2);
	}
	if(KeyMov == 12){//右下
				WantDeg = 135.0f + Get_PC_Deg_XZ(); 
				MovOn = 1;

				/*モーションを「右後進」にする*/
				Set_UnderMotion(7);
	}
	if(KeyMov == 8){//下
				WantDeg = 180.0f + Get_PC_Deg_XZ(); 
				MovOn = 1;

				/*モーションを「後進」にする*/
				Set_UnderMotion(8);
	}
	if(KeyMov == 9){//左下
				WantDeg = -135.0f + Get_PC_Deg_XZ(); 
				MovOn = 1;

				/*モーションを「左後進」にする*/
				Set_UnderMotion(6);

	}

	//キーが入力されていても、キック中なら
	if( Get_MyState() == 1) {
				MovOn = 0;//絶対動かない
	}

	//空中で、ダッシュ状態なら
	if( ( Get_AirOnPC() == 1) && ( Get_MyState() == 2)){
				WantDeg = Get_PC_Deg_XZ();//まっすぐ進む
				MovOn = 1;//絶対動く
	}

	//左飛び状態なら
	if( Get_MyState() == 3) {
				WantDeg = -90.0f + Get_PC_Deg_XZ();
				MovOn = 1;//絶対動く
	}

	//右飛び状態なら
	if( Get_MyState() == 4) {
				WantDeg = 90.0f + Get_PC_Deg_XZ(); 
				MovOn = 1;//絶対動く
	}


	/*動く方向を決めるよ*/
	if(MovOn == 1){

					if( Get_MyState() == 0){//通常状態なら
							if( Get_AirOnPC() == 0){//空中でなければ
									if(Get_Attitude() == 0){//姿勢が「立っている状態」なら
											/*スピードを増加させる*/
											Set_MoveSpeed( Get_MoveSpeed() + 0.8f);

											//スピードに制限をかける
											if( 25.0f <= Get_MoveSpeed() ){
														Set_MoveSpeed( 25.0f);
											}

											//固定スピードの設定(立ち)
											FixedMoveSpeed = 50.0f;
									}

									if(Get_Attitude() == 1){//姿勢が「しゃがみ状態」なら
											/*スピードを増加させる*/
											Set_MoveSpeed( Get_MoveSpeed() + 0.4f);

											//スピードに制限をかける
											if( 20.0f <= Get_MoveSpeed() ){
														Set_MoveSpeed( 20.0f);
											}

											//固定スピードの設定(しゃがみ)
											FixedMoveSpeed = 30.0f;
									}
							}
							if( Get_AirOnPC() == 1){//空中にいるなら
									
									/*スピードを増加させる*/
									Set_MoveSpeed(Get_MoveSpeed() + 0.3f);

									//スピードに制限をかける
									if( 10.0f <= Get_MoveSpeed() ){
												Set_MoveSpeed( 10.0f);
									}

									//固定スピードの設定(しゃがみ)
									FixedMoveSpeed = 20.0f;
							}

					}
					if( Get_MyState() == 2){//ダッシュ状態なら

							if( Get_AirOnPC() == 0){//地上にいるなら
									/*スピードを増加させる*/
									Set_MoveSpeed( Get_MoveSpeed() + 2.0f);

									//スピードに制限をかける
									if( 40.0f <= Get_MoveSpeed() ){
												Set_MoveSpeed(40.0f);
									}

									//固定スピードの設定(しゃがみ)
									FixedMoveSpeed = 70.0f;
							}
							if( Get_AirOnPC() == 1){//空中にいるなら
									/*スピードを増加させる*/
									Set_MoveSpeed( Get_MoveSpeed() + 2.0f);

									//スピードに制限をかける
									if( 40.0f <= Get_MoveSpeed() ){
												Set_MoveSpeed(40.0f);
									}

									//固定スピードの設定(しゃがみ)
									FixedMoveSpeed = 70.0f;
							}
					}
					if( ( Get_MyState() == 3) || ( Get_MyState() == 4)){//左飛び状態なら
									/*スピードを固定*/
									Set_MoveSpeed(0.0f);

									//固定スピードの設定(しゃがみ)
									FixedMoveSpeed = 90.0f;
					}



					/*ダミーモデルの座標に設定*/
					ech = E3DRotateInit ( Get_DummyModel());
					_ASSERT( ech != 1 );//エラーチェック

					ech = E3DGetPos( Get_BodyModel(), &PCPos);
					_ASSERT( ech != 1 );//エラーチェック

					ech = E3DSetPos( Get_DummyModel(), PCPos);
					_ASSERT( ech != 1 );//エラーチェック

					ech = E3DRotateY( Get_DummyModel(), WantDeg);
					_ASSERT( ech != 1 );//エラーチェック

					ech = E3DPosForward( Get_DummyModel(), (float)Get_MoveSpeed() + FixedMoveSpeed);
					_ASSERT( ech != 1 );//エラーチェック

					ech = E3DGetPos( Get_DummyModel(), &SubPos);
					_ASSERT( ech != 1 );//エラーチェック

					ech = E3DSetPos( Get_BodyModel(), SubPos);
					_ASSERT( ech != 1 );//エラーチェック
	}
	else{//減速をさせなければならないなら
					if( Get_AirOnPC() == 0){//空中にいるなら
								if( Get_Attitude() == 0) Set_MoveSpeed( Get_MoveSpeed() - 0.8f);//姿勢が「通常状態」なら
								if( Get_Attitude() == 1) Set_MoveSpeed( Get_MoveSpeed() - 1.0f);//姿勢が「しゃがみ状態」なら
					}
					if( Get_AirOnPC() == 1) Set_MoveSpeed( Get_MoveSpeed() - 0.6f);//姿勢が「しゃがみ状態」なら


					//スピードに制限をかける
					if( Get_MoveSpeed() <= 0.0 ){
								Set_MoveSpeed( 0.0f);
					}


					Set_UnderMotion(0);
	}




	return 0;
}