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.生产者发起调用…...
 
shell脚本--常见案例
1、自动备份文件或目录 2、批量重命名文件 3、查找并删除指定名称的文件: 4、批量删除文件 5、查找并替换文件内容 6、批量创建文件 7、创建文件夹并移动文件 8、在文件夹中查找文件...
线程同步:确保多线程程序的安全与高效!
全文目录: 开篇语前序前言第一部分:线程同步的概念与问题1.1 线程同步的概念1.2 线程同步的问题1.3 线程同步的解决方案 第二部分:synchronized关键字的使用2.1 使用 synchronized修饰方法2.2 使用 synchronized修饰代码块 第三部分ÿ…...
 
转转集团旗下首家二手多品类循环仓店“超级转转”开业
6月9日,国内领先的循环经济企业转转集团旗下首家二手多品类循环仓店“超级转转”正式开业。 转转集团创始人兼CEO黄炜、转转循环时尚发起人朱珠、转转集团COO兼红布林CEO胡伟琨、王府井集团副总裁祝捷等出席了开业剪彩仪式。 据「TMT星球」了解,“超级…...
vue3 字体颜色设置的多种方式
在Vue 3中设置字体颜色可以通过多种方式实现,这取决于你是想在组件内部直接设置,还是在CSS/SCSS/LESS等样式文件中定义。以下是几种常见的方法: 1. 内联样式 你可以直接在模板中使用style绑定来设置字体颜色。 <template><div :s…...
Neo4j 集群管理:原理、技术与最佳实践深度解析
Neo4j 的集群技术是其企业级高可用性、可扩展性和容错能力的核心。通过深入分析官方文档,本文将系统阐述其集群管理的核心原理、关键技术、实用技巧和行业最佳实践。 Neo4j 的 Causal Clustering 架构提供了一个强大而灵活的基石,用于构建高可用、可扩展且一致的图数据库服务…...
vue3 定时器-定义全局方法 vue+ts
1.创建ts文件 路径:src/utils/timer.ts 完整代码: import { onUnmounted } from vuetype TimerCallback (...args: any[]) > voidexport function useGlobalTimer() {const timers: Map<number, NodeJS.Timeout> new Map()// 创建定时器con…...
 
k8s业务程序联调工具-KtConnect
概述 原理 工具作用是建立了一个从本地到集群的单向VPN,根据VPN原理,打通两个内网必然需要借助一个公共中继节点,ktconnect工具巧妙的利用k8s原生的portforward能力,简化了建立连接的过程,apiserver间接起到了中继节…...
 
【数据分析】R版IntelliGenes用于生物标志物发现的可解释机器学习
禁止商业或二改转载,仅供自学使用,侵权必究,如需截取部分内容请后台联系作者! 文章目录 介绍流程步骤1. 输入数据2. 特征选择3. 模型训练4. I-Genes 评分计算5. 输出结果 IntelliGenesR 安装包1. 特征选择2. 模型训练和评估3. I-Genes 评分计…...
Python 包管理器 uv 介绍
Python 包管理器 uv 全面介绍 uv 是由 Astral(热门工具 Ruff 的开发者)推出的下一代高性能 Python 包管理器和构建工具,用 Rust 编写。它旨在解决传统工具(如 pip、virtualenv、pip-tools)的性能瓶颈,同时…...
 
html css js网页制作成品——HTML+CSS榴莲商城网页设计(4页)附源码
目录 一、👨🎓网站题目 二、✍️网站描述 三、📚网站介绍 四、🌐网站效果 五、🪓 代码实现 🧱HTML 六、🥇 如何让学习不再盲目 七、🎁更多干货 一、👨…...
