int Client::Run() { bool quit = false; renderer.SetDrawColor(Math::Color::White); renderer.Clear(); while(!quit) { Error::Throw(); for(auto e : SDLW::Events::Poll()) { switch(e.GetType()) { case SDLW::Events::Base::Type::quit: { quit = true; break; } case SDLW::Events::Base::Type::mouse: { auto ev = e.GetMouse(); switch(ev.GetType()) { case SDLW::Events::Event::Mouse::Type::motion: { auto event = ev.GetMotion(); break; } case SDLW::Events::Event::Mouse::Type::button: { auto event = ev.GetButton(); break; } default: { break; } } break; } case SDLW::Events::Base::Type::window: { auto ev = e.GetWindow(); switch(ev.GetType()) { case SDLW::Events::Event::Window::Type::enter: { controll->EnterCursor(); break; } case SDLW::Events::Event::Window::Type::leave: { controll->LeaveCursor(); break; } default: break; } break; } default: { break; } } } controll->Rendering(renderer, Math::Rect(size)); renderer.Present(); frame++; SDLW::Delay(30); } return 0; }
void Touch::Update(glm::vec2 position, glm::vec2 previous, double timestamp) { _timestamp = timestamp; _previous = previous; _position = position; _sampler.add(timestamp, position); if (GetMotion() == Motion::Moving) _hasMoved = true; }
void Touch::Update(glm::vec2 position, double timestamp, MouseButtons buttons) { _timestamp = timestamp; _previous = _position; _position = position; _previousButtons = _currentButtons; _currentButtons = buttons; _sampler.add(timestamp, position); if (GetMotion() == Motion::Moving) _hasMoved = true; }
//***************************************************************************** // 更新 //***************************************************************************** void CPlayer::Update() { //キー変数と取得 CInputKeyboard *pKeyBoard; pKeyBoard = CManager::GetInputKeyboard();//入力処理へのポインタ取得 //カメラ変数と取得 D3DXVECTOR3 CameraRot = CCamera::GetCameraRot(); //地面の高さの取得変数 CScene3d *pScene3d; pScene3d = CManager::GetScene3D(); //過去の座標を記録 D3DXVECTOR3 oldVtx = m_Vertex_3d.vtx; //ギミックの影響を反映させる if(m_pSceneLink) { //ギミック情報取得 VERTEX_3D pVtx; m_pSceneLink->GetVtx(&pVtx); m_Vertex_3d.vtx += pVtx.Speed_vtx; //m_Vertex_3d.Rot_vtx.y += 0.005f; //プレイヤーの角度の修正 while(m_Vertex_3d.Rot_vtx.y >= 1) { m_Vertex_3d.Rot_vtx.y -= 1 * 2; } while(m_Vertex_3d.Rot_vtx.y <= -1) { m_Vertex_3d.Rot_vtx.y += 1 * 2; } } //プレイヤーの今回の角度 //死亡した場合 if(m_bDeath) { //死亡エフェクト処理 m_Vertex_3d.Scail_vtx -= D3DXVECTOR3(0.02f,0.02f,0.02f); m_Vertex_3d.Rot_vtx.y += 0.2f; m_Vertex_3d.vtx.y += 0.1f; //プレイヤーが消滅したらゲーム終了 if(m_Vertex_3d.Scail_vtx.x < 0.0f) { CScene::Release(); CManager::ChangeMode(CManager::MODE_REZULT_GAMEOVER); } //以下の処理を行わずに終了 return; } //移動処理 //奥移動 if(pKeyBoard->GetkeyboardPress(DIK_W)) { //角度指定 if(pKeyBoard->GetkeyboardPress(DIK_D)) { PurposeRot = 0.25f + CameraRot.y; } else if(pKeyBoard->GetkeyboardPress(DIK_A)) { PurposeRot = -0.25f + CameraRot.y; } else { PurposeRot = 0.0f + CameraRot.y; } ResultRot = PurposeRot - m_Vertex_3d.Rot_vtx.y; m_Vertex_3d.MoveFlag = true; } //手前移動 else if(pKeyBoard->GetkeyboardPress(DIK_S)) { if(pKeyBoard->GetkeyboardPress(DIK_D)) { PurposeRot = 0.75f + CameraRot.y; } else if(pKeyBoard->GetkeyboardPress(DIK_A)) { PurposeRot = -0.75f + CameraRot.y; } else { PurposeRot = 1.0f + CameraRot.y; } ResultRot = PurposeRot - m_Vertex_3d.Rot_vtx.y; m_Vertex_3d.MoveFlag = true; } //左移動 else if(pKeyBoard->GetkeyboardPress(DIK_A)) { PurposeRot = -0.5f + CameraRot.y ; ResultRot = PurposeRot - m_Vertex_3d.Rot_vtx.y; m_Vertex_3d.MoveFlag = true; } //右移動 else if(pKeyBoard->GetkeyboardPress(DIK_D)) { //目的の角度の指定 PurposeRot = 0.5f + CameraRot.y; //角度の結果を計算 ResultRot = PurposeRot - m_Vertex_3d.Rot_vtx.y; m_Vertex_3d.MoveFlag = true; } else { m_Vertex_3d.MoveFlag = false; } //移動処理 if(m_Vertex_3d.MoveFlag) { while(ResultRot >= 1) { ResultRot -= 1 * 2; } while(ResultRot <= -1) { ResultRot += 1 * 2; } m_Vertex_3d.Rot_vtx.y += ResultRot * PLAYER_ROT; m_Vertex_3d.Speed_vtx.x += sin(D3DX_PI * PurposeRot) * MOVE; m_Vertex_3d.Speed_vtx.z += cos(D3DX_PI * PurposeRot) * MOVE; if(!jump && !m_bMotion) { if(m_bBlendMotion) { m_bBlendMotion = false; } SetMotion(MOTIONTYPE_WALK,10,m_bMotion); } } else { if(GetMotion() == MOTIONTYPE_WALK) { m_bFinishMotion = true; } } //ジャンプ if(pKeyBoard->GetkeyboardTrigger(DIK_SPACE) && !jump) { m_Vertex_3d.Speed_vtx.y = 1.0f; SetMotion(MOTIONTYPE_JUMP,10,false); } else if(pKeyBoard->GetkeyboardTrigger(DIK_1)) { SetMotion(MOTIONTYPE_PUNCH,10,m_bMotion); } //重力 m_Vertex_3d.Speed_vtx.y -= 0.03f; //空気抵抗 m_Vertex_3d.Speed_vtx.y -= m_Vertex_3d.Speed_vtx.y * 0.05f; //抵抗摩擦 m_Vertex_3d.Speed_vtx.x -= m_Vertex_3d.Speed_vtx.x * 0.2f; m_Vertex_3d.Speed_vtx.z -= m_Vertex_3d.Speed_vtx.z * 0.2f; //移動 m_Vertex_3d.vtx.x += m_Vertex_3d.Speed_vtx.x; m_Vertex_3d.vtx.y += m_Vertex_3d.Speed_vtx.y; m_Vertex_3d.vtx.z += m_Vertex_3d.Speed_vtx.z; //コインを全て取得したら if(CScore::GetScore() >= 500 && !clear) { CSter::Create(CRenderer::GetDevice(),D3DXVECTOR3(-48.0f,0.0f,48.0f),YEROWW_TEXTURE); clear = true; } //一定以上落下で死亡 if(m_Vertex_3d.vtx.y < -5.0f) { m_bDeath = true; PlaySound(SE_00,false); } //時間終了でもアウト if(CTime::TimeUp()) { m_bDeath = true; PlaySound(SE_00,false); } //地面にいるかの判定 if(m_Vertex_3d.vtx.y < pScene3d->GetHeight(m_Vertex_3d.vtx)) { //高さの指定 m_Vertex_3d.vtx.y = pScene3d->GetHeight(m_Vertex_3d.vtx); jump = false; if(m_motionType == MOTIONTYPE_JUMP) { SetMotion(MOTIONTYPE_NEUTRAL,8,true); } } //宙に浮いている場合 else { jump = true; } //ギミック更新処理 HitGimmick(); //壁にぶつかったかの判定 if(HitWall()) { m_Vertex_3d.vtx = oldVtx; } //モーションの更新 UpdateMotion(); //単発モーションが終了した場合 if(m_bFinishMotion) { if(m_bBlendMotion) { m_bBlendMotion = false; } if(GetMotion() == MOTIONTYPE_WALK) { SetMotion(MOTIONTYPE_NEUTRAL,20,true); } else { SetMotion(MOTIONTYPE_NEUTRAL,10,false); } m_bMotion = false; m_bFinishMotion = false; } }