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.生产者发起调用…...
基于算法竞赛的c++编程(28)结构体的进阶应用
结构体的嵌套与复杂数据组织 在C中,结构体可以嵌套使用,形成更复杂的数据结构。例如,可以通过嵌套结构体描述多层级数据关系: struct Address {string city;string street;int zipCode; };struct Employee {string name;int id;…...
华为云AI开发平台ModelArts
华为云ModelArts:重塑AI开发流程的“智能引擎”与“创新加速器”! 在人工智能浪潮席卷全球的2025年,企业拥抱AI的意愿空前高涨,但技术门槛高、流程复杂、资源投入巨大的现实,却让许多创新构想止步于实验室。数据科学家…...
idea大量爆红问题解决
问题描述 在学习和工作中,idea是程序员不可缺少的一个工具,但是突然在有些时候就会出现大量爆红的问题,发现无法跳转,无论是关机重启或者是替换root都无法解决 就是如上所展示的问题,但是程序依然可以启动。 问题解决…...
java_网络服务相关_gateway_nacos_feign区别联系
1. spring-cloud-starter-gateway 作用:作为微服务架构的网关,统一入口,处理所有外部请求。 核心能力: 路由转发(基于路径、服务名等)过滤器(鉴权、限流、日志、Header 处理)支持负…...
《Qt C++ 与 OpenCV:解锁视频播放程序设计的奥秘》
引言:探索视频播放程序设计之旅 在当今数字化时代,多媒体应用已渗透到我们生活的方方面面,从日常的视频娱乐到专业的视频监控、视频会议系统,视频播放程序作为多媒体应用的核心组成部分,扮演着至关重要的角色。无论是在个人电脑、移动设备还是智能电视等平台上,用户都期望…...
【大模型RAG】Docker 一键部署 Milvus 完整攻略
本文概要 Milvus 2.5 Stand-alone 版可通过 Docker 在几分钟内完成安装;只需暴露 19530(gRPC)与 9091(HTTP/WebUI)两个端口,即可让本地电脑通过 PyMilvus 或浏览器访问远程 Linux 服务器上的 Milvus。下面…...
学校招生小程序源码介绍
基于ThinkPHPFastAdminUniApp开发的学校招生小程序源码,专为学校招生场景量身打造,功能实用且操作便捷。 从技术架构来看,ThinkPHP提供稳定可靠的后台服务,FastAdmin加速开发流程,UniApp则保障小程序在多端有良好的兼…...
最新SpringBoot+SpringCloud+Nacos微服务框架分享
文章目录 前言一、服务规划二、架构核心1.cloud的pom2.gateway的异常handler3.gateway的filter4、admin的pom5、admin的登录核心 三、code-helper分享总结 前言 最近有个活蛮赶的,根据Excel列的需求预估的工时直接打骨折,不要问我为什么,主要…...
【算法训练营Day07】字符串part1
文章目录 反转字符串反转字符串II替换数字 反转字符串 题目链接:344. 反转字符串 双指针法,两个指针的元素直接调转即可 class Solution {public void reverseString(char[] s) {int head 0;int end s.length - 1;while(head < end) {char temp …...
(转)什么是DockerCompose?它有什么作用?
一、什么是DockerCompose? DockerCompose可以基于Compose文件帮我们快速的部署分布式应用,而无需手动一个个创建和运行容器。 Compose文件是一个文本文件,通过指令定义集群中的每个容器如何运行。 DockerCompose就是把DockerFile转换成指令去运行。 …...
