c语言实现俄罗斯方块
发表在C语言视频课程答疑 2019-02-11 悬赏:8 学分
是否精华
版块置顶:

求解,大米粥老师讲解的俄罗斯方块项目,求大佬帮助解决一下错误


捕获.PNG


分享到:
精彩评论 7
18524814039
学分:19 LV2
2019-02-11
沙发
#include <stdio.h>
#include <conio.h>
#include <windows.h> 
#include <time.h> 


#define FrameX 13
#define FrameY 3
#define Frame_height 20
#define Frame_width 18

int i,j,temp,temp1,temp2;
int a[80][80]={0};//0,1,2
int b[4];//0,1
struct Tetris
{
	int x;
	int y;
	int flag;   
	int next;
	int speed;     
	int number; 
	int score;
	int level;
};
HANDLE hOut;
/********º¯  Êý  Éù  Ã÷********/
int color(int c);                          //¿ØÖÆ̨ÖеÄÎÄ×ÖÑÕÉ« 
void gotoxy(int x, int y);
void DrwaGameframe();
void Flag(struct Tetris *);
void MakeTetris(struct Tetris *mt);
void PrintTeris(struct Tetris *pt);
void CleanTetris(struct Tetris *);
int ifMove(struct Tetris *);
void Del_Fullline(struct Tetris *);
void Gameplay();
void regulation();
void explation();
void welcom();
void Replay(struct Tetris *);
void title();
void flower();
void close();



/*¿ØÖÆÎÄ×ÖÑÕÉ« 
 * 
 */
int color(int c)
{
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),c);
	return 0; 
} 

/*¿ØÖÆÎÄ×ÖÏÔʾλÖà
 * 
 */
void gotoxy(int x, int y)
{
	COORD pos;
	pos.X = x;
	pos.Y = y;
	SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),pos);
} 



/*²Ëµ¥Ñ¡Ïî 
 * 
 */
void welcom()
{
	int n; 
	int i,j = 1;
	color(14);
	for(i=9;i<=20;i++)
	{
		for(j=15;j<=60;j++)
		{
			gotoxy(j,i);
			if(i == 9 || i==20)
			printf("=");
			else if(j == 15 || j == 59)
			printf("||");
		}
			
	}
 	color(12);
 	gotoxy(25,12);
 	printf("1.¿ªÊ¼ÓÎÏ·");
	gotoxy(40,12);
	printf("2.°´¼ü˵Ã÷"); 
	gotoxy(25,17);
	printf("3.ÓÎÏ·¹æÔò");
	gotoxy(40,17); 
	printf("4.Í˳ö");
	
	color(3); 
	gotoxy(21,22); 
	printf("ÇëÑ¡Ôñ[1 2 3 4]£º[ ]\b\b"); 
	color(14);
	scanf("%d",&n);
	switch(n)
	{
		case 1:
			system("cls"); 
			DrwaGameframe();
			break;
		case 2:
			break;
		case 3:
			break;
		case 4:
			break;
	} 
} 

/*»¶Ó­½çÃæÉϵıêÌâ 
 * 
 */
void title()
{
	color(15);
	gotoxy(25,3);
	printf("Ȥ Î¶ ¶í Âޠ˹ ·½ ¿é"); 
	color(11);
	gotoxy(18,5);
	printf("¡ö");
	gotoxy(18,6);
	printf("¡ö¡ö");
	gotoxy(18,7);
	printf("¡ö");
	color(14);
	gotoxy(26,6);
	printf("¡ö¡ö");
	gotoxy(26,7);
	printf("  ¡ö¡ö");
	color(2);
	gotoxy(36,6);
	printf("¡ö¡ö");
	gotoxy(36,7);
	printf("¡ö¡ö");
	color(13);
	gotoxy(45,5);
	printf("¡ö");
	gotoxy(45,6);
	printf("¡ö");
	gotoxy(45,7);
	printf("¡ö");
	gotoxy(45,8);
	printf("¡ö");
	color(12);
	gotoxy(52,6);
	printf("¡ö");
	gotoxy(52,7);
	printf("¡ö¡ö¡ö");
}
18524814039
学分:19 LV2
2019-02-11
板凳

void flower()

