Example #1
0
/* ================================================ */
const InputWatcher::STICK_INFO InputWatcher::GetStickInfo( const InputWatcher::STICK_KIND &stickKind )
{
	int xx = 0;
	int yy = 0;
	math::Angle angle = 0.0f;

	if(stickKind == STICK_LEFT){
		GetJoypadAnalogInput( &xx, &yy, m_watchPadIndex );
	}
	else{
		GetJoypadAnalogInputRight( &xx, &yy, m_watchPadIndex );
	}

	if(math::Abs(xx) < STICK_INVALID_RANGE
		&& math::Abs(yy) < STICK_INVALID_RANGE){
		// 傾いてはいるが無効範囲
		angle = 0;
		xx = 0;
		yy = 0;
	}
	else{
		angle = math::ArcTan2( static_cast<float>(yy), static_cast<float>(xx));
	}

	STICK_INFO ret;
	ret.Init();
	ret.m_vec = math::Vector2(static_cast<float>(xx),static_cast<float>(yy));
	ret.m_angle = angle;
	return ret;
}
Example #2
0
	void Creticle::controll()
	{
		int right_lever_x = 0,right_lever_y = 0;
		GetJoypadAnalogInputRight(&right_lever_x,&right_lever_y,DX_INPUT_PAD1);

		//�ړ�����
		if(Pplayer->target_type == FREE)
		{
			if(CheckHitKey(KEY_INPUT_UP) == TRUE || right_lever_y < 0)
			{
				if(Pplayer->Preticle->pos.y - Pplayer->pos.y < 290)
				{
					pos.y -= (right_lever_y * movespeed)*0.002;
				}
			}
			if(CheckHitKey(KEY_INPUT_DOWN) == TRUE || right_lever_y > 0 )
			{
				if(Pplayer->pos.y - Pplayer->Preticle->pos.y < 290)
				{
					pos.y -= (right_lever_y * movespeed)*0.002;
				}
			}

			if(CheckHitKey(KEY_INPUT_LEFT) == TRUE || right_lever_x < 0)
			{
				angle.x	-= (right_lever_x * (DX_PI/180)*movespeed)*0.001f;
				angle.z += (right_lever_x * (DX_PI/180)*movespeed)*0.001f; 			
	//			Pplayer->model_angle_x += (right_lever_x * movespeed)*0.001f; 			
			}
			if(CheckHitKey(KEY_INPUT_RIGHT) == TRUE || right_lever_x > 0)
			{
				angle.x	-= (right_lever_x * (DX_PI/180)*movespeed)*0.001f;
				angle.z += (right_lever_x * (DX_PI/180)*movespeed)*0.001f; 			
	//			Pplayer->model_angle_x += (right_lever_x *movespeed)*0.001f; 			
			}
			if(( GetJoypadInputState( DX_INPUT_PAD1 ) & PAD_INPUT_A ) != 0 && Pplayer->pos.y < 890 )
			{
				pos.y += Pplayer->movespeed; 			
			}
			if(( GetJoypadInputState( DX_INPUT_PAD1 ) & PAD_INPUT_C ) != 0 && Pplayer->pos.y > 110 )
			{
				pos.y -= Pplayer->movespeed; 			
			}
			angle.y = fabsf(Pplayer->Preticle->pos.y - Pplayer->pos.y); 
			move_radius = sqrt((300 + angle.y) * (300 - angle.y));
			pos.x = Pplayer->pos.x + move_radius*cos(angle.x + (DX_PI/2));
			pos.z = Pplayer->pos.z + move_radius*sin(angle.z + (DX_PI/2));
		}
	}
Example #3
0
	void Ccamera::controll()
	{
		int right_lever_x = 0,right_lever_y = 0;
		GetJoypadAnalogInputRight(&right_lever_x,&right_lever_y,DX_INPUT_PAD1);


		//�ړ�����

		if(CheckHitKey(KEY_INPUT_LEFT) == TRUE || right_lever_x < 0)
		{
			angle.x	-= (right_lever_x * (PI/180)*movespeed)*0.001f;
			angle.z += (right_lever_x * (PI/180)*movespeed)*0.001f; 			
		}
		if(CheckHitKey(KEY_INPUT_RIGHT) == TRUE || right_lever_x > 0)
		{
			angle.x	-= (right_lever_x * (PI/180)*movespeed)*0.001f;
			angle.z += (right_lever_x * (PI/180)*movespeed)*0.001f; 			
		}
		pos.y = Pplayer->pos.y;
		pos.x = Pplayer->pos.x + move_radius*cos(angle.x - (PI/2));
		pos.z = Pplayer->pos.z + move_radius*sin(angle.z - (PI/2));


	}