GameObjc.mm 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  1. #import "GameObjc.h"
  2. #include "Game.h"
  3. #include "DanceGame.h"
  4. #include "FootStep.h"
  5. #include "InertialTrajProcess.h"
  6. //#include "OriginTraj.h"
  7. @interface GameObjc()
  8. {
  9. @private
  10. Game *game;
  11. int gametype;
  12. }
  13. @end
  14. @implementation GameObjc
  15. - (instancetype)initWithGametype:(int)gametype{
  16. self = [super init];
  17. if (self){
  18. gametype = gametype;
  19. game = new Game(gametype);
  20. }
  21. return self;
  22. }
  23. - (void)gameProcess:(int)timeStamp
  24. rightPos:(int *)rightPos
  25. rightAtt:(int *)rightAtt
  26. rightZupt:(int)rightZupt
  27. right_press:(int)right_press
  28. leftPos:(int *)leftPos
  29. leftAtt:(int *)leftAtt
  30. leftZupt:(int)leftZupt
  31. left_press:(int)left_press
  32. jump:(int)jump
  33. down:(int)down
  34. rssi:(int)rssi
  35. girl_shoes:(int)girl_shoes{
  36. game->GameProcess(timeStamp, rightPos, rightAtt, rightZupt,right_press,leftPos, leftAtt, leftZupt, left_press,jump, down, rssi,girl_shoes);
  37. }
  38. - (void)runGameProcess:(int *)rightPos
  39. rightAtt:(int *)rightAtt
  40. rightZupt:(int)rightZupt
  41. leftPos:(int *)leftPos
  42. leftAtt:(int *)leftAtt
  43. leftZupt:(int)leftZupt
  44. jump:(int)jump
  45. down:(int)down
  46. girl_shoes:(int)girl_shoes{
  47. game->RunGameProcess(rightPos, rightAtt, rightZupt, leftPos, leftAtt, leftZupt, jump, down,girl_shoes);
  48. }
  49. - (void)getGameResult:(int *)matrix{
  50. game->getGameResult(matrix);
  51. }
  52. - (int)getStepFreq:(int)leftOrRight{
  53. return game->getStepFreq(leftOrRight);
  54. }
  55. - (int)getStepStatus:(int)leftOrRight{
  56. return game->getStepStatus(leftOrRight);
  57. }
  58. - (int)getStepCount:(int)leftOrRight{
  59. return game->getStepCount(leftOrRight);
  60. }
  61. - (float)getGamePos:(int)left_or_right index:(int)index{
  62. return game->getGamePos(left_or_right, index);
  63. }
  64. - (void)start{
  65. game->start(nil);
  66. }
  67. - (void)end{
  68. game->end();
  69. }
  70. - (void)isBingo{
  71. game->isBingo();
  72. }
  73. -(int)getInteractionCMD{
  74. return game->getInteractionCMD();
  75. }
  76. /// 向外提供,手动释放
  77. - (void)handRelease{
  78. delete game;
  79. }
  80. - (void)dealloc{
  81. delete game;
  82. }
  83. @end
  84. @interface RunGameObjc ()
  85. {
  86. @private
  87. RunGame * runGame;
  88. }
  89. @end
  90. @implementation RunGameObjc
  91. - (instancetype)init{
  92. self = [super init];
  93. if (self) {
  94. runGame = new RunGame();
  95. }
  96. return self;
  97. }
  98. - (int)getResultLeftRight:(int *)pos
  99. devNum:(short)devNum{
  100. return runGame->getResultLeftRight(pos, devNum);
  101. }
  102. - (int)getResultJump:(short)jump{
  103. return runGame->getResultJump(jump);
  104. }
  105. - (int)getResultDown:(short)down{
  106. return runGame->getResultDown(down);
  107. }
  108. - (void)setResultConLeft:(short)zupt{
  109. runGame->setResultConLeft(zupt);
  110. }
  111. - (void)setResultConRight:(short)zupt{
  112. runGame->setResultConRight(zupt);
  113. }
  114. - (int)getResultLeft:(int *)pos girl_shoes:(int)girl_shoes{
  115. return runGame->getResultLeft(pos,girl_shoes);
  116. }
  117. - (int)getResultRight:(int *)pos girl_shoes:(int)girl_shoes{
  118. return runGame->getResultRight(pos,girl_shoes);
  119. }
  120. - (void)process:(int *)rightPos
  121. rightAtt:(int *)rightAtt
  122. rightZupt:(int)rightZupt
  123. leftPos:(int *)leftPos
  124. leftAtt:(int *)leftAtt
  125. leftZupt:(int)leftZupt
  126. jump:(int)jump
  127. down:(int)down
  128. girl_shoes:(int)girl_shoes{
  129. runGame->Process(rightPos, rightAtt, rightZupt, leftPos, leftAtt, leftZupt, jump, down,girl_shoes);
  130. }
  131. - (void)getResult:(int *)dec{
  132. runGame->getResult(dec);
  133. }
  134. /// 向外提供,手动释放
  135. - (void)handRelease{
  136. delete runGame;
  137. }
  138. - (void)dealloc{
  139. delete runGame;
  140. }
  141. @end
  142. @interface DanceGameObjc ()
  143. {
  144. @private
  145. DanceGame *danceGame;
  146. }
  147. @end
  148. @implementation DanceGameObjc
  149. - (instancetype)init{
  150. self = [super init];
  151. if (self) {
  152. danceGame = new DanceGame();
  153. }
  154. return self;
  155. }
  156. //- (int)gamePositionProcess:(int *)pos
  157. // stepPos:(int *)stepPos
  158. // rssi:(int)rssi
  159. // hostOrSlave:(short)hostOrSlave{
  160. // //SInt16 ==> short*
  161. // return danceGame->game_position_process(pos, stepPos, rssi, hostOrSlave);
  162. //}
  163. //- (void)gameBoundary:(int *)globalPos{
  164. // danceGame->game_boundary(globalPos);
  165. //}
  166. //- (int)getDirectionFloat:(float *)pos
  167. // rssi:(int)rssi{
  168. // //float==>32位
  169. // return danceGame->getDirectionFloat(pos,rssi);
  170. //}
  171. //- (short)danceGameProcess:(int *)pos
  172. // zupt:(short)zupt
  173. // rssi:(int)rssi
  174. // hostOrSlave:(short)hostOrSlave{
  175. // return danceGame->dance_game_process(pos, zupt, rssi, hostOrSlave);
  176. //}
  177. - (void)process:(int *)rightPos
  178. rightAtt:(int *)rightAtt
  179. rightZupt:(int)rightZupt
  180. right_press:(int)right_press
  181. leftPos:(int *)leftPos
  182. leftAtt:(int *)leftAtt
  183. leftZupt:(int)leftZupt
  184. left_press:(int)left_press
  185. jump:(int)jump
  186. down:(int)down
  187. rssi:(int)rssi{
  188. danceGame->Process(rightPos, rightAtt, rightZupt, right_press,leftPos, leftAtt, leftZupt, left_press,jump, down, rssi);
  189. }
  190. - (void)getResult:(int *)matrix{
  191. danceGame->getResult(matrix);
  192. }
  193. //- (float)getRssiDistance:(int)rssi{
  194. // return danceGame->getRssiDistance(rssi);
  195. //}
  196. //- (int)savePosAndRssi:(int *)pos
  197. // zupt:(short)zupt
  198. // rssi:(int)rssi
  199. // hostOrSlave:(short)hostOrSlave{
  200. // return danceGame->savePosAndRssi(pos, zupt, rssi, hostOrSlave);
  201. //}
  202. /// 向外提供,手动释放
  203. - (void)handRelease{
  204. delete danceGame;
  205. }
  206. - (void)dealloc{
  207. delete danceGame;
  208. }
  209. @end
  210. @interface FootStepObjc ()
  211. {
  212. @private
  213. FootStep *footStep;
  214. }
  215. @end
  216. @implementation FootStepObjc
  217. - (instancetype)init{
  218. self = [super init];
  219. if (self) {
  220. footStep = new FootStep();
  221. }
  222. return self;
  223. }
  224. //pos开辟3个空间
  225. - (void)stepCal:(int)timeStamp posList:(int *)pos zupt:(int)zupt{
  226. footStep->stepCal(timeStamp, pos, zupt);
  227. }
  228. - (int)getStepFreq{
  229. return footStep->getStepFreq();
  230. }
  231. - (int)getStepStatus{
  232. return footStep->getStepStatus();
  233. }
  234. - (int)getStepCount{
  235. return footStep->getStepCount();
  236. }
  237. - (void)dealloc{
  238. delete footStep;
  239. }
  240. /// 向外提供,手动释放
  241. - (void)handRelease{
  242. delete footStep;
  243. }
  244. @end
  245. @interface InertialTrajProcessObjc ()
  246. {
  247. @private
  248. InertialTrajProcess * inertialTrajProcess;
  249. }
  250. @end
  251. @implementation InertialTrajProcessObjc
  252. - (instancetype)init{
  253. self = [super init];
  254. if (self) {
  255. inertialTrajProcess = new InertialTrajProcess();
  256. }
  257. return self;
  258. }
  259. - (void)trajRotate:(int *)pos{
  260. inertialTrajProcess->TrajRotate(pos);
  261. }
  262. //rotateMatrix只能开辟4个空间
  263. - (void)trajRotate:(int *)pos
  264. rotateMatrix:(float *)rotateMatrix{
  265. inertialTrajProcess->TrajRotate(pos,rotateMatrix);
  266. }
  267. - (void)resetHeading:(short)heading{
  268. inertialTrajProcess->ResetHeading(heading);
  269. }
  270. /// 向外提供,手动释放
  271. - (void)handRelease{
  272. delete inertialTrajProcess;
  273. }
  274. - (void)dealloc{
  275. delete inertialTrajProcess;
  276. }
  277. @end
  278. //@interface OriginTrajObj ()
  279. //{
  280. // @private
  281. // OriginTraj * originTraj;
  282. //}
  283. //@end
  284. //@implementation OriginTrajObj
  285. //- (instancetype)init{
  286. // self = [super init];
  287. // if (self){
  288. // originTraj = new OriginTraj();
  289. // }
  290. // return self;
  291. //}
  292. //
  293. //- (void)process:(int*)right_pos
  294. // right_att:(int*)right_att
  295. // right_zupt:(int)right_zupt
  296. // left_pos:(int*)left_pos
  297. // left_att:(int*)left_att
  298. // left_zupt:(int) left_zupt{
  299. // originTraj->Process(right_pos, right_att, right_zupt, left_pos, left_att, left_zupt);
  300. //}
  301. //
  302. //- (float)getGamePos:(int)left_or_right
  303. // index:(int)index{
  304. // return originTraj->getGamePos(left_or_right, index);
  305. //}
  306. //
  307. ///// 向外提供,手动释放
  308. //- (void)handRelease{
  309. // delete originTraj;
  310. //}
  311. //- (void)dealloc{
  312. // delete originTraj;
  313. //}
  314. //@end