C++写吃豆人

以下是C++写吃豆人小游戏的源代码:

(别忘了给作者点赞哦)

#include <cstdio>
#include <iostream>
#include <ctime>
#include <conio.h>
#include <windows.h>       //停顿:Sleep(); 
#include <cstdlib>         //清屏:system("cls");
#include <cstring>         //1:'◎' 2:'⊙' 3:'▲' 4:'◆' 5:'■'
using namespace std;
int a[100][100], dir[100][100];
//string guo[5]={'▲','◆','■','▼','★'};
int fx[4][2] = { {0,-1},{1,0},{0,1},{-1,0} }; //ap来记录奖励块的分   
int n, m, ff, f = 1, t = 50, T = 50, ap = 10, egg[2], danshu, headx, heady, endx, endy, point = 0, apple = 0, fangx, stopp = 0, panduan = 0;  //ff用来判断  panduan 0:中途退出;1:咬到自己;2:重置  
int lastfx;
int zuobi = 0;
int fff[110][110];
string print[4][4] = { {"═","╔","  ","╚"},{"╝","║","╚","  "},{"  ","╗","═","╝"},{"╗"," ","╔","║"} };
void color(int a)//颜色函数
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), a);
}
void gotoxy(int x, int y)//位置函数(行为x 列为y)
{
COORD pos;
pos.X = 2 * y;
pos.Y = x;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos);
}
void reset() {
system("cls");
color(7); printf("                   ★"); color(10); printf("贪吃蛇"); color(11); printf("★\n\n"); color(7);
printf("⊙打印若有错位请调整窗口大小或按r重输小点的数⊙\n\n  请输入场地大小(格式:行数 列数) 推荐(20 20) \n\n>>");
scanf("%d%d", &n, &m);
system("cls");
color(14);
for (int i = 1; i <= m; i++) { gotoxy(0, i); printf("※"); gotoxy(n + 1, i); printf("※"); }
for (int i = 1; i <= n; i++) { gotoxy(i, 0); printf("※"); gotoxy(i, m + 1); printf("※"); }

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值