{

color(12);

gotoxy(66,11);

printf("(_)");

gotoxy(64,12);

printf("(_) (_)");

color(14);

gotoxy(67,12);

printf("@");

color(12);

gotoxy(66,13);

printf("(_)");

color(14); 

gotoxy(71,12);

printf("|");

gotoxy(72,11);

printf("/");

gotoxy(70,13);

printf("\\|");

gotoxy(70,14);

printf("`|/");

gotoxy(70,15);

printf("\\|");

gotoxy(71,16);

printf("|/");

gotoxy(71,17);

printf("|");

color(10);

gotoxy(67,17);

printf("\\\\\\\\");

gotoxy(73,17);

printf("///");

color(2);

gotoxy(67,18);

printf("^^^^^^^^^");

color(13);

gotoxy(72,10);

printf("(_) (_)");

color(14);

gotoxy(75,10);

printf("@");

color(13);

gotoxy(74,9);

printf("(_)");

gotoxy(74,11);

printf("(_)");

color(14);

gotoxy(61,19);

printf("×÷Õߣº");

color(10);

gotoxy(65,20);

printf("ÉòÑô¹¤³ÌѧԺ");

gotoxy(65,21);

printf("Îï Áª Íø 181");

color(15);

gotoxy(68,22);

printf("ËÎÓ¢½¡"); 

}

18524814039
学分:19 LV2
2019-02-11
地板

void DrwaGameframe()

