C语言俄罗斯方块游戏源代码
俄罗斯方块 变形 c语言
俄罗斯方块变形c语言
在C语言中实现俄罗斯方块游戏是一项复杂的任务,涉及到图形界面、游戏逻辑和事件处理等多个方面。以下是一个简化版的俄罗斯方块游戏示例,使用字符在控制台中显示游戏界面。
c复制代码
#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#define WIDTH 20
#define HEIGHT 10
typedef enum {
BLOCK_EMPTY,
BLOCK_I,
BLOCK_J,
BLOCK_L,
BLOCK_O,
BLOCK_S,
BLOCK_Z
} BlockType;
typedef struct {
BlockType type;
int x;
int y;
} Block;
Block board[WIDTH][HEIGHT];
BlockType currentBlock = BLOCK_I;
int rotation = 0;
int x = WIDTH / 2;
int y = HEIGHT - 1;
void drawBoard() {
for (int i = 0; i < WIDTH; i++) { for (int j = 0; j < HEIGHT; j++) { char ch = ' ';
switch (board[i][j].type) {
case BLOCK_EMPTY:
ch = '.';
break;
case BLOCK_I:
ch = 'I';
break;
case BLOCK_J:
俄罗斯方块C语言源代码
俄罗斯方块C语言源代码.txt43风帆,不挂在桅杆上,是一块无用的布;桅杆,不挂上风帆,是一根平常的柱;理想,不付诸行动是虚无缥缈的雾;行动,而没有理想,是徒走没有尽头的路。44成功的门往往虚掩着,只要你勇敢去推,它就会豁然洞开。#include #include
#include
#include
#include
#ifdef __cplusplus
#define __CPPARGS ...
#else
#define __CPPARGS
#endif
#define MINBOXSIZE 15 /* 最小方块的尺寸 */
#define BGCOLOR 7 /* 背景着色 */
#define GX 200
#define GY 10
#define SJNUM 10000 /* 每当玩家打到一万分等级加一级*/
/* 按键码*/
#define VK_LEFT 0x4b00
#define VK_RIGHT 0x4d00
#define VK_DOWN 0x5000
#define VK_UP 0x4800
#define VK_HOME 0x4700
#define VK_END 0x4f00
#define VK_SPACE 0x3920
#define VK_ESC 0x011b
#define VK_ENTER 0x1c0d
/* 定义俄罗斯方块的方向(我定义他为4种)*/
#define F_DONG 0
#define F_NAN 1
#define F_XI 2
#define F_BEI 3
#define NEXTCOL 20 /* 要出的下一个方块的纵坐标*/
俄罗斯方块C语言代码
>
include <>
include <>
include <>
__cplusplus
define __CPPARGS ...
else
define __CPPARGS
define MINBOXSIZE 15 / 最小方块的尺寸 /
define BGCOLOR 7 / 背景着色 /
define GX 200
define GY 10
define SJNUM 10000 / 每当玩家打到一万分等级加一级/ / 按键码/
define VK_LEFT 0x4b00
define VK_RIGHT 0x4d00
define VK_DOWN 0x5000
define VK_UP 0x4800
define VK_HOME 0x4700
define VK_END 0x4f00
define VK_SPACE 0x3920
define VK_ESC 0x011b
define VK_ENTER 0x1c0d
/ 定义俄罗斯方块的方向我定义他为4种/
define F_DONG 0
define F_NAN 1
define F_XI 2
define F_BEI 3
define NEXTCOL 20 / 要出的下一个方块的纵坐标/ define NEXTROW 12 / 要出的下一个方块的横从标/ define MAXROW 14 / 游戏屏幕大小/
define MAXCOL 20
define SCCOL 100 /游戏屏幕大显示器上的相对位置/ define SCROW 60
俄罗斯方块c代码
/********************************************** 游戏名称:俄罗斯方块
**********************************************/
#ifndef BLOCK_H_H
#define BLOCK_H_H
#include
#include
#include
using namespace std;
#define WIDTH 10 //游戏区宽度
#define HEIGHT 22 //游戏区高度
#define SIZE 10 //方块大小
#define KIND 8 //方块种类
#define ID_LEFT 0
#define ID_RIGHT 1
#define ID_DOWN 2
#define ID_UP 3
#define ID_TIMER 4
//八种方块
struct BLOCK
{
WORD dir[4];
COLORREF color;
};
//当前方块、下一方块
struct BLOCKINFO
{
byte id:3;
char x,y;
byte dir:2;
};
enum DRAW
{
SHOW,//显示方块
HIDE//隐藏方块
};
///////////定义函数////////////////
void Init(HDC hdc); //初始化
void NewGame(HDC hdc); //新游戏
void GameOver(); //游戏结束
void NewBlock(HDC hdc); //产生新方块
bool CheckBlock(BLOCKINFO block); //检查是否可放下方块
俄罗斯方块c语言源代码
俄罗斯方块c语言源代码
俄罗斯方块游戏是一款非常受欢迎的游戏,使用C语
言编写源代码实现其功能。下面是俄罗斯方块游戏的C语
言源代码:
1. 创建窗口函数: // 创建窗口函数 void CreateWindow(int width, int height) { // 使用
SDL库创建窗口 SDL_Init(SDL_INIT_EVERYTHING); SDL_Window *window = SDL_CreateWindow("Tetris",
SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
width, height, 0); // 设置刷新时间
SDL_SetHint(SDL_HINT_RENDER_VSYNC, "1"); }
2. 创建游戏函数: // 创建游戏函数 void CreateGame() { // 设置随机数种子
srand((unsigned int)time(NULL)); // 加载游戏资
源 LoadResources(); // 初始化游戏数据InitGameData(); // 初始化游戏界面
InitGameUI(); // 开始游戏循环 GameLoop(); // 清理游戏资源 CleanupGame(); }
3. 绘图函数: // 绘图函数 void Draw(int x, int
y, Color color) { // 使用SDL库在指定位置绘制
指定颜色的矩形 SDL_Rect rect; rect.x = x;
俄罗斯方块源代码
C语言俄罗斯方块源代码
Vc6.0编译通过
#include<windows.h>
#include<stdio.h>
#include<time.h>
#include<stdlib.h>
#include<malloc.h>
#include<conio.h>
#define MAP_WIDTH10
#define MAP_HEIGHT20
#define BLOCKM"■"
#define BKBLOCK"□"
#define OUTSTD GetStdHandle(STD_OUTPUT_HANDLE)
typedef int(*PFUN)(void *pData);
void ShowMapArray(int map[MAP_HEIGHT][MAP_WIDTH]);
//生成方块
int xyIsInarrBlock(int arrBlock[4][2], int x, int y) //有返回1 没有返回0 {
int i;
for (i = 0;i<4;i++)
if (arrBlock[i][0] == x && arrBlock[i][1] == y)
return 1;
return 0;
}
void GetTransBlocks(int arrBlock[4][2])//坐标模式4*4方块
{
int nTmp, x, y;
int nCount = 1;
int i;
int nMinx = 0, nMiny = 0;
memset(arrBlock, 0, 8 * sizeof(int));
c语言 俄罗斯方块 源代码
#include #include #include #include #include #define SIZE 16#define COLOR WHITE#define BKCOLOR BLACK#define WIGHT 12#define HIGHT 22struct shape{int xy[8] ;int color ;int next ;};struct shape shapes[19] ={{ 0 + 5, -2 , 0 + 5, -1 , 0 + 5, 0 , 1 + 5, 0 , RED , 1},{-1 + 5, 0 , 0 + 5, 0 , 1 + 5, -1 , 1 + 5, 0 , RED , 2},{ 0 + 5, -2 , 1 + 5, -2 , 1 + 5, -1 , 1 + 5, 0 , RED , 3},{-1 + 5, -1 , -1 + 5, 0 , 0 + 5, -1 , 1 + 5, -1 , RED , 0},{ 0 + 5, -2 , 0 + 5, -1 , 0 + 5, 0 , 1 + 5, -2 , BLUE , 5},{-1 + 5, -1 , -1 + 5, 0 , 0 + 5, 0 , 1 + 5, 0 , BLUE , 6},{ 0 + 5, 0 , 1 + 5, -2 , 1 + 5, -1 , 1 + 5, 0 , BLUE , 7},{-1 + 5, -1 , 0 + 5, -1 , 1 + 5, -1 , 1 + 5, 0 , BLUE , 4},{-1 + 5, 0 , 0 + 5, -1 , 0 + 5, 0 , 1 + 5, 0 , GREEN , 9},{ 0 + 5, -1 , 1 + 5, -2 , 1 + 5, -1 , 1 + 5, 0 , GREEN , 10},{-1 + 5, -1 , 0 + 5, -1 , 0 + 5, 0 , 1 + 5, -1 , GREEN , 11},{ 0 + 5, -2 , 0 + 5, -1 , 0 + 5, 0 , 1 + 5, -1 , GREEN , 8},{-1 + 5, 0 , 0 + 5, -1 , 0 + 5, 0 , 1 + 5, -1 , LIGHTMAGENTA , 13},{ 0 + 5, -2 , 0 + 5, -1 , 1 + 5, -1 , 1 + 5, 0 , LIGHTMAGENTA , 12},{-1 + 5, -1 , 0 + 5, -1 , 0 + 5, 0 , 1 + 5, 0 , BROWN , 15},{ 0 + 5, -1 , 0 + 5, 0 , 1 + 5, -2 , 1 + 5, -1 , BROWN , 14},{ 0 + 5, -3 , 0 + 5, -2 , 0 + 5, -1 , 0 + 5, 0 , MAGENTA , 17},{-1 + 5, -1 , 0 + 5, -1 , 1 + 5, -1 , 2 + 5, -1 , MAGENTA , 16},{ 0 + 5, -1 , 0 + 5, 0 , 1 + 5, -1 , 1 + 5, 0 , LIGHTBLUE, 18}};struct shape tmpshapes;struct shape tmpshapes1;struct _Cloro{int color;};struct _Cloro Colors[WIGHT][HIGHT] = {0};BYTE Game_Word[WIGHT][HIGHT] = {0};int X;int Y;int Score;int times;/*-1 0 1 2-3□□□□-2□□□□-1□□□□0□■□□□□□□ □□□□ □□□□ □□□□ □■□□ □□□□ □■■□ □□□□ □■□□ □□■□ □□■□ ■■■□ □■■□ ■■■□ □□■□ ■□□□ □□□□ □□□□ □□□□ □□□□ □■□□ □■■□ □□□□ □□□□ □■□□ □■□□ □■□□ □■■□ □■■□ □■□□ ■■■□ ■■□□ □□□□ □■□□ □□□□ □□□□ □■□□ □□□□ ■■□□ □■□□ □■■□ □■■□ □■□□ □■■□ -8-7-6-5-4-3-2-1 0 1 2 3 4 5 6 7 8 9 10111213141516171819202122232425262728293031-4□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□-3□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□-2□□□□□□□□□□□□□□□□□□□□□□□□□
自己用C语言编写的俄罗斯方块小游戏 hello world级
#include #include #include#include#include#include "time.h"#include "fb_draw.h"#define SMALL_CUBSIZE 4#define X_SMALL_START 500#define Y_SMALL_START 100#define SMALL_UNIT 10#define BIG_CUBSIZE_X 16#define BIG_CUBSIZE_Y 12#define BIG_UNIT 25int small_cub[SMALL_CUBSIZE][SMALL_CUBSIZE]={0};int big_cub[BIG_CUBSIZE_X][BIG_CUBSIZE_Y]={0};int record[BIG_CUBSIZE_X][BIG_CUBSIZE_Y]={0};int record2[BIG_CUBSIZE_X][BIG_CUBSIZE_Y]={0};static int small_color;static int big_color=0xa0;static int stop_flag=0,count=0;static int flag1=0,flag2;struct termios old,new;void clear_screen(){ int x,y; for (x = 0; x < xres(); x++) for (y = 0; y < yres(); y++) { fb_draw_point(x, y, 0x0); }}void draw_frame(){ int x,y; for(x=99,y=99;x<402;x++) fb_draw_point(x, y, 0xbf); for(x=99,y=99;y<502;y++) fb_draw_point(x, y, 0xbf); for(x=401,y=99;y<502;y++) fb_draw_point(x, y, 0xbf); for(x=99,y=501;x<402;x++) fb_draw_point(x, y, 0xbf);}void zero_cub(int x,int y,int chosen){ int i,j; for(i=0;i for(j=0;j if(chosen==1) small_cub[i][j]=0; else big_cub[i][j]=0; } }}void small_cub_select(int a){ int i,j; zero_cub(SMALL_CUBSIZE,SMALL_CUBSIZE,1); switch(a){ case 0: for(i=0;i<2;i++){ for(j=0;j<2;j++) small_cub[i][j]=1; } break; case 1: for(i=0;i<4;i++) small_cub[0][i]=1; break; case 2: for(i=0;i<4;i++) small_cub[i][0]=1; break; case 3: for(i=0;i<2;i++) small_cub[0][i]=1; for(i=1;i<3;i++) small_cub[1][i]=1; break; case 4: for(i=1;i<3;i++) small_cub[i][0]=1; for(i=0;i<2;i++) small_cub[i][1]=1; break; case 5: for(i=1;i<3;i++) small_cub[0][i]=1; for(i=0;i<2;i++) small_cub[1][i]=1; break; case 6: for(i=0;i<2;i++) small_cub[i][0]=1; for(i=1;i<3;i++) small_cub[i][1]=1; break; case 7: for(i=0;i<3;i++) small_cub[i][0]=1; small_cub[0][1]=1; break; case 8: for(i=0;i<3;i++) small_cub[0][i]=1; small_cub[1][2]=1; break; case 9: for(i=0;i<3;i++) small_cub[i][1]=1; small_cub[2][0]=1; break; case 10: for(i=0;i<3;i++) small_cub[1][i]=1; small_cub[0][0]=1; break; case 11: for(i=0;i<3;i++) small_cub[i][1]=1; small_cub[0][0]=1; break; case 12: for(i=0;i<3;i++) small_cub[1][i]=1; small_cub[0][2]=1; break; case 13: for(i=0;i<3;i++) small_cub[i][0]=1; small_cub[2][1]=1; break; case 14: for(i=0;i<3;i++) small_cub[0][i]=1; small_cub[1][0]=1; break; case 15: for(i=0;i<3;i++) small_cub[1][i]=1; small_cub[0][1]=1; break; case 16: for(i=0;i<3;i++) small_cub[i][0]=1; small_cub[1][1]=1; break; case 17: for(i=0;i<3;i++) small_cub[0][i]=1; small_cub[1][1]=1; break; case 18: for(i=0;i<3;i++) small_cub[i][1]=1; small_cub[1][0]=1; break; default : return ; }}void clear_small_screen(){
俄罗斯方块C语言代码
#include
#include
#include
#include
#include
#ifdef__cplusplus
#define __CPPARGS ...
#else
#define __CPPARGS
#endif
#define MINBOXSIZE 15 /* 最小方块的尺寸*/
#define BGCOLOR 7 /* 背景着色*/
#define GX 200
#define GY 10
#define SJNUM 10000 /* 每当玩家打到一万分等级加一级*/ /* 按键码*/
#define VK_LEFT 0x4b00
#define VK_RIGHT 0x4d00
#define VK_DOWN 0x5000
#define VK_UP 0x4800
#define VK_HOME 0x4700
#define VK_END 0x4f00
#define VK_SPACE 0x3920
#define VK_ESC 0x011b
#define VK_ENTER 0x1c0d
/* 定义俄罗斯方块的方向(我定义他为4种)*/
#define F_DONG 0
#define F_NAN 1
#define F_XI 2
#define F_BEI 3
#define NEXTCOL 20 /* 要出的下一个方块的纵坐标*/
#define NEXTROW 12 /* 要出的下一个方块的横从标*/
#define MAXROW 14 /* 游戏屏幕大小*/
#define MAXCOL 20
#define SCCOL 100 /*游戏屏幕大显示器上的相对位置*/
C语言编程俄罗斯方块的算法及源代码
//俄罗斯方块
#include "stdio.h"
#include "conio.h"
#include "stdlib.h"
#include "windows.h"
#include "time.h"
#define N 17
#define M 13
#define K 19
int s[N][M]={{0,0,0},{0,0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0}, {1},{1,0,0,1},{1,1,1,1,1,1,0,1,1,0,0,1,1}};/*当前状态*/
int
a[K][3][3]={{0,2,0,2,2,2},{0,2,0,2,2,0,0,2},{0,2,0,0,2,2,0,2},{2,2,2,0,2},{2,2,2,0,0,2 ,0},
{2,0,0,2,2,2},{2,0,0,2,0,0,2,2},{0,0,2,0,0,2,0,2,2},{0,0,2,2,2,2},{2,2,2,2,0,0}, {2,2,0,0,2,0,0,2,0},{0,2,2,0,2,0,0,2,0},{{2},{2},{2}},{2,2,2},{2,2,0,2,2,0},
{2,0,0,2,2,0,0,2},{0,0,2,0,2,2,0,2},{2,2,0,0,2,2},{0,2,2,2,2,0}};
void Disp()
{
int i,j;
for(i=0;i<N;i++)
{
for(j=0;j<M;j++)
printf("%c",s[i][j]?48+s[i][j]:' ');
俄罗斯方块C源代码
/* *俄罗斯方块源程序 */ #include <stdio.h> #include <stdlib.h> #include <dos.h> #include <graphics.h> /*图形函数库*/
/*定义按键码*/ #define VK_LEFT 0x4b00 #define VK_RIGHT 0x4d00 #define VK_DOWN 0x5000 #define VK_UP 0x4800 #define VK_ESC 0x011b #define TIMER 0x1c /*设置中断号*/
sprintf(stemp," -Turn Left -Turn Right"); stemp[0]=27; stemp[13]=26;
outtextxy(xs+40,ys+45,stemp); outtextxy(xs+40,ys+60,"Esc-Exit "); setcolor(FgColor); }
SIZE; x=oldx; } Curbox_x=x; Curbox_y=y;/*x,y 是保存方块的当前坐标的*/ flag_newbox=false; /*是否要产生新方块的标记 0*/
俄罗斯方块(C语言)
#include <stdlib.h>
#include <graphics.h>
#include <bios.h>
#define mDRAW 5
#define mLINE 6
#define mADOWN 7
#define mGEN 8
#define mLEFT 75
#define mRIGHT 77
#define mSPACE 57
#define mDOWN 80
#define mESC 1
#define TIMEINT 2
#define MAXX 9
#define MAXY 30
#define BACKCOLOR BLACK
#define WINX 50
#define WINY 470
#define GAP 6
#define AREAX (WINX+GAP)
#define AREAY (WINY-GAP)
#define BOXW 15
int oldarea[MAXY+1][MAXX];
int area[MAXY+1][MAXX];
int actW,actH,actX,actY;
int curX,curY,curColor,curW,curH;
int newX,newY,newColor,newW,newH; int active;
int box[4][4];
int FORCOLOR;
int MESSAGE;
int BOX[7][4][4]={
{
{1,1,1,1},
{0,0,0,0},
{0,0,0,0},
{0,0,0,0}
},{
{1,1,1,0},
C语言俄罗斯方块游戏源代码
C语言俄罗斯方块游戏源代码
/*学无止境*/ #include
#include
#include
#define ESC 27
#define UP 328
#define DOWN 336
#define LEFT 331
#define RIGHT 333
#define BLANK 32
#define BOTTOM 2
#define CANNOT 1
#define CAN 0
#define MAX 30
#define F1 315
#define ADD 43
#define EQUAL 61
#define DEC 45
#define SOUNDs 115
#define SOUNDS 83
#define PAUSEP 80
#define PAUSEp 112
void Init();
void Down();
void GoOn();
void ksdown();
void Display(int color);
void Give();
int Touch(int x,int y,int dx,int dy);
int GeyKey();
void Select();
void DetectFill();
void GetScores();
void Fail();
void Help();
void Quit();
void DrawBox(int x,int y,int Color);
void OutTextXY(int x,int y,char *String); void DispScore(int x,int y,char Ch);
俄罗斯方块游戏代码
#include <stdio.h>
#include <dos.h>
#include <conio.h>
#include <graphics.h>
#include <stdlib.h>
#ifdef __cplusplus
#define __CPPARGS ...
#else
#define __CPPARGS
#endif
#define MINBOXSIZE 15 /* 最小方块的尺寸*/
#define BGCOLOR 7 /* 背景着色*/
#define GX 200
#define GY 10
#define SJNUM 10000 /* 每当玩家打到一万分等级加一级*/ /* 按键码*/
#define VK_LEFT 0x4b00
#define VK_RIGHT 0x4d00
#define VK_DOWN 0x5000
#define VK_UP 0x4800
#define VK_HOME 0x4700
#define VK_END 0x4f00
#define VK_SPACE 0x3920
#define VK_ESC 0x011b
#define VK_ENTER 0x1c0d
/* 定义俄罗斯方块的方向(我定义他为4种)*/
#define F_DONG 0
#define F_NAN 1
#define F_XI 2
#define F_BEI 3
#define NEXTCOL 20 /* 要出的下一个方块的纵坐标*/
#define NEXTROW 12 /* 要出的下一个方块的横从标*/
C语言实现俄罗斯方块小游戏
C语⾔实现俄罗斯⽅块⼩游戏C语⾔实现俄罗斯⽅块⼩游戏的制作代码,具体内容如下
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#define TTY_PATH "/dev/tty"
#define STTY_ON "stty raw -echo -F"
#define STTY_OFF "stty -raw echo -F"
int map[21][14];
char direct;
int node[7][4][16]={
{{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,0,0,0,1,0,0,0,1,0,0,0,1,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,0}},
{{0,1,0,0,1,1,1,0,0,0,0,0,0,0,0,0},//3边加⼀中点
{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},
用C语言写俄罗斯方块 源代码
// 程序名称:俄罗斯方块
// 编译环境:Visual C++ 6.0,EasyX 2011惊蛰版
// 程序编写:krissi <zhaoh1987@>
// 最后更新:2010-12-18
//
#include "graphics.h"
#include <conio.h>
#include <time.h> /////////////////////////////////////////////
// 定义常量、枚举量、结构体、全局变量
/////////////////////////////////////////////#define WIDTH 10 // 游戏区宽度
#define HEIGHT 22 // 游戏区高度
#define SIZE 20 // 每个游戏区单位的实际像素// 定义操作类型
enum CTRL
{
CTRL_ROTATE, // 方块旋转
CTRL_LEFT, CTRL_RIGHT, CTRL_DOWN, // 方块左、右、下移动
CTRL_SINK, // 方块沉底
CTRL_QUIT // 退出游戏
};// 定义绘制方块的方法
enum DRAW
{
SHOW, // 显示方块
HIDE, // 隐藏方块
FIX // 固定方块
};// 定义七种俄罗斯方块
struct BLOCK
{
WORD dir[4]; // 方块的四个旋转状态
COLORREF color; // 方块的颜色
} g_Blocks[7] = { {0x0F00, 0x4444, 0x0F00, 0x4444, RED}, // I
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
/*学无止境*/ #include
#include
#include
#define ESC 27
#define UP 328
#define DOWN 336
#define LEFT 331
#define RIGHT 333
#define BLANK 32
#define BOTTOM 2
#define CANNOT 1
#define CAN 0
#define MAX 30
#define F1 315
#define ADD 43
#define EQUAL 61
#define DEC 45
#define SOUNDs 115
#define SOUNDS 83
#define PAUSEP 80
#define PAUSEp 112
void Init();
void Down();
void GoOn();
void ksdown();
void Display(int color);
void Give();
int Touch(int x,int y,int dx,int dy);
int GeyKey();
void Select();
void DetectFill();
void GetScores();
void Fail();
void Help();
void Quit();
void DrawBox(int x,int y,int Color);
void OutTextXY(int x,int y,char *String); void DispScore(int x,int y,char Ch);
void DrawNext(int Color);
int Heng=12,Shu=20; /*横竖*/
int Position[MAX][MAX];
int middle[MAX][MAX];
int ActH,ActS;
int Act,Staus;
int i,j,k;
int Wid=10;
int NoPass=CAN;
float Delays=15000;
int BeginH=250,BeginS=7;
float Seconds=0;
int Scores=0;
int flag=1;
int Sounds=CAN;
int PreAct,NextAct;
int a[8][4][4][4]={{{1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0}, {1,1,1,1,0,0,0,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},
{1,1,1,1,0,0,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,0},
{1,1,0,0,1,1,0,0,0,0,0,0,0,0,0,0}},
{{1,1,1,0,0,1,0,0,0,0,0,0,0,0,0,0},
{0,1,0,0,1,1,0,0,0,1,0,0,0,0,0,0},
{0,1,0,0,1,1,1,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}}, {{1,0,0,0,1,1,0,0,0,1,0,0,0,0,0,0}, {0,1,1,0,1,1,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}, {0,1,1,0,1,1,0,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}, {1,1,0,0,0,1,1,0,0,0,0,0,0,0,0,0}}, {{1,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0}, {1,1,0,0,1,0,0,0,1,0,0,0,0,0,0,0}, {1,1,1,0,0,0,1,0,0,0,0,0,0,0,0,0}, {0,1,0,0,0,1,0,0,1,1,0,0,0,0,0,0}}, {{0,0,1,0,1,1,1,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}, {1,1,1,0,1,0,0,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}}, {{1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0}}}; int b[4][4];
main(int argc,char *argv[])
{
if (argc!=1)
{
if (argv[1]!="")
Heng=atoi(argv[1]);
if (argv[2]!="")
Shu=atoi(argv[2]);
}
Init(); /*初始化界面*/
PreAct=random(8); /*取得当前的方块*/
for(;;) /*以下是游戏流程*/
{
NextAct=random(8); /*取得下一个方块*/ DrawNext(1); /*画出下一个方块*/
Act=PreAct;
if (Heng%2==0) ActH=Heng/2;
else ActH=(Heng-1)/2;
ActS=0; /*方块开始从游戏空间的中间下落*/ Staus=0; /*取开始的状态*/
NoPass=CAN; /*物体可以下落*/
Give(); /*取得当前的方块*/