c语言vc设计俄罗斯方块教程,c语言课程设计俄罗斯方块源代码.pdf

c语言课程设计俄罗斯方块源代码

1、 新建 “.h ”头文件,将 “头文件”

代码粘贴至其中,

2、 新建 “.c ”源文件,将 “源代码”

代码粘贴到其中。

3、 新建空白工程,将头文件和源代码

添加进去,调试使用。

//头文件

//1.自定义枚举类型,定义7 种形态的游戏方块

typedefenumtetris_shape

{

ZShape 0,

SShape,

LineShape,

TShape,

SquareShape,

LShape,

MirroredLShape

}shape;

//2.函数声明

//(1)操作方块函数

intmaxX();//取得当前方块的最大x 坐标

intminX();//取得当前方块的最小x 坐标

voidturn_left();//当前方块逆时针旋转90度

voidturn_right();

int out_of_table();

voidtransform();

int leftable();

intrightable();

int downable();

voidmove_left();

voidmove_right();

//(2)操作游戏桌面的函数

int add_to_table();

voidremove_full();

//(3)控制游戏函数

voidnew_game();

voidrun_game();

voidnext_shape();

intrandom(int seed);

//(4)绘图函数

voidpaint();

voiddraw_table();

//(5)其他功能函数

voidkey_down(WPARAMwParam);

voidresize();

voidinitialize();

void finalize();

//(6)回调函数,用来处理Windows 消息

LRESULTCALLBACKWndProc (HWND,UINT,WPARAM,LPARAM);

//源代码

//1.文件包含

#include

#include

#include

#include"tetris.h"

//2.常量定义

#defineAPP_NAME "TETRIS"

#defineAPP_TITLE "TetrisGame"

#defineGAMEOVER "GAME OVER"

#define SHAPE_COUNT7

#defineBLOCK_COUNT4

#defineMAX_SPEED 5

#defineCOLUMS 10

#defineROWS20

#defineRED RGB(255,0,0)

#defineYELLOWRGB(255,255,0)

#defineGRAYRGB(128,128,128)

#defineBLACKRGB(0,0,0)

#defineWHITERGB(255,255,255)

#define STONERGB(192,192,192)

#defineCHARS_IN_LINE 14

#define SCORE "SCORE %4d"

//3.全局变量定义

//(1)

char score_char[CHARS_IN_LINE] {0};

//(2)

char*press_enter "PressEnterkey...";

//(3)帮助提示信息

char *help[]

{

"pressspaceorupkey totransform shape.",

"Pressleft orright key tomover shape.",

"Pressdownkey to speedup.",

"Pressenterkey topausegame.",

"Enjoy it.:-)",

0

};

//(4)枚举游戏的状态

enum game_state

{

game_start,

game_run,

game_pause,

game_over,

}state game_start;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值