文章目录
前言
熟悉的味道,游戏,它又回来了······
主要是看游戏这个专栏很火,所以今天再来写一篇关于游戏的博客吧。
来看一下运行截图(瞎下的):
代码也是基于easyx来做的,所以需要安装easyx后才能够运行。
代码部分
直接上干货:
#include <iostream>
#include <graphics.h>
#include <string.h>
#include <conio.h>
#include <stdlib.h>
#include <time.h>
class seat
{
public:
int i = 0;
int j = 0;
int number = 0;
};
class box
{
public:
void draw();
public:
int x = 0;
int y = 0;
int value = -1;
int modle = 0;
bool isnew = false;
COLORREF color = WHITE;
};
void draw();
void init();
seat findbestseat(int color, int c);
void isWIN();
void game();
int main()
{
initgraph(700, 700);
setbkcolor(WHITE);
cleardevice();
setbkmode(TRANSPARENT);
while (true)
{
init();
game();
cleardevice();
}
}
box BOX[19][19];
int win = -1;
int whoplay = 0;
int playercolor = 0;
int dx[4]{1, 0, 1, 1};
int dy[4]{0, 1, 1, -1};
int Score[3][5] = {
{0, 80, 250, 500, 500}, {0, 0, 80, 250, 500}, {0, 0, 0, 80, 500}};
int MAXxs[361];
int MAXys[361];
int mylength = 0;
void box::draw()
{
COLORREF thefillcolor = getfillcolor();
setlinestyle(PS_SOLID, 2);
setfillcolor(color);
solidrectangle(x, y, x + 30, y + 30);
if (isnew)
{
setlinecolor(LIGHTGRAY);
line(x + 1, y + 2, x + 8, y + 2);
line(x + 2, y + 1, x + 2, y + 8);
line(x + 29, y + 2, x + 22, y + 2);
line(x + 29, y + 1, x + 29, y + 8);
line(x + 2, y + 29, x + 8, y + 29);
line(x + 2, y + 22, x + 2, y + 29);
line(x + 29, y + 29, x + 22, y + 29);
line(x + 29, y + 22, x + 29, y + 29);
}
setlinecolor(BLACK);
switch (modle)
{
case 0:
line(x + 15, y, x + 15, y + 30);
line(x - 1, y + 15, x + 30, y + 15);
break;
case 1:
line(x + 14, y + 15, x + 30, y + 15);
setlinestyle(PS_SOLID, 3);
line(x + 15, y, x + 15, y + 30);
setlinestyle(PS_SOLID, 2);
break;
case 2:
line(x - 1, y + 15, x + 15, y + 15);
setlinestyle(PS_SOLID, 3);
line(x + 15, y, x + 15, y + 30);
setlinestyle(PS_SOLID, 2);
break;
case 3:
line(x + 15, y + 15, x + 15, y + 30);
setlinestyle(PS_SOLID, 3);
line(x - 1, y + 15, x + 30, y + 15);
setlinestyle(PS_SOLID, 2);
break;
case 4:
line(x + 15, y, x + 15, y + 15);
setlinestyle(PS_SOLID, 3);
line(x - 1, y + 15, x + 30, y + 15);
setlinestyle(PS_SOLID, 2);
break;
case 5:
setlinestyle(PS_SOLID, 3);
line(x + 15, y, x + 15, y + 15);
line(x + 15, y + 15, x + 30, y + 15);
setlinestyle(PS_SOLID, 2);
break;
case 6:
setlinestyle(PS_SOLID, 3);
line(x + 15, y, x + 15, y + 15);
line(x - 1, y + 15, x + 15, y + 15);
setlinestyle(PS_SOLID, 2);
break;
case 7:
setlinestyle(PS_SOLID, 3);
line(x - 1, y + 15, x + 15, y + 15);
line(x + 15, y + 15, x + 15, y + 30);
setlinestyle(PS_SOLID, 2);
break;
case 8:
setlinestyle(PS_SOLID, 3);
line(x + 15, y + 15, x + 30, y + 15);
line(x + 15, y + 15, x + 15, y + 30);
setlinestyle(PS_SOLID, 2);
break;
case 9:
line(x + 15, y, x + 15, y + 30);
line(x - 1, y + 15, x + 30, y + 15);
setfillcolor(BLACK);
setlinestyle(PS_SOLID, 1);
fillci