#include "Game.h" Game::Game(int gametype) { GameType = gametype; rotateTrajLeft = InertialTrajProcess(); rotateTrajRight = InertialTrajProcess(); leftFootStep = FootStep(); rightFootStep = FootStep(); rotateMatrix[0] = 1.0f; rotateMatrix[1] = 0.0f; rotateMatrix[2] = 0.0f; rotateMatrix[3] = 1.0f; leftStepRate = 0; rightStepRate = 0; leftRate = 0; rightRate = 0; if (GameType == RUNGAME) { rungame = RunGame(); } else if (GameType == DANCEGAME) { dancegame = DanceGame(); } else if (GameType == ORIGINTRAJ) { originTraj = OriginTraj(); } } void Game::GameProcess(int timeStamp, int* right_pos, int* right_att, int right_zupt, int* left_pos, int* left_att, int left_zupt, int jump, int down, int rssi, int girl_shoes) { leftFootStep.stepCal(timeStamp, left_pos, left_zupt); rightFootStep.stepCal(timeStamp, right_pos, right_zupt); if (GameType == RUNGAME) { //跑酷游戏处理函数 if (left_zupt) { rotateTrajLeft.ResetHeading(left_att[0]); } rotateTrajLeft.TrajRotate(left_pos); if (right_zupt) { rotateTrajRight.ResetHeading(right_att[0]); } rotateTrajRight.TrajRotate(right_pos); rungame.Process(right_pos, right_att, right_zupt, left_pos, left_att, left_zupt, jump, down, girl_shoes); //跑酷游戏处理结果获取 rungame.getResult(resultMatrix); } else if (GameType == DANCEGAME) { dancegame.Process(right_pos, right_att, right_zupt, left_pos, left_att, left_zupt, jump, down, rssi); dancegame.getResult(resultMatrix); } else if (GameType == ORIGINTRAJ) { originTraj.Process(right_pos, right_att, right_zupt, left_pos, left_att, left_zupt); } } void Game::RunGameProcess(int* right_pos, int* right_att, int right_zupt, int* left_pos, int* left_att, int left_zupt, int jump, int down, int girl_shoes) { rungame.Process( right_pos, right_att, right_zupt, left_pos, left_att, left_zupt, jump, down, girl_shoes); } void Game::getGameResult(int* matrix) { memcpy(matrix, resultMatrix, 4 * sizeof(int)); } int Game::getStepStatus(int left_or_right) { if (left_or_right == LEFT_FOOT) return leftFootStep.getStepStatus(); else if (left_or_right == RIGHT_FOOT) return rightFootStep.getStepStatus(); else return -1; } int Game::getStepFreq( int left_or_right) { if (left_or_right == LEFT_FOOT) return leftFootStep.getStepFreq(); else if (left_or_right == RIGHT_FOOT) return rightFootStep.getStepFreq(); else return -1; } int Game::getStepCount(int left_or_right) { if (left_or_right == LEFT_FOOT) return leftFootStep.getStepCount(); else if (left_or_right == RIGHT_FOOT) return rightFootStep.getStepCount(); else return -1; } float Game::getGamePos(int left_or_right, int index) { if (index < 0 || index >2) return -1; if (GameType == RUNGAME) { return -1; } else if(GameType == DANCEGAME) { return dancegame.getGamePos(left_or_right, index); } else if (GameType == ORIGINTRAJ) { return originTraj.getGamePos(left_or_right, index); } else { return -1; } } string Game::getVersion() { return GAME_VERSION; }