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是一种直译式脚本语言,一种动态类型,弱类型,基于原型的高级语言。 直译式:js程序运行过程中直接编译成机器语言。 脚本语言:在程序运行过程中逐行进行解释说明,不需要预编译。 动态类型:js…...

爬虫是什么?
目录 1.什么是互联网爬虫? 2.爬虫核心? 3.爬虫的用途? 4.爬虫分类? 5.反爬手段? 1.什么是互联网爬虫? 如果我们把互联网比作一张大的蜘蛛网,那一台计算机上的数据便是蜘蛛网上的一个猎物,而爬虫程序…...
深入理解Presto分页查询:方法与最佳实践
目录 引言为什么需要分页查询Presto简介分页查询的基本概念Presto分页查询的实现方法 使用LIMIT和OFFSET使用游标分页结合外部工具和框架 分页查询的性能优化 索引优化查询计划优化数据分区 实际案例分析最佳实践与常见问题 大数据集分页复杂查询分页实时性要求高的场景 总结 …...
如何使用Go语言中的并发函数实现网络爬虫的分布式部署?
如何使用go语言中的并发函数实现网络爬虫的分布式部署? 在当今的互联网时代,大量的信息蕴藏在各个网站中,爬虫成为了一种重要的工具。而对于大规模的数据爬取任务,采用分布式部署能够更有效地提升爬取速度和效率。Go语言的并发机…...

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

JVM线上监控环境搭建Grafana+Prometheus+Micrometer
架构图 一: SpringBoot自带监控Actuator SpringBoot自带监控功能Actuator,可以帮助实现对程序内部运行情况监控,比如监控内存状况、CPU、Bean加载情况、配置属性、日志信息、线程情况等。 使用步骤: 1. 导入依赖坐标 <dependency><…...
MyBatis(17)MyBatis 如何处理枚举类型
MyBatis 处理枚举类型的机制相对直接,它提供了一种灵活的方式来处理Java枚举(enum)类型和数据库之间的映射。在MyBatis中,你可以通过两种方式处理枚举类型:使用枚举的名称(name)或者枚举的序号&…...

云数据中心运维新纪元:让Linux服务器如虎添翼
文章目录 一、Linux系统管理的高级技巧1. 性能调优与监控:2. 自动化与脚本编写:3. 文件系统与存储管理: 二、服务器配置优化的策略1. 硬件选型与配置:2. 网络配置与优化:3. 应用部署与调优: 三、安全策略的…...
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职位
今天反客为主,聊一下这个HR的话题,考虑到SAP职位的专业性,感觉还是有必要谈一谈这个话题。最近跟几位HR的小伙伴聊了一下,讨论了下不同公司的SAP职位的招聘要求,感觉还是有那么几个存在的问题: 追求完美的…...

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

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

安卓实现微信聊天气泡
一搜没一个能用的,我来: 布局文件: <?xml version"1.0" encoding"utf-8"?> <androidx.constraintlayout.widget.ConstraintLayout xmlns:android"http://schemas.android.com/apk/res/android"xml…...

软件测试(功能、接口、性能、自动化)详解 | 测试人生路
一、软件测试功能测试 测试用例编写是软件测试的基本技能;也有很多人认为测试用例是软件测试的核心;软件测试中最重要的是设计和生成有效的测试用例;测试用例是测试工作的指导,是软件测试的必须遵守的准则。 黑盒测试常见测试用…...
【面试题】网络IO模型
IO(Input/Output)模型指的是计算机系统中对输入/输出操作进行处理的不同方式。它定义了操作系统内核、应用程序和I/O设备之间如何交互和协调数据传输。不同的IO模型在效率、复杂性和适用场景方面都有所差异。以下是几种主要的IO模型及其特点:…...

