Develop
2013.04.23 12:54
[c] 간단한 점 이동 샘플 소스코드
Views 6577 Comment 0
#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;
}
}
No. | Category | Subject | Author | Date | Views |
---|---|---|---|---|---|
229 | Develop |
[c] 디피-헬만 키교환(Diffie–Hellman key exchange) 샘플 코드.. ㅋㄷ
![]() |
hooni | 2013.04.23 | 9121 |
228 | Develop |
[mysql] 양력, 음력 DB데이터
![]() |
hooni | 2013.04.23 | 7841 |
227 | Develop | [c] 파일(int fd)에서 개행문자 단위로 읽기 by 후리자 | hooni | 2013.04.23 | 7162 |
226 | Develop |
[c] 지폰(gphone) 소스.. 수정(암호화)
![]() |
hooni | 2013.04.23 | 7440 |
225 | Develop |
[c] 암호 알고리즘 소스..
![]() |
hooni | 2013.04.23 | 8348 |
224 | Develop |
[c] 시스템 보안 과제.. 시간(amc time) 변경
![]() |
hooni | 2013.04.23 | 7203 |
223 | Develop | [switch] 시스코 카탈리스트(Cisco Catalyst) 2950 미러링 설정 | hooni | 2013.04.23 | 11419 |
222 | Develop |
[c] 네트워크 보안 프로그래밍 과제 (Server,Agent,Client)
![]() |
hooni | 2013.04.23 | 6487 |
221 | Develop |
[php] 탐색기와 같은 다이나믹 트리(xml/xsl 이용)
![]() |
hooni | 2013.04.23 | 7192 |
220 | Develop |
[js] 스타크래프트(starcraft)..
![]() |
hooni | 2013.04.23 | 6661 |
219 | Develop |
[js] 툴팁.. 좋은거.. (tooltip)
![]() |
hooni | 2013.04.23 | 7075 |
218 | Develop | [web] URL 인코딩 방법.. 테이블.. ㅋㅋ | hooni | 2013.04.23 | 7172 |