美文网首页
玩游戏吗😂

玩游戏吗😂

作者: 闸合 | 来源:发表于2020-03-16 20:24 被阅读0次

备忘录里的,我都忘了是啥的代码了🤕

#include<graphics.h>

#include<stdio.h>

#include<conio.h>

#include<time.h>

struct XY

{

int x;

int y;

struct XY *next;

};

enum direction

{

up, down, left, right

};

void main()

{

srand((unsigned)time(nullptr));

initgraph(800, 600, NOMINIMIZE);

setbkcolor(BROWN);

cleardevice();

setfillcolor(LIGHTGRAY);

solidrectangle(60, 60, 540, 540);

setcolor(YELLOW);

settextstyle(25, 0, _T("楷体"));

outtextxy(600, 100, _T("喜欢就抢制作"));

outtextxy(580, 140, _T("WSAD控制上下左右"));

outtextxy(580, 180, _T("需要英文小写WSAD"));

outtextxy(600, 220, _T("QQ:1319910854"));

char c;

int map[15][15] = { 0 };

struct XY sn = { 1,5,nullptr };

struct XY save = sn;

struct XY *psn = &sn;

struct XY food = { 0,0 ,nullptr};

enum direction move = right;

bool flag = false;

setfillcolor(GREEN);

solidcircle(60 + 16 + 32 * sn.x, 60 + 16 + 32 * sn.y, 15);

map[sn.x][sn.y] = 1;

while (true)

{

while (!flag)

{

food.x = rand() % 15;

food.y = rand() % 15;

if (map[food.x][food.y] == 0)

{

map[food.x][food.y] = 2;

flag = true;

}

}

if (_kbhit())

{

c = _getch();

switch (c)

{

case 'w': move = up;

break;

case 's': move = down;

break;

case 'a': move = left;

break;

case 'd': move = right;

break;

default:

break;

}

}

save = sn;

switch (move)

{

case up: sn.y--;

break;

case down: sn.y++;

break;

case left: sn.x--;

break;

case right: sn.x++;

break;

default:

break;

}

if (sn.x > -1 && sn.x<15 && sn.y>-1 && sn.y < 15)

{

psn = (struct XY*)malloc(sizeof(struct XY));

psn->x = save.x;

psn->y = save.y;

psn->next = save.next;

sn.next = psn;

switch (map[sn.x][sn.y])

{

case 0:

{

map[sn.x][sn.y] = 1;

struct XY *s;

psn = &sn;

while (psn->next->next != nullptr)

psn = psn->next;

s = psn->next;

psn->next = nullptr;

map[s->x][s->y] = 0;

free(s);

break;

}

case 1:

{

break;

}

case 2:

{

map[sn.x][sn.y] = 1;

flag = false;

break;

}

default:

break;

}

setfillcolor(LIGHTGRAY);

solidrectangle(60, 60, 540, 540);

setfillcolor(GREEN);

psn = &sn;

while (true)

{

solidcircle(60 + 16 + 32 * psn->x, 60 + 16 + 32 * psn->y, 15);

if (psn->next == nullptr)

break;

else

psn = psn->next;

}

solidcircle(60 + 16 + 32 * sn.x, 60 + 16 + 32 * sn.y, 15);

setfillcolor(RED);

if (flag)

{

solidcircle(60 + 16 + 32 * food.x, 60 + 16 + 32 * food.y, 15);

}

}

else

{

break;

}

Sleep(500);

}

setcolor(YELLOW);

settextstyle(50, 0, _T("楷体"));

outtextxy(200, 300, _T("游戏结束"));

outtextxy(100, 380, _T("按任意键结束游戏"));

system("pause");

closegraph();


生活不易

早点休息

❤️

相关文章

  • 爱你

    ‌ (大部分人都喜欢玩游戏,而只有少数人不玩游戏,你知道为什么吗?其中也有本质的区别)你知道我为什么不玩游戏吗?当...

  • 必须”要带着无条件的爱去与你的孩子互动“

    你喜欢玩游戏吗?喜欢! 你有童心吗?有! 你希望有颗童心的家人陪你玩游戏吗?想! 前段时间,有看到《微习惯》一书,...

  • 玩游戏吗?

    “世界上最遥远的距离,就是你在我旁边,而你在玩手机” 这句话的是从网上流传的一张图片得来的,从而引发大家对...

  • 玩游戏吗?

    很久之前,我家里喜欢玩游戏的应该是我爸,那时候家里买了一个和电脑类似的学习机,上面可以打字,可以玩简单的埋地雷的游...

  • 玩游戏吗😂

    备忘录里的,我都忘了是啥的代码了? #include #include #include<...

  • 玩游戏吗

    昨晚上看了一个视频,今天就开始玩游戏了。 就是抖音里的小游戏,羊了个羊。说白了,就是消消乐,三个一起就消失。 我是...

  • 打游戏快乐吗?

    玩游戏到底是为了什么? 玩游戏是为了快乐吗?是为了赢吗? 现在很多青年人都喜欢玩游戏,大多数人手机上都会有一两个游...

  • 游戏人生的男男女女

    赵某小白 2019-4-13 总有女生吐槽男生,怎么那么爱玩游戏呢?就那么着迷吗?是我不好看吗?非要玩游戏...

  • 你会和孩子玩游戏吗?

    你的父母小时候和你玩游戏吗? 不玩儿,玩的很少,只下过棋之类的。 你会和你的孩子玩游戏吗? 会呀。 玩的太多了,打...

  • 挽留的感动

    “还不睡觉?” “睡不着” “唱歌吗?通宵的那种” “你不睡了?” “反正玩游戏也是玩游戏” “好啊” 一次周末在...

网友评论

      本文标题:玩游戏吗😂

      本文链接:https://www.haomeiwen.com/subject/rpmoehtx.html