数据结构-----【链表:基础】
链表基础 1、链表的理论基础 1)基础: 链表:通过指针串联在一起的线性结构,每个节点由两部分组成,一个是数据域,一个是指针域(存放指向下一个节点的指针),最后一个指针…...
如何在pycharm里面运行pytest用例
pycharm运行三种方式 1.以xx.py脚本方式直接执行,当写的代码里面没用到unittest和pytest框架时,并且脚本名称不是以test_开头命名的,此时pycharm会以xx.py脚本方式运行 2.当脚本命名为test_xx.py时,用到unittest框架,…...

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

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

练习(含atoi的模拟实现,自定义类型等练习)
一、结构体大小的计算及位段 (结构体大小计算及位段 详解请看:自定义类型:结构体进阶-CSDN博客) 1.在32位系统环境,编译选项为4字节对齐,那么sizeof(A)和sizeof(B)是多少? #pragma pack(4)st…...

高危文件识别的常用算法:原理、应用与企业场景
高危文件识别的常用算法:原理、应用与企业场景 高危文件识别旨在检测可能导致安全威胁的文件,如包含恶意代码、敏感数据或欺诈内容的文档,在企业协同办公环境中(如Teams、Google Workspace)尤为重要。结合大模型技术&…...
Pinocchio 库详解及其在足式机器人上的应用
Pinocchio 库详解及其在足式机器人上的应用 Pinocchio (Pinocchio is not only a nose) 是一个开源的 C 库,专门用于快速计算机器人模型的正向运动学、逆向运动学、雅可比矩阵、动力学和动力学导数。它主要关注效率和准确性,并提供了一个通用的框架&…...
高效线程安全的单例模式:Python 中的懒加载与自定义初始化参数
高效线程安全的单例模式:Python 中的懒加载与自定义初始化参数 在软件开发中,单例模式(Singleton Pattern)是一种常见的设计模式,确保一个类仅有一个实例,并提供一个全局访问点。在多线程环境下,实现单例模式时需要注意线程安全问题,以防止多个线程同时创建实例,导致…...

回溯算法学习
一、电话号码的字母组合 import java.util.ArrayList; import java.util.List;import javax.management.loading.PrivateClassLoader;public class letterCombinations {private static final String[] KEYPAD {"", //0"", //1"abc", //2"…...

MySQL:分区的基本使用
目录 一、什么是分区二、有什么作用三、分类四、创建分区五、删除分区 一、什么是分区 MySQL 分区(Partitioning)是一种将单张表的数据逻辑上拆分成多个物理部分的技术。这些物理部分(分区)可以独立存储、管理和优化,…...

HubSpot推出与ChatGPT的深度集成引发兴奋与担忧
上周三,HubSpot宣布已构建与ChatGPT的深度集成,这一消息在HubSpot用户和营销技术观察者中引发了极大的兴奋,但同时也存在一些关于数据安全的担忧。 许多网络声音声称,这对SaaS应用程序和人工智能而言是一场范式转变。 但向任何技…...

windows系统MySQL安装文档
概览:本文讨论了MySQL的安装、使用过程中涉及的解压、配置、初始化、注册服务、启动、修改密码、登录、退出以及卸载等相关内容,为学习者提供全面的操作指导。关键要点包括: 解压 :下载完成后解压压缩包,得到MySQL 8.…...

实战三:开发网页端界面完成黑白视频转为彩色视频
一、需求描述 设计一个简单的视频上色应用,用户可以通过网页界面上传黑白视频,系统会自动将其转换为彩色视频。整个过程对用户来说非常简单直观,不需要了解技术细节。 效果图 二、实现思路 总体思路: 用户通过Gradio界面上…...

【UE5 C++】通过文件对话框获取选择文件的路径
目录 效果 步骤 源码 效果 步骤 1. 在“xxx.Build.cs”中添加需要使用的模块 ,这里主要使用“DesktopPlatform”模块 2. 添加后闭UE编辑器,右键点击 .uproject 文件,选择 "Generate Visual Studio project files",重…...