bool Snake::play() { int direct; int moveRet; genTarget(); for (;;) { Sleep(Speed); direct = curDirect; if (_kbhit()) { char ch = (char)_getch(); if (ch < 0) { ch = (char)_getch(); switch (ch) { case KEY_UP: direct = D_NORTH; break; case KEY_DOWN: direct = D_SOUTH; break; case KEY_LEFT: direct = D_WEST; break; case KEY_RIGHT: direct = D_EAST; } } } if (isPlay) { moveRet = moveTo(direct); if (moveRet == -1) { endGame(); return false; } else if (moveRet > 0) { ++intLenght; genTarget(); } con->gotoxy(snakeHead.X, snakeHead.Y); } } }
/// called at end of a basic block with _bcIndex set to the next target /// returns with the next byte code index to translate at, which may not match the target provided /// if that target block has already been generated int32_t genBBEndAndBBStart() { genTarget(this->_bcIndex); return findNextByteCodeToGen(); }