c語言編寫的小遊戲

2021-06-21 00:51:34 字數 1577 閱讀 5939

#include

#include

#include

#include

#include

#include

#include "conf.h" 

typedef struct node

node; 

typedef struct

snake;

typedef struct                    

frame; 

typedef enum                     //四個方向

direction; 

typedef enum

bool;//*/ 

void initgraphmode();                     //初始化圖形驅動

void closegraphmode();                

void foot(int,int);                            

void head(int,int);

void createframe();                     //完成整個遊戲框架的繪製    

void createsnake();     //建立一條兩個節點的蛇,蛇的每一節是佇列中的乙個節點

bool playgame();                         //遊戲的主體函式,

int hit(int,int);      //判斷是否越界,或者撞到自身,兩個引數分別是新的頭接點的x,y座標

bool gameover();                         //繪製遊戲結束時彈出的對話方塊                       

void enqueue(node);                     //入隊函式

node dequeue();                         //出隊函式

void clearkeybuf();     //清除鍵盤緩衝,此函式可以消除不停的按無效鍵的影響 

snake snake;

frame frame;

void main()

while(playgame());

closegraphmode();}

void initgraphmode()

void closegraphmode()

void createframe()

void createsnake()

bool playgame()

}while(overlap==true);

randomnode.x=randx;

randomnode.y=randy;

randomnode.next=null;

setfillstyle(solid_fill,red);

bar(randomnode.x+1,randomnode.y+1,randomnode.x+blockwidth-1,randomnode.y+blockheight-1);

neednode=false;

C語言小遊戲 生命遊戲

使用的是microsoft visual studio 2017開發環境 lifegame.cpp 定義控制台應用程式的入口點。include stdafx.h include include include include define high 25 define width 50 全域性變數 ...

C語言小遊戲 掃雷

1.這個小遊戲由兩個原始檔,乙個標頭檔案分工合作完成。test.c game.c game.h 2.確定基本框架,在test.c中寫主函式以及遊戲所需的基本框架 例如 menum switch 3.先確定這個遊戲需要的函式功能,在game.h中進行函式宣告,game.c中進行函式的定義,test.c...

C語言 掃雷小遊戲

第一次下子,不炸死 座標周圍沒雷,可以實現展開 遊戲結束後展示玩家用時 game.h ifndef game h define game h include include include include define row 12 define col 12 define count 10 棋盤中...