//[6] 점수판 출력 void ShowPoint(void) { SetCursorPosition(40, 3); printf("테스리스"); SetCursorPosition(40, 5); printf("LEVEL : %d\n", level); SetCursorPosition(40, 7); printf("SCORE : %d\n", score); }
Coordinate GameInterface::AttackInterface(int startPointX, int startPointY) { int currentX = startPointX; int currentY = startPointY; Coordinate attackCoordinate; SetColor(WHITE, WHITE); SetCursorPosition(currentX, currentY); printf_s(" "); while (true) { int shipCoordX = (currentX - startPointX) / 4; int shipCoordY = (currentY - startPointY) / 2; SetCursorPosition(currentX, currentY); int keyinput; keyinput = _getch(); if (keyinput == -32) { keyinput = _getch(); } if (keyinput == KEY_DOWN || keyinput == KEY_RIGHT || keyinput == KEY_LEFT || keyinput == KEY_UP) { SetCursorAndColor(currentX, currentY, BLACK, BLACK); printf_s(" "); if (keyinput == KEY_DOWN && currentY < 2 * (m_MapSize - 1) + startPointY) { currentY += 2; } else if (keyinput == KEY_UP && currentY > startPointY) { currentY -= 2; } else if (keyinput == KEY_LEFT && currentX > startPointX) { currentX -= 4; } else if (keyinput == KEY_RIGHT && currentX < 4 * (m_MapSize - 1) + startPointX) { currentX += 4; } SetCursorAndColor(currentX, currentY, WHITE, WHITE); printf_s(" "); } else if (keyinput == SPACE) { attackCoordinate.m_X = rand() % m_MapSize; attackCoordinate.m_Y = rand() % m_MapSize; break; } else if (keyinput == ENTER) { attackCoordinate.m_X = shipCoordX; attackCoordinate.m_Y = shipCoordY; break; } } return attackCoordinate; }
Position GameInterface::PositionToSetShip(ShipType shipType) { Position tempPosition; tempPosition.m_X = FIRST_MAP_GOTOX; tempPosition.m_Y = FIRST_MAP_GOTOY; tempPosition.m_direction = DOWN; Position position; SetCursorPosition(FIRST_MAP_GOTOX, FIRST_MAP_GOTOY); m_GameRenderer->RenderShipOnMap(shipType, tempPosition); while (true) { int shipCoordX = (tempPosition.m_X - FIRST_MAP_GOTOX) / 4; int shipCoordY = (tempPosition.m_Y - FIRST_MAP_GOTOY) / 2; SetCursorPosition(tempPosition.m_X, tempPosition.m_Y); int keyinput; keyinput = _getch(); if (keyinput == -32) { keyinput = _getch(); } if (keyinput == KEY_DOWN || keyinput == KEY_UP || keyinput == KEY_LEFT || keyinput == KEY_RIGHT || keyinput == SPACE) { m_GameRenderer->RenderSpaceOnMap(shipType, tempPosition); if (keyinput == KEY_DOWN && tempPosition.m_Y < 2 * (m_MapSize - 1) + FIRST_MAP_GOTOY) { tempPosition.m_Y += 2; } else if (keyinput == KEY_UP && tempPosition.m_Y > FIRST_MAP_GOTOY) { tempPosition.m_Y -= 2; } else if (keyinput == KEY_LEFT && tempPosition.m_X > FIRST_MAP_GOTOX) { tempPosition.m_X -= 4; } else if (keyinput == KEY_RIGHT && tempPosition.m_X < 4 * (m_MapSize - 1) + FIRST_MAP_GOTOX) { tempPosition.m_X += 4; } else if (keyinput == SPACE) { tempPosition.m_direction = (Direction)(((int)tempPosition.m_direction + 1) % 4); } m_GameRenderer->RenderShipOnMap(shipType, tempPosition); } else if (keyinput == ENTER) { position.m_X = shipCoordX; position.m_Y = shipCoordY; position.m_direction = tempPosition.m_direction; break; } } return position; }
int main(int argc, char *argv[]) { unsigned char result[16]; int i; ClearScreen(0x07); SetCursorPosition(0, 0); for (i = 0; i < 6; ++i) { PutString("Test : "); PutUnsignedLongLong(&cases[i].a); PutString(" * "); PutUnsignedLongLong(&cases[i].b); PutString("\r\n"); PutString(" == "); PutUnsignedLongLong(&cases[i].rh); PutUnsignedLongLong(&cases[i].rl); PutString("\r\n"); llmultiply(cases[i].a, cases[i].b, result); PutString("Result "); PutUnsignedLongLong(&result[8]); PutUnsignedLongLong(&result[0]); PutString("\r\n"); PutString("\r\n"); } return 0; }
/*커서위치정보->배열위치정보 변경*/ arrX = arrX / 2 - 2; //콘솔좌표->배열 열 변환값 arrY = arrY - 2; //콘솔좌표->배열 행 변환값 //보드판에서 블록 이동시 1인식 for (y = 0; y < 4; y++) { for (x = 0; x < 4; x++) { if (blocks[n][y][x] == 1) { board[arrY + y][arrX + x] = 1; } } } } //[10] /*배열, 블록 옮김*/ void Stepper(int column) { int y, x; /*board배열 값 행 다운*/ for (y = column; y >= 0; y--) { for (x = 1; x <= 10; x++) { board[y][x] = board[y - 1][x]; } } /*board배열 0행에 0삽입*/ for (x = 1; x <= 10; x++) board[0][x] = 0; /*board배열 1값 전체 출력 */ for (y = 1; y <= 19; y++) { for (x = 1; x <= 10; x++) { SetCursorPosition((BOARD_X)+x * 2 + 1, y + BOARD_Y); if (board[y][x] == 1) printf("■"); else printf(" "); } } }
void AddPoint(int TailLength) { SetCursorPosition(MAX_WIDTH+5,MAX_HEIGHT/5); char buf[33]; itoa(TailLength-1,buf,10); printf("PUNKTY %s",buf); }
void BotClickFollowArea() { //—юды int ypos = 0; int xpos = 1; generator.seed(std::time(0)); // seed with the current time NumberDistribution distributiony(-50, 50); Generator numberGeneratory(generator, distributiony); int randomy = numberGeneratory(); NumberDistribution distributionx(-30, 30); Generator numberGeneratorx(generator, distributionx); int randomx = numberGeneratorx(); NumberDistribution distributionsleep(-280, 100); Generator numberGeneratorSleep(generator, distributionsleep); int randomsleep = numberGeneratorSleep(); if(ypos + randomy > 680) { randomy = 0; } SetCursorPosition(xpos + randomx, ypos + randomy); mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0); // нажали левую кнопку мыши mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0); // отпустили левую кнопку мыши ( Ќ≈ «јЅџ¬ј“№ ) BotSleep(0,0,0,0,0,0,0,0,0,0,0,0,300 + randomsleep); }
//[15] 게임 종료 화면 void EndGame() { SetCursorPosition(40, 15); printf("게임 종료"); getchar(); // 입력 대기 system("cls"); }
void BotIdentifyItems() { while(1) { SetCursorPosition(10,13); Sleep(400); CaptureScreen(&globalscreengrab); if(FindIdentifyColor(&globalscreengrab) == 0) { break; } else { SetCursorPosition(rx,ry); Sleep(500); CaptureScreen(&globalscreengrab); mouse_event(MOUSEEVENTF_RIGHTDOWN,0,0,0,0); // нажали левую кнопку мыши mouse_event(MOUSEEVENTF_RIGHTUP,0,0,0,0); // отпустили левую кнопку мыши ( НЕ ЗАБЫВАТЬ ) if(FindLegendaryItems(&globalscreengrab) == 1) { Sleep(7000); Item_x.push_back(rx); Item_y.push_back(ry); logprint("Легендарный предмет распознан и занесен в массив", 0); } else { Sleep(3000); CaptureScreen(&globalscreengrab); if(FindUsefulItems(&globalscreengrab) == 0) { //если вещь бесполезная тупо оставляем в инвентаре - выкинет на поле битвы logprint("Вещь бесполезна", 0); } else { Item_x.push_back(rx); Item_y.push_back(ry); logprint("Вещь полезна, занесена в массив", 0); } } } } }
void BotFollowFlag() { srand ( time(NULL) ); int followflagtype = rand() % 4 + 1; if(StartLevel == 0) { if(followflagtype == 1) { SetCursorPosition(rx + 20,ry + 20); } else if(followflagtype == 2) { SetCursorPosition(rx - 20,ry + 20); } else if(followflagtype == 3) { SetCursorPosition(rx - 20,ry - 20); } else if(followflagtype == 4) { SetCursorPosition(rx + 20,ry - 20); } } else { if(followflagtype == 1) { SetCursorPosition(367,228); } else if(followflagtype == 2) { SetCursorPosition(649,253); } else if(followflagtype == 3) { SetCursorPosition(346,450); } else if(followflagtype == 4) { SetCursorPosition(674,451); } } BotSleep(0,0,0,0,0,0,0,0,0,0,0,0,800); CaptureScreen(&globalscreengrab); if(BotGetFlagStatus(&globalscreengrab) == 1) { StartLevel = 0; mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0); // нажали левую кнопку мыши mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0); // отпустили левую кнопку мыши ( Ќ≈ «јЅџ¬ј“№ ) BotSleep(1,0,0,0,0,0,0,0,0,0,0,0,1000); } }
//[13] 현재 블록 클리어 void ClearBlock(int rotation, int move1, int move2) { int x, y; COORD cursor = GetCursorPosition(); if (CanPositionedAt(rotation, move1, move2) == true) { for (y = 0; y < 4; y++) { for (x = 0; x < 4; x++) { SetCursorPosition(cursor.X + (x * 2), cursor.Y + y); if (blocks[rotation][y][x] == 1) printf(" "); } } SetCursorPosition(cursor.X + move1, cursor.Y + move2); } }
void PrintDisplayBuffer() { while (true) { Sleep(100); _Get_Output_Mutex SetCursorPosition(0, 1); PrintPromptAndInfo(); _Release_Output_Mutex } }
void WebEditBox::LineEnd (void) { if (miCurrentLine == (miNumLines - 1)) { End(); } else { SetCursorPosition(GetLineOffset(miCurrentLine+1)-1); } }
void VogueWindow::TurnCursorOn(bool resetCursorPosition, bool forceOn) { if (IsCursorOn() == false) { glfwSetInputMode(m_pWindow, GLFW_CURSOR, GLFW_CURSOR_NORMAL); } if (resetCursorPosition) { SetCursorPosition(m_cursorOldX, m_cursorOldY); } }
//[8] 현재 위치에 블록 출력 void WriteBlock(int rotation) { int i, j; COORD cursor = GetCursorPosition(); if (CanPositionedAt(rotation, 0, 0) == true) { //콘솔창위치 설정, 배열값에서 1은 ■출력, 0은 출력없음 for (i = 0; i < 4; i++) // 행 반복 { for (j = 0; j < 4; j++) // 열 반복 { SetCursorPosition(cursor.X + (j * 2), cursor.Y + i); if (blocks[rotation][i][j] == 1) { printf("■"); } } } SetCursorPosition(cursor.X, cursor.Y); } }
//[5] 게임판 그리기 void DrawField(void) { int x, y; //중앙 보드 라인 for (x = 1; x <= BOARD_WIDTH + 1; x++) { board[BOARD_HEIGHT][x] = 1; //board 배열 중앙 1인식 SetCursorPosition((BOARD_X)+x * 2, BOARD_Y + BOARD_HEIGHT); //콘솔좌표 printf("━"); } //왼쪽 보드 라인 for (y = 0; y < BOARD_HEIGHT + 1; y++) { board[y][0] = 1; //board 배열 왼쪽 1인식 SetCursorPosition(BOARD_X, BOARD_Y + y); if (y == BOARD_HEIGHT) printf("┗"); else printf("ㅣ"); } //오른쪽 보드 라인 for (y = 0; y < BOARD_HEIGHT + 1; y++) { board[y][BOARD_WIDTH + 1] = 1; //board 배열 오른쪽 1인식 SetCursorPosition(BOARD_X + (BOARD_WIDTH + 2) * 2, BOARD_Y + y); if (y == BOARD_HEIGHT) printf("┛"); else printf("ㅣ"); } //모든 x값 y값 변경 board[20][0] = 1; board[20][11] = 1; puts(" "); }
void DrawScreen(char scr[][MAX_HEIGHT]) { scr[MAX_WIDTH/2][MAX_HEIGHT/2] = 'o'; for(int y = 0; y<MAX_HEIGHT; y++) { for(int x = 0; x<MAX_WIDTH; x++) printf("%c",scr[x][y]); printf("\n"); } SetCursorPosition(MAX_WIDTH+5,MAX_HEIGHT/5); printf("PUNKTY 0"); }
void GameManager::WriteGameResult(int who) { if (who < 0) return; if (m_GameType == PVP_PLAY || m_GameType == AI_PLAY) { SetCursorAndColor(24, 8, WHITE, BLACK); if (m_GameType == AI_PLAY && who == 1) printf_s(" AI WIN ", who + 1); else printf_s(" PLAYER %d WIN", who + 1); SetCursorPosition(24, 10); printf_s(" %d Turn ", m_Turn); } }
VOID CancelKeySelection( IN PCONSOLE_INFORMATION Console, IN BOOL JustCursor ) /*++ This routine terminates a key selection. --*/ { if (!JustCursor) { // // turn off selection flag // Console->Flags &= ~CONSOLE_SELECTING; SetWinText(Console,msgMarkMode,FALSE); } // // invert old select rect, if we have one. // if (Console->SelectionFlags & CONSOLE_SELECTION_NOT_EMPTY) { MyInvert(Console,&Console->SelectionRect); } else { ConsoleHideCursor(Console->CurrentScreenBuffer); } // restore text cursor if (Console->CurrentScreenBuffer->Flags & CONSOLE_TEXTMODE_BUFFER) { SetCursorInformation(Console->CurrentScreenBuffer, Console->TextCursorSize, Console->TextCursorVisible ); SetCursorPosition(Console->CurrentScreenBuffer, Console->TextCursorPosition, TRUE ); } ConsoleShowCursor(Console->CurrentScreenBuffer); }
void printMenu() { system("cls"); //clear the console window SetCursorPosition(10,2); // move the cursor to postion 30, 10 from top-left corner printf("1. Add new Route"); SetCursorPosition(10,4); printf("2. List all Routes"); SetCursorPosition(10,6); printf("3. Save routes to file"); SetCursorPosition(10,8); printf("4. List all Routes by country"); SetCursorPosition(10,10); printf("5. List all Routes from given season"); SetCursorPosition(10,12); printf("6. Delete route by code"); // option for deleting record SetCursorPosition(10,14); printf("7. Modify route by code"); // exit from the program SetCursorPosition(10,16); printf("8. Exit"); // exit from the program SetCursorPosition(10,18); printf("Your Choice: "); // enter the choice 1, 2, 3, 4, 5 }
void WebEditBox::LineUp (void) { if (miCurrentLine == 0) { return; } long iColumn = miCursorPos - GetLineOffset(miCurrentLine); long iIndex = iColumn + GetLineOffset(miCurrentLine - 1); if (iIndex >= GetLineOffset(miCurrentLine)) { iIndex = GetLineOffset(miCurrentLine) - 1; } SetCursorPosition(iIndex); }
void StyledTextBox::RemoveSelectedText() { if (!HasSelectedText()) { return; } auto text = GetStdText(); auto eraseStart = begin(text) + GetSelectionStart(); auto eraseEnd = eraseStart + (GetSelectionEnd() - GetSelectionStart()); text.erase(eraseStart, eraseEnd); SetCursorPosition(GetSelectionStart()); SetText(text); ClearSelection(); }
void ImfManager::CommitString( unsigned int serial, const std::string commit ) { DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::CommitString\n", commit.c_str() ); Dali::ImfManager handle( this ); Dali::ImfManager::ImfEventData imfEventData( Dali::ImfManager::COMMIT, commit, 0, 0 ); Dali::ImfManager::ImfCallbackData callbackData = mEventSignal.Emit( handle, imfEventData ); if( callbackData.update ) { SetCursorPosition( callbackData.cursorPosition ); SetSurroundingText( callbackData.currentText ); mEditCursorPosition = callbackData.cursorPosition; mPreEditCursorPosition = mEditCursorPosition; NotifyCursorPosition(); } }
void interpretChar(char c) { switch (engInfo.mode) { case PRINTING_MODE: switch (c) { case ASCII_ESC: engInfo.mode = INTERPRETING_MODE; break; case ASCII_CR: SetCursorPosition(ROW(TermInfo), 0); break; case ASCII_LF: NewLine(); break; case ASCII_BS: BackSpace(); break; case ASCII_BELL: Beep(750, 300); break; case 0x0F: // do nothing! break; default: PrintChar(c); break; } break; case INTERPRETING_MODE: engInfo.code[engInfo.codeLen] = c; switch (parseCode()) { case PARTIAL: engInfo.codeLen++; break; case VALID: resetCode(); break; case INVALID: resetCode(); break; } } }
void WebEditBox::LineDown (void) { if (miCurrentLine == miNumLines - 1) { return; } long iColumn = miCursorPos - GetLineOffset(miCurrentLine); long iIndex = iColumn + GetLineOffset(miCurrentLine + 1); if (miCurrentLine < miNumLines - 2) { if (iIndex >= GetLineOffset(miCurrentLine + 2)) { iIndex = GetLineOffset(miCurrentLine + 2) - 1; } } SetCursorPosition(iIndex); }
//[4] 시작 화면 및 콘솔 초기화 void ConsoleInit() { // 콘솔 초기화 및 시작 화면 구성 영역 printf(" 테트리스\n\n"); printf("" "=================================== \n" "조작법: \n" "[→] 오른쪽으로 이동 \n" "[←] 왼쪽으로 이동 \n" "[↑] 왼쪽으로 회전하기 \n" "[↓] 아래로 1칸 내 리 기 \n" "[Space] 아래로 떨어뜨리기 \n" " \n" "아무키나 누르면 시작됩니다. \n" "=================================== \n"); getch(); system("cls"); // Console.Clear(); CursorVisible(false); // 커서 숨기기 SetCursorPosition(0, 0); //보드표시 시작위치 설정 }
void FServerConsole::Serialize( const TCHAR* sData, ELogVerbosity::Type eVerbosity, const class FName& sCategory, const double fTime ) { FScopeLock hLock( &m_hLock ); #if PLATFORM_WINDOWS COORD hCursorPosition = GetCursorPosition(); #endif ClearInputLine(); m_pConsole->Serialize( sData, eVerbosity, sCategory, fTime ); RedrawInputLine(); #if PLATFORM_WINDOWS hCursorPosition.Y = GetCursorPosition().Y; SetCursorPosition( hCursorPosition ); #endif }
/* 1~10까지 행의 열 전체가 1로되면 블록사라짐. 사라지면 Stepper함수 실행 */ void RemoveLine(void) { int i; int x, y; int z = 0; // 19행부터 시작해서 1행까지 반복 for (y = 19; y >= 1; y--) { //행기준으로 4번 반복 for (z = 0; z < 4; z++) { i = 0; //1열부터 10열까지 증가 for (x = 1; x < 11; x++) { //행기준 if (board[y][x] == 1) { i++; //1이 10개면 행 블록 삭제 if (i == 10) { for (x = 1; x < 11; x++) { SetCursorPosition((x + 2) * 2, y + 2); printf(" "); } //행 기준으로 블록을 내리기 CountScore(); Stepper(y); } // end if } // end if } } } // end for } // end RemoveLine()
void StyledTextBox::OnKeyChar(wxKeyEvent& keyEvent) { // Process visible character input if (!keyEvent.HasModifiers()) { int keycode = keyEvent.GetRawKeyCode(); if (keycode < 255 && isprint(keycode)) { if (HasSelectedText()) { RemoveSelectedText(); } char c = (wxChar)keycode; auto text = GetStdText(); auto insertPosition = begin(text) + GetCursorPosition(); text.insert(insertPosition, c); SetText(text); SetCursorPosition(GetCursorPosition() + 1); } } }
void WebEditBox::LineHome (void) { SetCursorPosition(GetLineOffset(miCurrentLine)); }