当前位置:编程学习 > VC++ >>

俄罗斯方块(C语言版,VC6下实现)

 

思想很老套了,擦除+矩阵打表,都是前人的东西,这里就不班门弄斧了,只有膜拜,虔诚的膜拜……

不过只有自己亲手敲过,才能体会各中艰辛,真的很蛋疼……

以后玩游戏再遇到易做图的bug 了还是留点口德吧,开发者各种不容易啊……

还有就是我发现群众的想象力是惊人的,各种idea ,各种易做图的方块,有创意的,恶搞的方块层出不穷,网上一搜,发现只有你想不到的,没有人家还没做出来的,唉,创意啊,永远是游戏的灵魂,继续努力吧

 

code:

PS:代码挺丑的,见谅,还有不少bug,欢迎板砖,欢迎鄙视……

 

#include<stdio.h> 

#include<stdlib.h> 

#include<windows.h> 

#include<time.h> 

#include<conio.h> 

 

#define MOD 28 

#define SIZE_N 19 

#define SIZE_M 12 

 

int cur_x,cur_y,score,mark,next,map[SIZE_N][SIZE_M],Gamespeed=300; 

char key1,key; 

 

int shape[28][6]={//这是个比较偷懒的方法,就是7种方块,加上旋转总共28种 

    {0,-1,0,-2,1,0}, {0,1,1,0,2,0}, {-1,0,0,1,0,2}, {0,-1,-1,0,-2,0}, 

    {0,-1,0,1,-1,0}, {0,1,1,0,-1,0}, {1,0,0,-1,0,1}, {1,0,-1,0,0,-1}, 

    {-1,1,0,1,1,0}, {0,-1,1,0,1,1}, {-1,0,0,-1,1,-1}, {-1,-1,-1,0,0,1}, 

    {-1,0,0,1,1,1}, {0,1,1,-1,1,0}, {-1,0,0,1,1,1}, {0,1,1,-1,1,0}, 

    {-1,0,0,-1,0,-2}, {-1,0,-2,0,0,1}, {0,1,0,2,1,0}, {0,-1,1,0,2,0}, 

    {0,1,1,0,1,1}, {0,-1,1,0,1,-1}, {-1,0,0,-1,-1,-1}, {-1,0,-1,1,0,1}, 

    {0,1,0,2,0,3}, {1,0,2,0,3,0}, {0,-1,0,-2,0,-3}, {-1,0,-2,0,-3,0} 

}; 

 

void gotoxy(int x,int y){//gotoxy在TC中是在system.h库文件里的一个函 

    COORD c; 

    c.X=x-1; c.Y=y-1; 

    SetConsoleCursorPosition (GetStdHandle(STD_OUTPUT_HANDLE), c); 

void Gameover(){//游戏结束的判断 

    int i,j,flag=0; 

    for(j=1;j<SIZE_M-1;j++){ 

        if(map[1][j]!=0){ 

            flag=1;break; 

        } 

    } 

    if(flag==1){ 

        for(i=1;i<SIZE_N-1;i++){ 

            gotoxy(2,i+1); 

            for(j=1;j<SIZE_M-1;j++){ 

                printf("□"); 

            }puts(""); 

        } 

        gotoxy(7,9); 

        printf("GAME OVER!"); 

        gotoxy(1,SIZE_N+1); 

        exit(0); 

    } 

void ShowMap(int id){ 

    int i,j; 

    gotoxy(1,1); 

    if(id!=-1){ 

        for(i=0;i<SIZE_N;i++){ 

            for(j=0;j<SIZE_M;j++){ 

                if(i==0&&j==0 || i==0&&j==SIZE_M-1 || j==0&&i==SIZE_N-1 || j==SIZE_M-1&&i==SIZE_N-1)printf(" "); 

                else if(i==0 || i==SIZE_N-1)printf("--"); 

                else if(j==0 || j==SIZE_M-1)printf("|"); 

                else if(map[i][j]==2) printf("■"); 

                else if(i==cur_x+shape[id][0] && j==cur_y+shape[id][1] || 

                    i==cur_x+shape[id][2] && j==cur_y+shape[id][3] || 

                    i==cur_x+shape[id][4] && j==cur_y+shape[id][5] || 

                    i==cur_x && j==cur_y) 

                    printf("■"); 

                else if(map[i][j]==0) printf("  ");  

            } 

            if(i==1)printf("   next:"); 

            if(i==11)printf("   score :   %d",score); 

            if(i==14)printf("   speed :   %d",score/100+1); 

            puts(""); 

        } 

    } 

    else { 

        mark=1; 

        for(i=0;i<SIZE_N;i++){ 

            for(j=0;j<SIZE_M;j++){ 

                if(i==0&&j==0 || i==0&&j==SIZE_M-1 || j==0&&i==SIZE_N-1 || j==SIZE_M-1&&i==SIZE_N-1)printf(" "); 

                else if(i==0 || i==SIZE_N-1)printf("--"); 

                else if(j==0 || j==SIZE_M-1)printf("|"); 

                else if(map[i][j]==2) printf("■"); 

                else if(map[i][j]==0) printf("  ");  

            } 

            if(i==1)printf("   next:"); 

            if(i==11)printf("   score :   %d",score); 

   &nbs

补充:软件开发 , Vc ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,