当前位置: 首页 > news >正文

gameui C++的代码

 

 gameui C++的代码

#include <graphics.h>
#include "gameboard.h"
const int WIDTH = 560;
const int HEIGHT = 780;
const int GRID_SIZE = 120;
class GameUi {
private:   public:GameUi(GameBoard& gb) {// 初始化图形窗口initgraph(WIDTH, HEIGHT);// 设置背景色setbkcolor(0xCCCCCC);cleardevice();// 绘制游戏背景和网格//setlinecolor(WHITE);//setlinestyle(PS_SOLID, 5);for (int i = 1; i < 4; ++i) {//line(i * GRID_SIZE, 0, i * GRID_SIZE, HEIGHT);//line(0, i * GRID_SIZE, WIDTH, i * GRID_SIZE);}DrawBlocks(gb);}void DrawBlocks(GameBoard& gb) {int c=0;int i;int j;int x;int y;for (i = 0; i < 4; ++i) {for (j = 0; j < 4; ++j) {if (gb.get_ij(i,j) != 0) {// 根据数字大小设置颜色和绘制位置x = j * GRID_SIZE + GRID_SIZE / 2;y = i * GRID_SIZE + GRID_SIZE / 2;x += 30;switch (gb.get_ij(i, j)){case 2:c = 0x99FFFF;break;case 4:c = 0x99FFCC;break;case 8:c = 0x99FF99;break;case 16:c = 0x99FF66;break;case 32:c = 0x99FF33;break;case 64:c = 0x99FF00;break;case 128:c = 0x99CCFF;break;case 128*2:c = 0x99CCCC;break;case 128 * 4:c = 0x99CC99;break;case 128 * 8:c = 0x99CC66;break;case 128 * 16:c = 0x99CC33;break;default:break;}setfillcolor(0xCCCCCC);fillrectangle(x - GRID_SIZE / 2 + 5, y - GRID_SIZE / 2 + 5, x + GRID_SIZE / 2 - 5, y + GRID_SIZE / 2 - 5);// 绘制数字settextcolor(c);// 设置背景色setbkcolor(0xCCCCCC);settextstyle(40, 0, _T("Arial"));    char str[10];sprintf(str, "%d", gb.get_ij(i, j));outtextxy(x - 15, y - 15, str);}else {// 根据数字大小设置颜色和绘制位置x = j * GRID_SIZE + GRID_SIZE / 2;y = i * GRID_SIZE + GRID_SIZE / 2;x += 30;setfillcolor(0xCCCCCC);fillrectangle(x - GRID_SIZE / 2 + 5, y - GRID_SIZE / 2 + 5, x + GRID_SIZE / 2 - 5, y + GRID_SIZE / 2 - 5);}}}//双for结束x = 0 * GRID_SIZE + GRID_SIZE / 2;y = i * GRID_SIZE + GRID_SIZE / 2;x += 30;y += 20;setfillcolor(0xCCCCCC);fillrectangle(x - GRID_SIZE / 2 + 5, y - GRID_SIZE / 2 + 5, x + GRID_SIZE / 2 - 5, y + GRID_SIZE / 2 - 5);// 绘制数字settextcolor(0xFF9966);settextstyle(40, 0, _T("Arial"));char str[100];sprintf(str, "%d", gb.getSum());outtextxy(x - 15, y - 15, str);x += 1*GRID_SIZE + GRID_SIZE / 2;setfillcolor(0xCCCCCC);fillrectangle(x - GRID_SIZE / 2 + 5, y - GRID_SIZE / 2 + 5, x + GRID_SIZE / 2 + 155, y + GRID_SIZE / 2 - 5);// 绘制数字settextcolor(0xFF9966);settextstyle(40, 0, _T("Arial"));sprintf(str, "BEST:%d", gb.getHistoricalMaxScore());outtextxy(x - 15, y - 15, str);y += 1 * GRID_SIZE + GRID_SIZE / 2;x = 130;setfillcolor(0xCCCCCC);fillrectangle(x - GRID_SIZE / 2 + 5, y - GRID_SIZE / 2 + 5, x + GRID_SIZE / 2 + 255, y + GRID_SIZE / 2 - 5);settextcolor(0xFF9966);settextstyle(40, 0, _T("Arial"));sprintf(str, "ESC:reset p:PAUSE");outtextxy(x - 15, y - 15, str);}void DrawBlocks1(GameBoard& gb) {int c = 0;int i;int j;int x;int y;for (i = 0; i < 4; ++i) {for (j = 0; j < 4; ++j) {if (gb.get_ij(i, j) != 0) {// 根据数字大小设置颜色和绘制位置x = j * GRID_SIZE + GRID_SIZE / 2;y = i * GRID_SIZE + GRID_SIZE / 2;x += 30;switch (gb.get_ij(i, j)){case 2:c = 0x11FFFF;break;case 4:c = 0x11FFCC;break;case 8:c = 0x11FF99;break;case 16:c = 0x11FF66;break;case 32:c = 0x11FF33;break;case 64:c = 0x11FF00;break;case 128:c = 0x11CCFF;break;case 128 * 2:c = 0x11CCCC;break;case 128 * 4:c = 0x11CC99;break;case 128 * 8:c = 0x11CC66;break;case 128 * 16:c = 0x11CC33;break;default:break;}setfillcolor(0xCCCCCC);fillrectangle(x - GRID_SIZE / 2 + 5, y - GRID_SIZE / 2 + 5, x + GRID_SIZE / 2 - 5, y + GRID_SIZE / 2 - 5);// 绘制数字settextcolor(c);settextstyle(40, 0, _T("Arial"));char str[10];sprintf(str, "%d", gb.get_ij(i, j));outtextxy(x - 15, y - 15, str);}else {// 根据数字大小设置颜色和绘制位置x = j * GRID_SIZE + GRID_SIZE / 2;y = i * GRID_SIZE + GRID_SIZE / 2;x += 30;setfillcolor(0xAAAAAA);fillrectangle(x - GRID_SIZE / 2 + 5, y - GRID_SIZE / 2 + 5, x + GRID_SIZE / 2 - 5, y + GRID_SIZE / 2 - 5);}}}//双for结束x = 0 * GRID_SIZE + GRID_SIZE / 2;y = i * GRID_SIZE + GRID_SIZE / 2;x += 30;y += 20;setfillcolor(0xCCCCCC);fillrectangle(x - GRID_SIZE / 2 + 5, y - GRID_SIZE / 2 + 5, x + GRID_SIZE / 2 - 5, y + GRID_SIZE / 2 - 5);// 绘制数字settextcolor(0xFF9966);settextstyle(40, 0, _T("Arial"));char str[100];sprintf(str, "%d", gb.getSum());outtextxy(x - 15, y - 15, str);x += 1 * GRID_SIZE + GRID_SIZE / 2;setfillcolor(0xCCCCCC);fillrectangle(x - GRID_SIZE / 2 + 5, y - GRID_SIZE / 2 + 5, x + GRID_SIZE / 2 + 155, y + GRID_SIZE / 2 - 5);// 绘制数字settextcolor(0xFF9966);settextstyle(40, 0, _T("Arial"));sprintf(str, "BEST:%d", gb.getHistoricalMaxScore());outtextxy(x - 15, y - 15, str);y += 1 * GRID_SIZE + GRID_SIZE / 2;x = 130;setfillcolor(0xCCCCCC);fillrectangle(x - GRID_SIZE / 2 + 5, y - GRID_SIZE / 2 + 5, x + GRID_SIZE / 2 + 255, y + GRID_SIZE / 2 - 5);settextcolor(0xFF9966);settextstyle(40, 0, _T("Arial"));sprintf(str, "ESC:reset p:PAUSE");outtextxy(x - 15, y - 15, str);}void DrawBlocks2(GameBoard& gb) {int c = 0;int i;int j;int x;int y;for (i = 0; i < 4; ++i) {for (j = 0; j < 4; ++j) {if (gb.get_ij(i, j) != 0) {// 根据数字大小设置颜色和绘制位置x = j * GRID_SIZE + GRID_SIZE / 2;y = i * GRID_SIZE + GRID_SIZE / 2;x += 30;switch (gb.get_ij(i, j)){case 2:c = 0x22FFFF;break;case 4:c = 0x22FFCC;break;case 8:c = 0x22FF99;break;case 16:c = 0x22FF66;break;case 32:c = 0x22FF33;break;case 64:c = 0x22FF00;break;case 128:c = 0x22CCFF;break;case 128 * 2:c = 0x22CCCC;break;case 128 * 4:c = 0x22CC99;break;case 128 * 8:c = 0x22CC66;break;case 128 * 16:c = 0x22CC33;break;default:break;}setfillcolor(0xCCCCCC);fillrectangle(x - GRID_SIZE / 2 + 5, y - GRID_SIZE / 2 + 5, x + GRID_SIZE / 2 - 5, y + GRID_SIZE / 2 - 5);// 绘制数字settextcolor(c);settextstyle(40, 0, _T("Arial"));char str[10];sprintf(str, "%d", gb.get_ij(i, j));outtextxy(x - 15, y - 15, str);}else {// 根据数字大小设置颜色和绘制位置x = j * GRID_SIZE + GRID_SIZE / 2;y = i * GRID_SIZE + GRID_SIZE / 2;x += 30;setfillcolor(0xBBBBBB);fillrectangle(x - GRID_SIZE / 2 + 5, y - GRID_SIZE / 2 + 5, x + GRID_SIZE / 2 - 5, y + GRID_SIZE / 2 - 5);}}}//双for结束x = 0 * GRID_SIZE + GRID_SIZE / 2;y = i * GRID_SIZE + GRID_SIZE / 2;x += 30;y += 20;setfillcolor(0xCCCCCC);fillrectangle(x - GRID_SIZE / 2 + 5, y - GRID_SIZE / 2 + 5, x + GRID_SIZE / 2 - 5, y + GRID_SIZE / 2 - 5);// 绘制数字settextcolor(0xFF9966);settextstyle(40, 0, _T("Arial"));char str[100];sprintf(str, "%d", gb.getSum());outtextxy(x - 15, y - 15, str);x += 1 * GRID_SIZE + GRID_SIZE / 2;setfillcolor(0xCCCCCC);fillrectangle(x - GRID_SIZE / 2 + 5, y - GRID_SIZE / 2 + 5, x + GRID_SIZE / 2 + 155, y + GRID_SIZE / 2 - 5);// 绘制数字settextcolor(0xFF9966);settextstyle(40, 0, _T("Arial"));sprintf(str, "BEST:%d", gb.getHistoricalMaxScore());outtextxy(x - 15, y - 15, str);y += 1 * GRID_SIZE + GRID_SIZE / 2;x = 130;setfillcolor(0xCCCCCC);fillrectangle(x - GRID_SIZE / 2 + 5, y - GRID_SIZE / 2 + 5, x + GRID_SIZE / 2 + 255, y + GRID_SIZE / 2 - 5);settextcolor(0xFF9966);settextstyle(40, 0, _T("Arial"));sprintf(str, "ESC:reset p:PAUSE");outtextxy(x - 15, y - 15, str);}void DrawBlocks3(GameBoard& gb) {int c = 0;int i;int j;int x;int y;for (i = 0; i < 4; ++i) {for (j = 0; j < 4; ++j) {if (gb.get_ij(i, j) != 0) {// 根据数字大小设置颜色和绘制位置x = j * GRID_SIZE + GRID_SIZE / 2;y = i * GRID_SIZE + GRID_SIZE / 2;x += 30;switch (gb.get_ij(i, j)){case 2:c = 0x900FFF;break;case 4:c = 0x300FCC;break;case 8:c = 0x300F99;break;case 16:c = 0x300F66;break;case 32:c = 0x300F33;break;case 64:c = 0x300F00;break;case 128:c = 0x300CFF;break;case 128 * 2:c = 0x300CCC;break;case 128 * 4:c = 0x300C99;break;case 128 * 8:c = 0x300C66;break;case 128 * 16:c = 0x300C33;break;default:break;}setfillcolor(0xCCCCCC);fillrectangle(x - GRID_SIZE / 2 + 5, y - GRID_SIZE / 2 + 5, x + GRID_SIZE / 2 - 5, y + GRID_SIZE / 2 - 5);// 绘制数字settextcolor(c);settextstyle(40, 0, _T("Arial"));char str[10];sprintf(str, "%d", gb.get_ij(i, j));outtextxy(x - 15, y - 15, str);}else {// 根据数字大小设置颜色和绘制位置x = j * GRID_SIZE + GRID_SIZE / 2;y = i * GRID_SIZE + GRID_SIZE / 2;x += 30;setfillcolor(0xDDDDDD);fillrectangle(x - GRID_SIZE / 2 + 5, y - GRID_SIZE / 2 + 5, x + GRID_SIZE / 2 - 5, y + GRID_SIZE / 2 - 5);}}}//双for结束x = 0 * GRID_SIZE + GRID_SIZE / 2;y = i * GRID_SIZE + GRID_SIZE / 2;x += 30;y += 20;setfillcolor(0xCCCCCC);fillrectangle(x - GRID_SIZE / 2 + 5, y - GRID_SIZE / 2 + 5, x + GRID_SIZE / 2 - 5, y + GRID_SIZE / 2 - 5);// 绘制数字settextcolor(0xFF9966);settextstyle(40, 0, _T("Arial"));char str[100];sprintf(str, "%d", gb.getSum());outtextxy(x - 15, y - 15, str);x += 1 * GRID_SIZE + GRID_SIZE / 2;setfillcolor(0xCCCCCC);fillrectangle(x - GRID_SIZE / 2 + 5, y - GRID_SIZE / 2 + 5, x + GRID_SIZE / 2 + 155, y + GRID_SIZE / 2 - 5);// 绘制数字settextcolor(0xFF9966);settextstyle(40, 0, _T("Arial"));sprintf(str, "BEST:%d", gb.getHistoricalMaxScore());outtextxy(x - 15, y - 15, str);y += 1 * GRID_SIZE + GRID_SIZE / 2;x = 130;setfillcolor(0xCCCCCC);fillrectangle(x - GRID_SIZE / 2 + 5, y - GRID_SIZE / 2 + 5, x + GRID_SIZE / 2 + 255, y + GRID_SIZE / 2 - 5);settextcolor(0xFF9966);settextstyle(40, 0, _T("Arial"));sprintf(str, "ESC:reset p:PAUSE");outtextxy(x - 15, y - 15, str);}void DrawBlocks4(GameBoard& gb) {int c = 0;int i;int j;int x;int y;for (i = 0; i < 4; ++i) {for (j = 0; j < 4; ++j) {if (gb.get_ij(i, j) != 0) {// 根据数字大小设置颜色和绘制位置x = j * GRID_SIZE + GRID_SIZE / 2;y = i * GRID_SIZE + GRID_SIZE / 2;x += 30;switch (gb.get_ij(i, j)){case 2:c = 0x44FFFF;break;case 4:c = 0x44FFCC;break;case 8:c = 0x44FF99;break;case 16:c = 0x44FF66;break;case 32:c = 0x44FF33;break;case 64:c = 0x44FF00;break;case 128:c = 0x44CCFF;break;case 128 * 2:c = 0x44CCCC;break;case 128 * 4:c = 0x44CC99;break;case 128 * 8:c = 0x44CC66;break;case 128 * 16:c = 0x44CC33;break;default:break;}setfillcolor(0xCCCCCC);fillrectangle(x - GRID_SIZE / 2 + 5, y - GRID_SIZE / 2 + 5, x + GRID_SIZE / 2 - 5, y + GRID_SIZE / 2 - 5);// 绘制数字settextcolor(c);settextstyle(40, 0, _T("Arial"));char str[10];sprintf(str, "%d", gb.get_ij(i, j));outtextxy(x - 15, y - 15, str);}else {// 根据数字大小设置颜色和绘制位置x = j * GRID_SIZE + GRID_SIZE / 2;y = i * GRID_SIZE + GRID_SIZE / 2;x += 30;setfillcolor(0xCCCCCC);fillrectangle(x - GRID_SIZE / 2 + 5, y - GRID_SIZE / 2 + 5, x + GRID_SIZE / 2 - 5, y + GRID_SIZE / 2 - 5);}}}//双for结束x = 0 * GRID_SIZE + GRID_SIZE / 2;y = i * GRID_SIZE + GRID_SIZE / 2;x += 30;y += 20;setfillcolor(0xCCCCCC);fillrectangle(x - GRID_SIZE / 2 + 5, y - GRID_SIZE / 2 + 5, x + GRID_SIZE / 2 - 5, y + GRID_SIZE / 2 - 5);// 绘制数字settextcolor(0xFF9966);settextstyle(40, 0, _T("Arial"));char str[100];sprintf(str, "%d", gb.getSum());outtextxy(x - 15, y - 15, str);x += 1 * GRID_SIZE + GRID_SIZE / 2;setfillcolor(0xCCCCCC);fillrectangle(x - GRID_SIZE / 2 + 5, y - GRID_SIZE / 2 + 5, x + GRID_SIZE / 2 + 155, y + GRID_SIZE / 2 - 5);// 绘制数字settextcolor(0xFF9966);settextstyle(40, 0, _T("Arial"));sprintf(str, "BEST:%d", gb.getHistoricalMaxScore());outtextxy(x - 15, y - 15, str);y += 1 * GRID_SIZE + GRID_SIZE / 2;x = 130;setfillcolor(0xCCCCCC);fillrectangle(x - GRID_SIZE / 2 + 5, y - GRID_SIZE / 2 + 5, x + GRID_SIZE / 2 + 255, y + GRID_SIZE / 2 - 5);settextcolor(0xFF9966);settextstyle(40, 0, _T("Arial"));sprintf(str, "ESC:reset p:PAUSE");outtextxy(x - 15, y - 15, str);}void DrawBlocks5(GameBoard& gb) {int c = 0;int i;int j;int x;int y;for (i = 0; i < 4; ++i) {for (j = 0; j < 4; ++j) {if (gb.get_ij(i, j) != 0) {// 根据数字大小设置颜色和绘制位置x = j * GRID_SIZE + GRID_SIZE / 2;y = i * GRID_SIZE + GRID_SIZE / 2;x += 30;switch (gb.get_ij(i, j)){case 2:c = 0x55FFFF;break;case 4:c = 0x55FFCC;break;case 8:c = 0x55FF99;break;case 16:c = 0x55FF66;break;case 32:c = 0x55FF33;break;case 64:c = 0x55FF00;break;case 128:c = 0x55CCFF;break;case 128 * 2:c = 0x55CCCC;break;case 128 * 4:c = 0x55CC99;break;case 128 * 8:c = 0x55CC66;break;case 128 * 16:c = 0x55CC33;break;default:break;}setfillcolor(0xCCCCCC);fillrectangle(x - GRID_SIZE / 2 + 5, y - GRID_SIZE / 2 + 5, x + GRID_SIZE / 2 - 5, y + GRID_SIZE / 2 - 5);// 绘制数字settextcolor(c);settextstyle(40, 0, _T("Arial"));char str[10];sprintf(str, "%d", gb.get_ij(i, j));outtextxy(x - 15, y - 15, str);}else {// 根据数字大小设置颜色和绘制位置x = j * GRID_SIZE + GRID_SIZE / 2;y = i * GRID_SIZE + GRID_SIZE / 2;x += 30;setfillcolor(0xCCCCCC);fillrectangle(x - GRID_SIZE / 2 + 5, y - GRID_SIZE / 2 + 5, x + GRID_SIZE / 2 - 5, y + GRID_SIZE / 2 - 5);}}}//双for结束x = 0 * GRID_SIZE + GRID_SIZE / 2;y = i * GRID_SIZE + GRID_SIZE / 2;x += 30;y += 20;setfillcolor(0xCCCCCC);fillrectangle(x - GRID_SIZE / 2 + 5, y - GRID_SIZE / 2 + 5, x + GRID_SIZE / 2 - 5, y + GRID_SIZE / 2 - 5);// 绘制数字settextcolor(0xFF9966);settextstyle(40, 0, _T("Arial"));char str[100];sprintf(str, "%d", gb.getSum());outtextxy(x - 15, y - 15, str);x += 1 * GRID_SIZE + GRID_SIZE / 2;setfillcolor(0xCCCCCC);fillrectangle(x - GRID_SIZE / 2 + 5, y - GRID_SIZE / 2 + 5, x + GRID_SIZE / 2 + 155, y + GRID_SIZE / 2 - 5);// 绘制数字settextcolor(0xFF9966);settextstyle(40, 0, _T("Arial"));sprintf(str, "BEST:%d", gb.getHistoricalMaxScore());outtextxy(x - 15, y - 15, str);y += 1 * GRID_SIZE + GRID_SIZE / 2;x = 130;setfillcolor(0xCCCCCC);fillrectangle(x - GRID_SIZE / 2 + 5, y - GRID_SIZE / 2 + 5, x + GRID_SIZE / 2 + 255, y + GRID_SIZE / 2 - 5);settextcolor(0xFF9966);settextstyle(40, 0, _T("Arial"));sprintf(str, "ESC:reset p:PAUSE");outtextxy(x - 15, y - 15, str);}void DrawBlocks6(GameBoard& gb) {int c = 0;int i;int j;int x;int y;for (i = 0; i < 4; ++i) {for (j = 0; j < 4; ++j) {if (gb.get_ij(i, j) != 0) {// 根据数字大小设置颜色和绘制位置x = j * GRID_SIZE + GRID_SIZE / 2;y = i * GRID_SIZE + GRID_SIZE / 2;x += 30;switch (gb.get_ij(i, j)){case 2:c = 0x66F0FF;break;case 4:c = 0x66F0CC;break;case 8:c = 0x66F099;break;case 16:c = 0x66F066;break;case 32:c = 0x66F033;break;case 64:c = 0x66F000;break;case 128:c = 0x66C0FF;break;case 128 * 2:c = 0x66C0CC;break;case 128 * 4:c = 0x66CC99;break;case 128 * 8:c = 0x66CC66;break;case 128 * 16:c = 0x66CC33;break;default:break;}setfillcolor(0xCCCCCC);fillrectangle(x - GRID_SIZE / 2 + 5, y - GRID_SIZE / 2 + 5, x + GRID_SIZE / 2 - 5, y + GRID_SIZE / 2 - 5);// 绘制数字settextcolor(c);settextstyle(40, 0, _T("Arial"));char str[10];sprintf(str, "%d", gb.get_ij(i, j));outtextxy(x - 15, y - 15, str);}else {// 根据数字大小设置颜色和绘制位置x = j * GRID_SIZE + GRID_SIZE / 2;y = i * GRID_SIZE + GRID_SIZE / 2;x += 30;setfillcolor(0xCCCCCC);fillrectangle(x - GRID_SIZE / 2 + 5, y - GRID_SIZE / 2 + 5, x + GRID_SIZE / 2 - 5, y + GRID_SIZE / 2 - 5);}}}//双for结束x = 0 * GRID_SIZE + GRID_SIZE / 2;y = i * GRID_SIZE + GRID_SIZE / 2;x += 30;y += 20;setfillcolor(0xCCCCCC);fillrectangle(x - GRID_SIZE / 2 + 5, y - GRID_SIZE / 2 + 5, x + GRID_SIZE / 2 - 5, y + GRID_SIZE / 2 - 5);// 绘制数字settextcolor(0xFF9966);settextstyle(40, 0, _T("Arial"));char str[100];sprintf(str, "%d", gb.getSum());outtextxy(x - 15, y - 15, str);x += 1 * GRID_SIZE + GRID_SIZE / 2;setfillcolor(0xCCCCCC);fillrectangle(x - GRID_SIZE / 2 + 5, y - GRID_SIZE / 2 + 5, x + GRID_SIZE / 2 + 155, y + GRID_SIZE / 2 - 5);// 绘制数字settextcolor(0xFF9966);settextstyle(40, 0, _T("Arial"));sprintf(str, "BEST:%d", gb.getHistoricalMaxScore());outtextxy(x - 15, y - 15, str);y += 1 * GRID_SIZE + GRID_SIZE / 2;x = 130;setfillcolor(0xCCCCCC);fillrectangle(x - GRID_SIZE / 2 + 5, y - GRID_SIZE / 2 + 5, x + GRID_SIZE / 2 + 255, y + GRID_SIZE / 2 - 5);settextcolor(0xFF9966);settextstyle(40, 0, _T("Arial"));sprintf(str, "ESC:reset p:PAUSE");outtextxy(x - 15, y - 15, str);}void Update(GameBoard& gb,int type) {cleardevice();if (type == 0) {DrawBlocks(gb);}if (type == 1) {DrawBlocks1(gb);}if (type == 2) {DrawBlocks2(gb);}if (type == 3) {DrawBlocks3(gb);}if (type == 4) {DrawBlocks4(gb);}if (type == 5) {DrawBlocks5(gb);}if (type == 6) {DrawBlocks6(gb);}Sleep(10);  // 控制帧率}void GameOver() {settextcolor(RED);settextstyle(64, 0, _T("Consolas"));outtextxy(WIDTH / 2 - 150, HEIGHT / 2 - 50, _T("Game Over"));        }void GamePause() {settextcolor(RED);settextstyle(64, 0, _T("Consolas"));outtextxy(WIDTH / 2 - 150, HEIGHT / 2 - 50, _T("Game Pause~!"));}~GameUi() {closegraph();}
};

相关文章:

gameui C++的代码

gameui C的代码 #include <graphics.h> #include "gameboard.h" const int WIDTH 560; const int HEIGHT 780; const int GRID_SIZE 120; class GameUi { private: public:GameUi(GameBoard& gb) {// 初始化图形窗口initgraph(WIDTH, HEIGHT);// 设置…...

1.什么是js?特点是什么?组成部分?

Js是一种直译式脚本语言&#xff0c;一种动态类型&#xff0c;弱类型&#xff0c;基于原型的高级语言。 直译式&#xff1a;js程序运行过程中直接编译成机器语言。 脚本语言&#xff1a;在程序运行过程中逐行进行解释说明&#xff0c;不需要预编译。 动态类型&#xff1a;js…...

爬虫是什么?

目录 1.什么是互联网爬虫&#xff1f; 2.爬虫核心? 3.爬虫的用途? 4.爬虫分类&#xff1f; 5.反爬手段&#xff1f; 1.什么是互联网爬虫&#xff1f; 如果我们把互联网比作一张大的蜘蛛网&#xff0c;那一台计算机上的数据便是蜘蛛网上的一个猎物&#xff0c;而爬虫程序…...

深入理解Presto分页查询:方法与最佳实践

目录 引言为什么需要分页查询Presto简介分页查询的基本概念Presto分页查询的实现方法 使用LIMIT和OFFSET使用游标分页结合外部工具和框架 分页查询的性能优化 索引优化查询计划优化数据分区 实际案例分析最佳实践与常见问题 大数据集分页复杂查询分页实时性要求高的场景 总结 …...

如何使用Go语言中的并发函数实现网络爬虫的分布式部署?

如何使用go语言中的并发函数实现网络爬虫的分布式部署&#xff1f; 在当今的互联网时代&#xff0c;大量的信息蕴藏在各个网站中&#xff0c;爬虫成为了一种重要的工具。而对于大规模的数据爬取任务&#xff0c;采用分布式部署能够更有效地提升爬取速度和效率。Go语言的并发机…...

STM32第九课:DHT11温湿度传感器

文章目录 需求一、DHT11温湿度传感器二、模块配置流程1.配置时钟和IO2.读取数据3.数据处理 三、导入语音模块四、关键代码总结 需求 1.完成DHT11温湿度检测模块的配置。 2.处理DHT11获取的数据&#xff0c;在串口打印处理后的实时数据。 2.通过Su-03t语音识别模块实现实时温湿…...

JVM线上监控环境搭建Grafana+Prometheus+Micrometer

架构图 一: SpringBoot自带监控Actuator SpringBoot自带监控功能Actuator&#xff0c;可以帮助实现对程序内部运行情况监控&#xff0c;比如监控内存状况、CPU、Bean加载情况、配置属性、日志信息、线程情况等。 使用步骤&#xff1a; 1. 导入依赖坐标 <dependency><…...

MyBatis(17)MyBatis 如何处理枚举类型

MyBatis 处理枚举类型的机制相对直接&#xff0c;它提供了一种灵活的方式来处理Java枚举&#xff08;enum&#xff09;类型和数据库之间的映射。在MyBatis中&#xff0c;你可以通过两种方式处理枚举类型&#xff1a;使用枚举的名称&#xff08;name&#xff09;或者枚举的序号&…...

云数据中心运维新纪元:让Linux服务器如虎添翼

文章目录 一、Linux系统管理的高级技巧1. 性能调优与监控&#xff1a;2. 自动化与脚本编写&#xff1a;3. 文件系统与存储管理&#xff1a; 二、服务器配置优化的策略1. 硬件选型与配置&#xff1a;2. 网络配置与优化&#xff1a;3. 应用部署与调优&#xff1a; 三、安全策略的…...

C# 多线程造成CPU占用率高

当线程多的时候就会造成CPU内存占用率过高 private void button1_Click(object sender, EventArgs e){Thread TH1, TH2, TH3, TH4, TH5;TH1 new Thread(Thread1){IsBackground true};TH2 new Thread(Thread2){IsBackground true};TH3 new Thread(Thread3){IsBackground t…...

谈谈在不同公司中的SAP职位

今天反客为主&#xff0c;聊一下这个HR的话题&#xff0c;考虑到SAP职位的专业性&#xff0c;感觉还是有必要谈一谈这个话题。最近跟几位HR的小伙伴聊了一下&#xff0c;讨论了下不同公司的SAP职位的招聘要求&#xff0c;感觉还是有那么几个存在的问题&#xff1a; 追求完美的…...

服务器连接不上

记录今天2024/07/02的问题&#xff1a; 我今天真的是非常无语&#xff0c;今天在连服务器的时候&#xff0c;突然发现连不上了。 后来才意识到&#xff0c;原来是我笔记本先是开了全局代理&#xff0c;然后再用easy connected连接。当时还跳出了一个窗口如下&#xff0c;我当时…...

论文辅导 | 基于贝叶斯优化-卷积神经网络-双向长短期记忆神经网络的锂电池健康状态评估

辅导文章 模型描述 准确估计电池健康状态是设备稳定运行的关键。针对当前健康状态研究中容量难以直接测量、估计模型调参费时等问题&#xff0c;提出基于多健康特征的贝叶斯优化&#xff08;BO&#xff09;算法优化卷积神经网络&#xff08;CNN&#xff09;与双向长短期记忆&a…...

安卓实现微信聊天气泡

一搜没一个能用的&#xff0c;我来&#xff1a; 布局文件&#xff1a; <?xml version"1.0" encoding"utf-8"?> <androidx.constraintlayout.widget.ConstraintLayout xmlns:android"http://schemas.android.com/apk/res/android"xml…...

软件测试(功能、接口、性能、自动化)详解 | 测试人生路

一、软件测试功能测试 测试用例编写是软件测试的基本技能&#xff1b;也有很多人认为测试用例是软件测试的核心&#xff1b;软件测试中最重要的是设计和生成有效的测试用例&#xff1b;测试用例是测试工作的指导&#xff0c;是软件测试的必须遵守的准则。 黑盒测试常见测试用…...

【面试题】网络IO模型

IO&#xff08;Input/Output&#xff09;模型指的是计算机系统中对输入/输出操作进行处理的不同方式。它定义了操作系统内核、应用程序和I/O设备之间如何交互和协调数据传输。不同的IO模型在效率、复杂性和适用场景方面都有所差异。以下是几种主要的IO模型及其特点&#xff1a;…...

数据结构-----【链表:基础】

链表基础 1、链表的理论基础 1&#xff09;基础&#xff1a; 链表&#xff1a;通过指针串联在一起的线性结构&#xff0c;每个节点由两部分组成&#xff0c;一个是数据域&#xff0c;一个是指针域&#xff08;存放指向下一个节点的指针&#xff09;&#xff0c;最后一个指针…...

如何在pycharm里面运行pytest用例

pycharm运行三种方式 1.以xx.py脚本方式直接执行&#xff0c;当写的代码里面没用到unittest和pytest框架时&#xff0c;并且脚本名称不是以test_开头命名的&#xff0c;此时pycharm会以xx.py脚本方式运行 2.当脚本命名为test_xx.py时&#xff0c;用到unittest框架&#xff0c…...

Charles抓包工具踩坑记录

请添加图片描述 Charles抓包工具 证书问题 输入网址&#xff1a;chls.pro/ssl 第一个下载证书网址&#xff0c;会出现一直加载不出来&#xff0c;无法下载证书的情况 解决&#xff1a;选择下面save Charles Root。。。 2 证书在mac中禁止修改问题 解决也很简单&#xff0c;按照…...

【RabbitMQ实战】邮件发送(直连交换机、手动ack)

一、实现思路 二、异常情况测试现象及解决 说明:本文涵盖了关于RabbitMQ很多方面的知识点, 如: 消息发送确认机制 、消费确认机制 、消息的重新投递 、消费幂等性, 二、实现思路 1.简略介绍163邮箱授权码的获取 2.编写发送邮件工具类 3.编写RabbitMQ配置文件 4.生产者发起调用…...

RestClient

什么是RestClient RestClient 是 Elasticsearch 官方提供的 Java 低级 REST 客户端&#xff0c;它允许HTTP与Elasticsearch 集群通信&#xff0c;而无需处理 JSON 序列化/反序列化等底层细节。它是 Elasticsearch Java API 客户端的基础。 RestClient 主要特点 轻量级&#xff…...

渗透实战PortSwigger靶场-XSS Lab 14:大多数标签和属性被阻止

<script>标签被拦截 我们需要把全部可用的 tag 和 event 进行暴力破解 XSS cheat sheet&#xff1a; https://portswigger.net/web-security/cross-site-scripting/cheat-sheet 通过爆破发现body可以用 再把全部 events 放进去爆破 这些 event 全部可用 <body onres…...

【解密LSTM、GRU如何解决传统RNN梯度消失问题】

解密LSTM与GRU&#xff1a;如何让RNN变得更聪明&#xff1f; 在深度学习的世界里&#xff0c;循环神经网络&#xff08;RNN&#xff09;以其卓越的序列数据处理能力广泛应用于自然语言处理、时间序列预测等领域。然而&#xff0c;传统RNN存在的一个严重问题——梯度消失&#…...

k8s业务程序联调工具-KtConnect

概述 原理 工具作用是建立了一个从本地到集群的单向VPN&#xff0c;根据VPN原理&#xff0c;打通两个内网必然需要借助一个公共中继节点&#xff0c;ktconnect工具巧妙的利用k8s原生的portforward能力&#xff0c;简化了建立连接的过程&#xff0c;apiserver间接起到了中继节…...

使用Matplotlib创建炫酷的3D散点图:数据可视化的新维度

文章目录 基础实现代码代码解析进阶技巧1. 自定义点的大小和颜色2. 添加图例和样式美化3. 真实数据应用示例实用技巧与注意事项完整示例(带样式)应用场景在数据科学和可视化领域,三维图形能为我们提供更丰富的数据洞察。本文将手把手教你如何使用Python的Matplotlib库创建引…...

API网关Kong的鉴权与限流:高并发场景下的核心实践

&#x1f525;「炎码工坊」技术弹药已装填&#xff01; 点击关注 → 解锁工业级干货【工具实测|项目避坑|源码燃烧指南】 引言 在微服务架构中&#xff0c;API网关承担着流量调度、安全防护和协议转换的核心职责。作为云原生时代的代表性网关&#xff0c;Kong凭借其插件化架构…...

macOS 终端智能代理检测

&#x1f9e0; 终端智能代理检测&#xff1a;自动判断是否需要设置代理访问 GitHub 在开发中&#xff0c;使用 GitHub 是非常常见的需求。但有时候我们会发现某些命令失败、插件无法更新&#xff0c;例如&#xff1a; fatal: unable to access https://github.com/ohmyzsh/oh…...

java高级——高阶函数、如何定义一个函数式接口类似stream流的filter

java高级——高阶函数、stream流 前情提要文章介绍一、函数伊始1.1 合格的函数1.2 有形的函数2. 函数对象2.1 函数对象——行为参数化2.2 函数对象——延迟执行 二、 函数编程语法1. 函数对象表现形式1.1 Lambda表达式1.2 方法引用&#xff08;Math::max&#xff09; 2 函数接口…...

goreplay

1.github地址 https://github.com/buger/goreplay 2.简单介绍 GoReplay 是一个开源的网络监控工具&#xff0c;可以记录用户的实时流量并将其用于镜像、负载测试、监控和详细分析。 3.出现背景 随着应用程序的增长&#xff0c;测试它所需的工作量也会呈指数级增长。GoRepl…...

内窥镜检查中基于提示的息肉分割|文献速递-深度学习医疗AI最新文献

Title 题目 Prompt-based polyp segmentation during endoscopy 内窥镜检查中基于提示的息肉分割 01 文献速递介绍 以下是对这段英文内容的中文翻译&#xff1a; ### 胃肠道癌症的发病率呈上升趋势&#xff0c;且有年轻化倾向&#xff08;Bray等人&#xff0c;2018&#x…...