123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
- #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;
- }
|