日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

c语言俄罗斯方块源代码 解说,C语言课程设计俄罗斯方块源代码解说.doc

發布時間:2023/12/10 编程问答 24 豆豆
生活随笔 收集整理的這篇文章主要介紹了 c语言俄罗斯方块源代码 解说,C语言课程设计俄罗斯方块源代码解说.doc 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

新建“.h”頭文件,將“頭文件”代碼粘貼至其中,

新建“.c”源文件,將“源代碼”代碼粘貼到其中。

新建空白工程,將頭文件和源代碼添加進去,調試使用。

//頭文件

//1.自定義枚舉類型,定義7種形態的游戲方塊

typedef enum tetris_shape

{

ZShape=0,

SShape,

LineShape,

TShape,

SquareShape,

LShape,

MirroredLShape

}shape;

//2.函數聲明

//(1)操作方塊函數

int maxX();//取得當前方塊的最大x坐標

int minX();//取得當前方塊的最小x坐標

void turn_left();//當前方塊逆時針旋轉90度

void turn_right();

int out_of_table();

void transform();

int leftable();

int rightable();

int downable();

void move_left();

void move_right();

//(2)操作游戲桌面的函數

int add_to_table();

void remove_full();

//(3)控制游戲函數

void new_game();

void run_game();

void next_shape();

int random(int seed);

//(4)繪圖函數

void paint();

void draw_table();

//(5)其他功能函數

void key_down(WPARAM wParam);

void resize();

void initialize();

void finalize();

//(6)回調函數,用來處理Windows消息

LRESULT CALLBACK WndProc (HWND,UINT,WPARAM,LPARAM);

//源代碼

//1.文件包含

#include

#include

#include

#include"tetris.h"

//2.常量定義

#define APP_NAME "TETRIS"

#define APP_TITLE "Tetris Game"

#define GAMEOVER "GAME OVER"

#define SHAPE_COUNT 7

#define BLOCK_COUNT 4

#define MAX_SPEED 5

#define COLUMS 10

#define ROWS 20

#define RED RGB(255,0,0)

#define YELLOW RGB(255,255,0)

#define GRAY RGB(128,128,128)

#define BLACK RGB(0,0,0)

#define WHITE RGB(255,255,255)

#define STONE RGB(192,192,192)

#define CHARS_IN_LINE 14

#define SCORE "SCORE %4d"

//3.全局變量定義

//(1)

char score_char[CHARS_IN_LINE]={0};

//(2)

char* press_enter="Press Enter key...";

//(3)幫助提示信息

char *help[]=

{

"press space or up key to transform shape.",

"Press left or right key to mover shape.",

"Press down key to speed up.",

"Press enter key to pause game.",

"Enjoy it.:-)",

0

};

//(4)枚舉游戲的狀態

enum game_state

{

game_start,

game_run,

game_pause,

game_over,

}state=game_start;

//(5)定義方塊的顏色

COLORREF shape_color[]=

{

RGB(255,0,0),

RGB(0,255,0),

RGB(0,0,255),

RGB(255,255,0),

RGB(0,255,255),

RGB(255,0,255),

RGB(255,255,255)

};

//(6)方塊的7中類型

int shape_coordinate[SHAPE_COUNT][BLOCK_COUNT][2]=

{

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

總結

以上是生活随笔為你收集整理的c语言俄罗斯方块源代码 解说,C语言课程设计俄罗斯方块源代码解说.doc的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。