C语言+EGE图形库小游戏吃豆子

本文介绍如何使用C语言结合EGE图形库编写一款有趣的吃豆子小游戏。通过实例代码,详细讲解游戏逻辑和图形绘制过程,适合初学者了解C语言图形编程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include <graphics.h>
void loadMenu();
void homeMenu();
void choice();
void introduce();
void createMap();
void enterNext();
void roleMove();
void mstMove();
void dieOver();
void crashJudge();
void showScore();
void gameOver();
//记录人物坐标重置坐标
//(row,col)
int row=0;
int col=0;
//记录怪物坐标
//(mstrow,mstcol)
int mstrow=0;
int mstcol=0;
//记录血量
int roleBlood=0;
//记录分数
int score=0;
//判断关卡
int lvFlag=0;
int TOTAL=0;
#define t1 20
#define t2 12
#define t3 10

#define WIDTH 10
#define LENGTH 10
#define BLR 9
#define BLC1 0
#define BLC2 1
#define BLC3 2



int pMap[WIDTH][LENGTH]={
  0};
const int pMap1[WIDTH][LENGTH]=
{
1,1,1,1,1,1,1,1,1,1,
1,9,0,0,0,0,0,0,9,1,
1,4,9,2,9,9,2,9,9,1,
1,0,2,9,9,9,9,2,0,1,
1,9,9,9,3,9,9,9,9,1,
1,0,2,9,9,9,9,2,0,1,
1,0,9,2,9,9,2,9,0,1,
1,0,0,0,0,0,0,0,0,1,
1,9,1,1,9,9,1,1,9,1,
10,10,10,9,9,9,9,9,9,9
};

const int pMap2[WIDTH][LENGTH]=
{
1,1,1,1,1,1,1,1,1,1,
1,0,0,2,0,0,0,0,0,1,
1,0,9,2,9,9,9,2,2,1,
1,0,9,2,9,9,9,9,0,1,
1,0,9,9,3,9,9,9,0,1,
1,9,9,9,9,9,2,9,9,1,
1,2,2,9,4,9,2,9,9,1,
1,9,9,9,9,9,2,9,9,1,
1,1,1,1,1,1,1,1,1,1,
10,10,
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值