{

color(11);

gotoxy(FrameX+Frame_width-7,FrameY-2);

printf("Ȥζ¶íÂÞ˹·½¿é");

color(12); 

gotoxy(FrameX,FrameY);

printf("¨X");

gotoxy(FrameX+2*Frame_width-2,FrameY);

printf("¨[");

gotoxy(FrameX,FrameY+Frame_height);

printf("¨^");

gotoxy(FrameX+2*Frame_width-2,FrameY+Frame_height);

printf("¨a");

//ÉϺá¿ò

for(i=2;i< 2*Frame_width-2;i+=2) 

{

gotoxy(FrameX+i,FrameY);

printf("¨T");

}

//Ϻá¿ò

for(i=2;i< 2*Frame_width-2;i+=2) 

{

gotoxy(FrameX+i,FrameY+Frame_height);

printf("¨T");

a[FrameX+i][FrameY+Frame_height] = 2;

}

//×óÊú¿ò

for(i=1;i< Frame_height;i++) 

{

gotoxy(FrameX,FrameY+i);

printf("¨U");

a[FrameX][FrameY+i] = 2;

}

//ÓÒÊú¿ò

for(i=1;i< Frame_height;i++) 

{

gotoxy(FrameX+2*Frame_width-2,FrameY+i);

printf("¨U");

a[FrameX+2*Frame_width-2][FrameY+i] = 2;

}  

color(2);

gotoxy(FrameX+2*Frame_width+3,FrameY+7);

printf("**********");

gotoxy(FrameX+2*Frame_width+3,FrameY+13);

printf("**********");

color(3);

gotoxy(FrameX+2*Frame_width+13,FrameY+7); 

printf("ÏÂÒ»¸ö·½¿é¿é£º");

color(14);

gotoxy(FrameX+2*Frame_width+3,FrameY+17); 

printf("¡ü¼ü£ºÐýת");

gotoxy(FrameX+2*Frame_width+3,FrameY+19); 

printf("space¼ü£ºÔÝÍ£ÓÎÏ·");

gotoxy(FrameX+2*Frame_width+3,FrameY+15); 

printf("Esc¼ü£ºÐýת");

 


18524814039
学分:19 LV2
2019-02-11
4L

void MakeTetris(struct Tetris *)

{

a[tetris->x][tetris->y] = b[0];

switch(tetris->flag)

{

case 1:

{

color(10);

a[tetris->x][tetris->y-1] = b[1];

a[tetris->x+2][tetris->y-1] = b[2];   //Õý·½ÐÎ

a[tetris->x+2][tetris->y] = b[3];     

break;

}

case 2:

{

color(13);

a[tetris->x-2][tetris->y] = b[1];

a[tetris->x+2][tetris->y] = b[2];    //³¤·½ÐΣ¨ºáÌõ£© 

a[tetris->x+4][tetris->y] = b[3];

break; 



18524814039
学分:19 LV2
2019-02-11
5L

}

case 3:

{

color(13);

a[tetris->x][tetris->y-1] = b[1];

a[tetris->x][tetris->y+1] = b[2];    //³¤·½ÐΣ¨ÊúÌõ£© 

a[tetris->x][tetris->y+2] = b[3];

break; 

case 4:

{

color(11);

a[tetris->x-2][tetris->y] = b[1];

a[tetris->x+2][tetris->y] = b[2];    //¶¡×ÖÐΣ¨0¡ã£© 

a[tetris->x][tetris->y+1] = b[3];

break; 

}

case 5:

{

color(11);

a[tetris->x][tetris->y-1] = b[1];

a[tetris->x-2][tetris->y] = b[2];    //¶¡×ÖÐΣ¨90¡ã£© 

a[tetris->x][tetris->y+1] = b[3];

break; 

}

case 6:

{

color(11);

a[tetris->x-2][tetris->y] = b[1];

a[tetris->x+2][tetris->y] = b[2];    //¶¡×ÖÐΣ¨180¡ã£© 

a[tetris->x][tetris->y-1] = b[3];

break; 

}

case 7:

{

color(11);

a[tetris->x][tetris->y-1] = b[1];

a[tetris->x+2][tetris->y] = b[2];    //¶¡×ÖÐΣ¨270¡ã£© 

a[tetris->x][tetris->y+1] = b[3];

break; 

}

case 8:

{

color(14);

a[tetris->x-2][tetris->y] = b[1];

a[tetris->x+2][tetris->y+1] = b[2];    //ÕýZ×ÖÐΣ¨0¡ã£© 

a[tetris->x][tetris->y+1] = b[3];

break; 

}

case 9:

{

color(14);

a[tetris->x-2][tetris->y] = b[1];

a[tetris->x-2][tetris->y+1] = b[2];    //ÕýZ×ÖÐΣ¨90¡ã£© 

a[tetris->x][tetris->y-1] = b[3];

break; 

}

case 10:

{

color(14);

a[tetris->x-2][tetris->y+1] = b[1];

a[tetris->x+2][tetris->y] = b[2];    //·´Z×ÖÐΣ¨0¡ã£© 

a[tetris->x][tetris->y+1] = b[3];

break; 

}


18524814039
学分:19 LV2
2019-02-11
6L


case 11:

{

color(14);

a[tetris->x-2][tetris->y-1] = b[1];

a[tetris->x-2][tetris->y] = b[2];    //·´Z×ÖÐΣ¨90¡ã£© 

a[tetris->x][tetris->y+1] = b[3];

break; 

}

case 12:

{

color(12);

a[tetris->x][tetris->y-1] = b[1];

a[tetris->x+2][tetris->y] = b[2];    //ÕýL×ÖÐΣ¨0¡ã£© 

a[tetris->x][tetris->y-2] = b[3];

break; 

}

case 13:

{

color(12);

a[tetris->x+4][tetris->y] = b[1];

a[tetris->x+2][tetris->y] = b[2];    //ÕýL×ÖÐΣ¨90¡ã£© 

a[tetris->x][tetris->y+1] = b[3];

break; 

}

case 14:

{

color(12);

a[tetris->x][tetris->y+1] = b[1];

a[tetris->x-2][tetris->y] = b[2];    //ÕýL×ÖÐΣ¨180¡ã£© 

a[tetris->x][tetris->y+2] = b[3];

break; 

}

case 15:

{

color(12);

a[tetris->x-2][tetris->y] = b[1];

a[tetris->x-4][tetris->y] = b[2];    //ÕýL×ÖÐΣ¨270¡ã£© 

a[tetris->x][tetris->y-1] = b[3];

break; 

}

case 16:

{

color(12);

a[tetris->x][tetris->y-1] = b[1];

a[tetris->x-2][tetris->y] = b[2];    //·´L×ÖÐΣ¨0¡ã£© 

a[tetris->x][tetris->y-2] = b[3];

break; 

}

case 17:

{

color(12);

a[tetris->x+4][tetris->y] = b[1];

a[tetris->x+2][tetris->y] = b[2];    //·´L×ÖÐΣ¨90¡ã£© 

a[tetris->x][tetris->y-1] = b[3];

break; 

}

case 18:

{

color(12);

a[tetris->x][tetris->y+1] = b[1];

a[tetris->x+2][tetris->y] = b[2];    //·´L×ÖÐΣ¨180¡ã£© 

a[tetris->x][tetris->y+2] = b[3];

break; 

}

case 19:

{

color(12);

a[tetris->x-2][tetris->y] = b[1];

a[tetris->x-4][tetris->y] = b[2];    //·´L×ÖÐΣ¨270¡ã£© 

a[tetris->x][tetris->y+1] = b[3];

break; 

}

}

}



18524814039
学分:19 LV2
2019-02-11
7L


/*ÅжÏÊÇ·ñ¿ÉÒƶ¯ 

 * 

 */

int ifMove(struct Tetris *)

{

if(a[tetris->x][tetris->y] !=0) 

{

return 0; 

}else 

{

(tetris->flag == 1 && (a[tetris->x][tetris->y-1]==0 && a[tetris->x+2][tetris->y-1]==0 && a[tetris->x+2][tetris->y]==0))  ||

(tetris->flag == 2 && (a[tetris->x-2][tetris->y]==0 && a[tetris->x+2][tetris->y]==0 && a[tetris->x+4][tetris->y] ==0))   ||

(tetris->flag == 3 && (a[tetris->x][tetris->y-1]==0 && a[tetris->x][tetris->y+1]==0 && a[tetris->x][tetris->y+2] ==0))   ||

(tetris->flag == 4 && (a[tetris->x-2][tetris->y]==0 && a[tetris->x+2][tetris->y]==0 && a[tetris->x][tetris->y+1] ==0))   ||

(tetris->flag == 5 && (a[tetris->x][tetris->y-1]==0 && a[tetris->x-2][tetris->y]==0 && a[tetris->x][tetris->y+1] ==0))   ||

(tetris->flag == 6 && (a[tetris->x-2][tetris->y]==0 && a[tetris->x+2][tetris->y]==0 && a[tetris->x][tetris->y-1] ==0))   || 

(tetris->flag == 7 && (a[tetris->x][tetris->y-1]==0 && a[tetris->x+2][tetris->y]==0 && a[tetris->x][tetris->y+1] ==0))   ||

(tetris->flag == 8 && (a[tetris->x-2][tetris->y]==0 && a[tetris->x+2][tetris->y+1]==0 && a[tetris->x][tetris->y+1] ==0)) ||

(tetris->flag == 9 && (a[tetris->x-2][tetris->y]==0 && a[tetris->x-2][tetris->y+1]==0 && a[tetris->x][tetris->y-1] ==0)) ||

(tetris->flag == 10 && (a[tetris->x-2][tetris->y+1]==0 && a[tetris->x+2][tetris->y]==0 && a[tetris->x][tetris->y+1]==0))||

(tetris->flag == 11 && (a[tetris->x-2][tetris->y-1]==0 && a[tetris->x-2][tetris->y]==0 &&a[tetris->x][tetris->y+1]==0))||

(tetris->flag == 12 && (a[tetris->x][tetris->y-1]==0 && a[tetris->x+2][tetris->y]==0 && a[tetris->x][tetris->y-2]==0))||

(tetris->flag == 13 && (a[tetris->x+4][tetris->y]==0 && a[tetris->x+2][tetris->y]==0 && a[tetris->x][tetris->y+1]==0))||

(tetris->flag == 14 && (a[tetris->x][tetris->y+1]==0 && a[tetris->x-2][tetris->y]==0 && a[tetris->x][tetris->y+2]==0))||

(tetris->flag == 15 && (a[tetris->x-2][tetris->y]==0 && a[tetris->x-4][tetris->y]==0 && a[tetris->x][tetris->y-1]==0))||

(tetris->flag == 16 && (a[tetris->x][tetris->y-1]==0 && a[tetris->x-2][tetris->y]==0 && a[tetris->x][tetris->y-2]==0))||

(tetris->flag == 17 && (a[tetris->x+4][tetris->y]==0 && a[tetris->x+2][tetris->y]==0 && a[tetris->x][tetris->y-1]==0))||

(tetris->flag == 18 && (a[tetris->x][tetris->y+1]==0 && a[tetris->x+2][tetris->y]==0 && a[tetris->x][tetris->y+2]==0))||

(tetris->flag == 19 && (a[tetris->x-2][tetris->y]==0 && a[tetris->x-4][tetris->y]==0 && a[tetris->x][tetris->y+1]==0));

 

 

 

int main() 

{

title();

flower();

welcom();

}


首页上一页 1 下一页尾页 7 条记录 1/1页
手机同步功能介绍
友情提示:以下图书配套资源能够实现手机同步功能
明日微信公众号
明日之星 明日之星编程特训营
客服热线(每日9:00-17:00)
400 675 1066
mingrisoft@mingrisoft.com
吉林省明日科技有限公司Copyright ©2007-2022,mingrisoft.com, All Rights Reserved长春市北湖科技开发区盛北大街3333号长春北湖科技园项目一期A10号楼四、五层
吉ICP备10002740号-2吉公网安备22010202000132经营性网站备案信息 营业执照