c언어 테트리스파일
본 자료는 미만의 자료로 미리보기를 제공하지 않습니다.
닫기
  • 1
해당 자료는 0페이지 까지만 미리보기를 제공합니다.
0페이지 이후부터 다운로드 후 확인할 수 있습니다.

소개글

c언어 테트리스파일에 대한 보고서 자료입니다.

목차

블럭모양설정
맵그리기
움직임 설정
블럭설정
블럭 지우기
게임오버

본문내용

#include
#include
#include
#include
#include

#define UP 72
#define DOWN 80
#define LEFT 75
#define RIGHT 77
#define maxx 16
#define maxy 22

void gotoxy(int x, int y);
void DrawMap();
void Move();
void PrintBlock(int x, int y, int block_num, int turn);
void EraseBlock(int x, int y, int block_num, int turn);
int check(int x, int y, int block_num, int turn);
void StopBlock(int x, int y, int block_num, int turn);
void FullLine();
void GameOver(int y);

int map[maxy][maxx];
int x,y;
int turn;
int bx, by;

int block[7][4][4][4]=//블럭 7개, 회전4개, 4*4에 블럭 표현
{
//I자 블럭
0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,
0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,
0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,
0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,

//사각형 블럭
0,1,1,0,0,1,1,0,0,0,0,0,0,0,0,0,
0,1,1,0,0,1,1,0,0,0,0,0,0,0,0,0,
0,1,1,0,0,1,1,0,0,0,0,0,0,0,0,0,
0,1,1,0,0,1,1,0,0,0,0,0,0,0,0,0,

//┐모양 블럭
1,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,
0,0,1,0,1,1,1,0,0,0,0,0,0,0,0,0,
0,1,0,0,0,1,0,0,0,1,1,0,0,0,0,0,
0,0,0,0,1,1,1,0,1,0,0,0,0,0,0,0,

//┌ 모양 블럭
0,1,1,0,0,1,0,0,0,1,0,0,0,0,0,0,
0,0,0,0,1,1,1,0,0,0,1,0,0,0,0,0,
0,1,0,0,0,1,0,0,1,1,0,0,0,0,0,0,
1,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,

//┴ 모양 블럭
0,1,0,0,1,1,1,0,0,0,0,0,0,0,0,0,
0,1,0,0,0,1,1,0,0,1,0,0,0,0,0,0,
0,0,0,0,1,1,1,0,0,1,0,0,0,0,0,0,
0,1,0,0,1,1,0,0,0,1,0,0,0,0,0,0,

//Z모양 블럭
1,1,0,0,0,1,1,0,0,0,0,0,0,0,0,0,
0,1,0,0,1,1,0,0,1,0,0,0,0,0,0,0,
1,1,0,0,0,1,1,0,0,0,0,0,0,0,0,0,
0,1,0,0,1,1,0,0,1,0,0,0,0,0,0,0,

//S모양 블럭
0,1,1,0,1,1,0,0,0,0,0,0,0,0,0,0,
0,1,0,0,0,1,1,0,0,0,1,0,0,0,0,0,
0,1,1,0,1,1,0,0,0,0,0,0,0,0,0,0,
0,1,0,0,0,1,1,0,0,0,1,0,0,0,0,0,
};

void TETRIS()
{
DrawMap();
Move();
system("PAUSE");
}

void gotoxy(int x, int y)
{
COORD Cur;
Cur.X=x;
Cur.Y=y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),Cur);
}

void DrawMap()
{
int i,j;
for(i=0;i {
map[i][0]=1;
map[i][maxx-1]=1;
}
for(j=0;j {
map[0][j]=1;
map[maxy-1][j]=1;
}
gotoxy(0,0);
for(i=0;i {
for(j=0;j if(map[i][j]!=0)
{
printf("□");
}
else if(map[i][j]==0)
{
printf(" ");
}
printf("\n");
}

}

void Move()
{
int key;

x=maxx/2-2;
y=1;
srand((unsigned)time(NULL));
int block_num=rand()%7;
turn=0;
int i;
for(i=0;;i++)
{
gotoxy(x,y);
PrintBlock(x, y, block_num, turn);
if(kbhit())
{
key=getch();
switch (key)
{
case UP:
EraseBlock(x, y, block_num, turn);
turn++;
if(check(x, y, block_num, turn%4)==1)
turn--;
else
turn%=4;
//y--;
//if(check(x, y, block_num, turn)==1)
// y++;
break;
case DOWN:
EraseBlock(x, y, block_num, turn);
y++;
if(check(x, y, block_num, turn)==1)
{
y--;
if(check(x, y, block_num, turn)==1)
y--;
GameOver(y);
PrintBlock(x, y, block_num, turn);
StopBlock(x, y, block_num, turn);
x=maxx/2-2;
y=1;
block_num=rand()%7;
turn=0;

키워드

  • 가격1,000
  • 페이지수1페이지
  • 등록일2011.05.02
  • 저작시기2010.9
  • 파일형식기타(h)
  • 자료번호#673750
본 자료는 최근 2주간 다운받은 회원이 없습니다.
청소해
다운로드 장바구니