내가 테트리스를 winapi.co.kr사이트에서 도움받아서 만들었거든.
근데 만들어 놓은걸 형이 보더니 피씩하면서, '태트리스는 초딩도 다 만드는건데 ㅋㅋㅋ' 라고 말하면서 개무시를 함.
나는 진심 내 초딩때 기억을 되살려봤을 때, 6학년때를 기준으로도 아래의 소스를 이해할 수 있을 것 같지는 않은데,
진짜 초딩들도 아래의 테트리스 소스정도는 걍 짜내는거야?
winapi사이트의 c 고급강좌 수준이 초등학생수준?
아래 소스는 winapi사이트에 등록된 코드.
#include <Turboc.h>
<o:p></o:p>
#define LEFT 75
#define RIGHT 77
#define UP 72
#define DOWN 80
#define ESC 27
#define BX 5
#define BY 1
#define BW 10
#define BH 20
<o:p></o:p>
void DrawScreen();
void DrawBoard();
BOOL ProcessKey();
void PrintBrick(BOOL Show);
int GetAround(int x,int y,int b,int r);
BOOL MoveDown();
void TestFull();
<o:p></o:p>
struct Point {
int x,y;
};
Point Shape[][4][4]={<o:p></o:p>
{ {0,0,1,0,2,0,-1,0}, {0,0,0,1,0,-1,0,-2}, {0,0,1,0,2,0,-1,0}, {0,0,0,1,0,-1,0,-2} },<o:p></o:p>
{ {0,0,1,0,0,1,1,1}, {0,0,1,0,0,1,1,1}, {0,0,1,0,0,1,1,1}, {0,0,1,0,0,1,1,1} },<o:p></o:p>
{ {0,0,-1,0,0,-1,1,-1}, {0,0,0,1,-1,0,-1,-1}, {0,0,-1,0,0,-1,1,-1}, {0,0,0,1,-1,0,-1,-1} },<o:p></o:p>
{ {0,0,-1,-1,0,-1,1,0}, {0,0,-1,0,-1,1,0,-1}, {0,0,-1,-1,0,-1,1,0}, {0,0,-1,0,-1,1,0,-1} },<o:p></o:p>
{ {0,0,-1,0,1,0,-1,-1}, {0,0,0,-1,0,1,-1,1}, {0,0,-1,0,1,0,1,1}, {0,0,0,-1,0,1,1,-1} },<o:p></o:p>
{ {0,0,1,0,-1,0,1,-1}, {0,0,0,1,0,-1,-1,-1}, {0,0,1,0,-1,0,-1,1}, {0,0,0,-1,0,1,1,1} },<o:p></o:p>
{ {0,0,-1,0,1,0,0,1}, {0,0,0,-1,0,1,1,0}, {0,0,-1,0,1,0,0,-1}, {0,0,-1,0,0,-1,0,1} },<o:p></o:p>
};<o:p></o:p>
<o:p></o:p>
enum { EMPTY, BRICK, WALL };
char *arTile[]={". ","■","□"};
int board[BW+2][BH+2];
int nx,ny;
int brick,rot;
<o:p></o:p>
void main()
{
int nFrame, nStay;
int x,y;
<o:p></o:p>
setcursortype(NOCURSOR);
randomize();
clrscr();
for (x=0;x<BW+2;x++) {
for (y=0;y<BH+2;y++) {
board[x][y] = (y==0 || y==BH+1 || x==0 || x==BW+1) ? WALL:EMPTY;
}
}
DrawScreen();
nFrame=20;
<o:p></o:p>
for (;1;) {
brick=random(sizeof(Shape)/sizeof(Shape[0]));
nx=BW/2;
ny=3;
rot=0;
PrintBrick(TRUE);
<o:p></o:p>
if (GetAround(nx,ny,brick,rot) != EMPTY) break;
nStay=nFrame;
for (;2;) {
if (--nStay == 0) {
nStay=nFrame;
if (MoveDown()) break;
}
if (ProcessKey()) break;
delay(1000/20);
}
}
clrscr();
gotoxy(30,12);puts("G A M E O V E R");
setcursortype(NORMALCURSOR);
}
<o:p></o:p>
void DrawScreen()
{
int x,y;
<o:p></o:p>
for (x=0;x<BW+2;x++) {
for (y=0;y<BH+2;y++) {
gotoxy(BX+x*2,BY+y);
puts(arTile[board[x][y]]);
}
}
<o:p></o:p>
gotoxy(50,3);puts("Tetris Ver 1.0");
gotoxy(50,5);puts("좌우:이동, 위:회전, 아래:내림");
gotoxy(50,6);puts("공백:전부 내림");
}
<o:p></o:p>
void DrawBoard()
{
int x,y;
<o:p></o:p>
for (x=1;x<BW+1;x++) {
for (y=1;y<BH+1;y++) {
gotoxy(BX+x*2,BY+y);
puts(arTile[board[x][y]]);
}
}
}
<o:p></o:p>
BOOL ProcessKey()
{
int ch,trot;
<o:p></o:p>
if (kbhit()) {
ch=getch();
if (ch == 0xE0 || ch == 0) {
ch=getch();
switch (ch) {
case LEFT:
if (GetAround(nx-1,ny,brick,rot) == EMPTY) {
PrintBrick(FALSE);
코드가 아랫부분이 짤렸넹;
난 테트리스 대학교2학년때서야 처음 만들었는데;;; 그것도 뭐 디자인 그딴거없이;;; 흑백의 세계였지만;;; 초딩이 어캐하냐! 초딩이 테트리스 만들실력이면 치킨집안해도 되겠네
테트리스를 촏잉이 만들다니 소스 보면서하면 만들수야있겠지만