Contents

Views 7979 Comment 0
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print
#include <stdio.h>
#include <conio.h>
#include <windows.h>

#define STD_HANDLE GetStdHandle(STD_OUTPUT_HANDLE)

void gotoxy(int x, int y)
{
    COORD Cur= {(SHORT)x, (SHORT) y};
    SetConsoleCursorPosition(STD_HANDLE, Cur);
}


void main()
{
    int x = 0;  // x좌표
    int direction = 1;  // 방향. 1이면 오른쪽, -1이면 왼쪽

    while(1)
    {
        while(!kbhit())  // 키보드가 입력되지 않는 한
        {
            _sleep(500);  // 0.5초 쉼
            gotoxy(x, 10);  // 현재 자리에 있는
            putchar(' ');  // 점을 없애기 위해 공백 출력
            x = x + direction;  // x좌표 이동
            if(x == 80) x = 0;  // 만약에 80이면 한바퀴 돌았으므로 0으로
            else if(x == 0) x = 79;  // 0이면 왼쪽으로 한바퀴 돌았으므로 오른쪽 끝 79로
            gotoxy(x, 10);  // 이동한 좌표로
            putchar('.');  // 점 출력
        }
        int key = getch();  // 키보드 입력
        if(key == 0)  // 특수키이면
        {
            key = getch();  // 입력받은 것중 나머지
        }
        if(key == 0x4b)  // 왼쪽 커서이면
            direction = -1;
        else if(key == 0x4d)  // 오른쪽 커서이면
            direction = 1;
    }
}


?

List of Articles
No. Category Subject Author Date Views
231 Develop [vbs] CD롬 뱉는 스크립트.. hooni 2003.04.23 12669
230 Develop [c++] 기초강좌 #02(레퍼런스,메모리할당) hooni 2003.04.23 12693
229 Develop [c++] String Tokenizer (나중에 c 코드로 변경해서 사용할 것) hooni 2013.04.23 12693
228 Develop [c++] RSA Sample 4 CPP hooni 2013.04.23 12705
227 Develop [swift] NotificationCenter 간단 예제 file hooni 2021.01.27 12735
226 Develop [php] 배열 관련 함수 설명 ㅎㅎ hooni 2003.04.23 12745
225 Develop 페이팔에서 돈 찾기 (Paypal withdraw) file hooni 2014.02.20 12745
224 Develop [c] 테트리스(Tetris) 게임(도스용) 소스코드 file hooni 2003.04.23 12777
223 Develop [c] 시간 관련 함수 설명과 예제.. file hooni 2003.04.23 12780
222 Develop [c++] 기초강좌 #04(클래스) hooni 2003.04.23 12804
221 Develop [php] whois정보 조회 프로그램 hooni 2003.04.23 12831
220 Develop [unix] 유닉스 명령에 메타문자 사용 hooni 2014.02.19 12852
Board Pagination Prev 1 ... 47 48 49 50 51 52 53 54 55 56 ... 71 Next
/ 71