代码拉取完成,页面将自动刷新
#include "Count.h"
//人物属性加点 在更改人物结构体内对应的数值
//要求人物属性加点总值为20 输出在天赋选卡后属性点的初始值(如:选择天赋:获得钱但体质-10 此时体质初始值输出为-10)
//在二十点加完后不允许继续加点
//若未加点完成就进入游戏弹出提示框/无法进入游戏 点击进入游戏将人物结构体role传入 Startlife 函数
char attributes[5][3];
void RoleSelect(character* role) {
/*initgraph(1440, 900, EX_SHOWCONSOLE);*/
cleardevice();
BeginBatchDraw();
int* attribute = (int*)malloc(5 * sizeof(int));
attribute[0] = 20;
attribute[1] = role->apprance;
attribute[2] = role->wealth;
attribute[3] = role->intelligence;
attribute[4] = role->health;
sprintf_s(attributes[0], 10, "%d", 20);
sprintf_s(attributes[1], 10, "%d", role->apprance);
sprintf_s(attributes[2], 10, "%d", role->wealth);
sprintf_s(attributes[3], 10, "%d", role->intelligence);
sprintf_s(attributes[4], 10, "%d", role->health);
while (true) {
FlushBatchDraw();
prinSelect(role,&attribute); //打印界面
}
closegraph();
}
//打印未点击前的基础页面
void prinSelect(character* role,int** attribute) {
//打印未点击前的基础页面
cleardevice();
char* strs[8];
char strs0[] = "调整初始属性"; char strs1[] = "剩余属性点:"; char strs2[] = "颜值"; char strs3[] = "家境"; char strs4[] = "智力"; char strs5[] = "体质"; char strs6[] = "已选天赋:"; char strs7[] = "开始新人生";
strs[0] = strs0; strs[1] = strs1; strs[2] = strs2; strs[3] = strs3; strs[4] = strs4; strs[5] = strs5; strs[6] = strs6; strs[7] = strs7;
setbkmode(TRANSPARENT);
settextstyle(60, 0, "宋体", 0, 0, 300, false, false, false);
settextcolor(RGB(252, 202, 0));
int width1 = textwidth(strs[0]);
//printf("%d", width1);
//调整初始属性
outtextxy((getwidth() - width1) / 2, 60, strs[0]);
//剩余属性
settextstyle(45, 0, "宋体", 0, 0, 300, false, false, false);
settextcolor(RGB(244, 206, 152));
int width2 = textwidth(strs[1]);
//printf("%d", width2);
outtextxy((getwidth() - width2) / 2 - 20, 160, strs[1]);
//颜值
settextstyle(45, 0, "宋体", 0, 0, 300, false, false, false);
settextcolor(RGB(222, 134, 143));
outtextxy(300, 280, strs[2]);
//-
setfillcolor(RGB(149, 149, 149));
fillrectangle(440, 280, 485, 325);
settextcolor(BLACK);
outtextxy(452, 280, '-');
//+
setfillcolor(RGB(255, 255, 255));
fillrectangle(635, 280, 680, 325);
outtextxy(647, 280, '+');
//printf("%d", textwidth(strs[3]));
//家境
settextstyle(45, 0, "宋体", 0, 0, 300, false, false, false);
settextcolor(RGB(204, 247, 131));
outtextxy(800, 280, strs[3]);
//-
setfillcolor(RGB(149, 149, 149));
fillrectangle(940, 280, 985, 325);
settextcolor(BLACK);
outtextxy(952, 280, '-');
//+
setfillcolor(RGB(255, 255, 255));
fillrectangle(1135, 280, 1180, 325);
outtextxy(1147, 280, '+');
//智力
settextstyle(45, 0, "宋体", 0, 0, 300, false, false, false);
settextcolor(RGB(184, 134, 248));
outtextxy(300, 450, strs[4]);
//-
setfillcolor(RGB(149, 149, 149));
fillrectangle(440, 450, 485, 495);
settextcolor(BLACK);
outtextxy(452, 450, '-');
//+
setfillcolor(RGB(255, 255, 255));
fillrectangle(635, 450, 680, 495);
outtextxy(647, 450, '+');
//体质
settextstyle(45, 0, "宋体", 0, 0, 300, false, false, false);
settextcolor(RGB(147, 210, 243));
outtextxy(800, 450, strs[5]);
//-
setfillcolor(RGB(149, 149, 149));
fillrectangle(940, 450, 985, 495);
settextcolor(BLACK);
outtextxy(952, 450, '-');
//+
setfillcolor(RGB(255, 255, 255));
fillrectangle(1135, 450, 1180, 495);
outtextxy(1147, 450, '+');
//已选天赋
/*settextstyle(35, 0, "宋体", 0, 0, 300, false, false, false);
settextcolor(RGB(228, 160, 95));
outtextxy(270, 600, strs[6]);*/
//开始新人生
settextstyle(45, 0, "宋体", 0, 0, 800, false, false, false);
settextcolor(RGB(255, 248, 29));
int width3 = textwidth(strs[7]);
//printf("%d", width2);
outtextxy((getwidth() - width3) / 2, 780, strs[7]);
settextstyle(45, 0, "宋体", 0, 0, 800, false, false, false);
/* printf("%d", attribute[0]);*/
static int width_attri[4];
width_attri[0] = textwidth(attributes[1]);
width_attri[1] = textwidth(attributes[2]);
width_attri[2] = textwidth(attributes[3]);
width_attri[3] = textwidth(attributes[4]);
outtextxy(840, 160, attributes[0]);
outtextxy(485 + (150 - width_attri[0]) / 2, 280, attributes[1]);
outtextxy(985 + (150 - width_attri[1]) / 2, 280, attributes[2]);
outtextxy(485 + (150 - width_attri[2]) / 2, 450, attributes[3]);
outtextxy(985 + (150 - width_attri[3]) / 2, 450, attributes[4]);
//调整属性
ExMessage msg;
if (peekmessage(&msg, EX_MOUSE)) {
//颜值--
//printf("%d\t%d\n", msg.x, msg.y);
if (SelectClickJG(440, 280, 485, 325, msg)) {
if ((*attribute)[0] != 20) {
(*attribute)[1]--;
(*attribute)[0]++;
sprintf_s(attributes[1], 3, "%d", (*attribute)[1]);
sprintf_s(attributes[0], 3, "%d", (*attribute)[0]);
}
}
//颜值++
if (SelectClickJG(635, 280, 680, 325, msg)) {
if ((*attribute)[0] != 0) {
(*attribute)[1]++;
(*attribute)[0]--;
sprintf_s(attributes[1], 3, "%d", (*attribute)[1]);
sprintf_s(attributes[0], 3, "%d", (*attribute)[0]);
}
}
//家境--
if (SelectClickJG(940, 280, 985, 325, msg)) {
if ((*attribute)[0] != 20) {
(*attribute)[2]--;
(*attribute)[0]++;
sprintf_s(attributes[2], 3, "%d", (*attribute)[2]);
sprintf_s(attributes[0], 3, "%d", (*attribute)[0]);
}
}
//家境++
if (SelectClickJG(1135, 280, 1180, 325, msg)) {
if ((*attribute)[0] != 0) {
(*attribute)[2]++;
(*attribute)[0]--;
sprintf_s(attributes[2], 3, "%d", (*attribute)[2]);
sprintf_s(attributes[0], 3, "%d", (*attribute)[0]);
}
}
//智力--
if (SelectClickJG(440, 450, 485, 495, msg)) {
if ((*attribute)[0] != 20) {
(*attribute)[3]--;
(*attribute)[0]++;
sprintf_s(attributes[3], 3, "%d", (*attribute)[3]);
sprintf_s(attributes[0], 3, "%d", (*attribute)[0]);
}
}
//智力++
if (SelectClickJG(635, 450, 680, 495, msg)) {
if ((*attribute)[0] != 0) {
(*attribute)[3]++;
(*attribute)[0]--;
sprintf_s(attributes[3], 3, "%d", (*attribute)[3]);
sprintf_s(attributes[0], 3, "%d", (*attribute)[0]);
}
}
//体质--
if (SelectClickJG(940, 450, 985, 495, msg)) {
if ((*attribute)[0] != 20) {
(*attribute)[4]--;
(*attribute)[0]++;
sprintf_s(attributes[4], 3, "%d", (*attribute)[4]);
sprintf_s(attributes[0], 3, "%d", (*attribute)[0]);
}
}
//体质++
if (SelectClickJG(1135, 450, 1180, 495, msg)) {
if ((*attribute)[0] != 0) {
(*attribute)[4]++;
(*attribute)[0]--;
sprintf_s(attributes[4], 3, "%d", (*attribute)[4]);
sprintf_s(attributes[0], 3, "%d", (*attribute)[0]);
}
}
//开始新人生
if (SelectClickJG(610, 780, 830, 820, msg)) {
role->apprance += (*attribute)[1];
role->wealth += (*attribute)[2];
role->intelligence += (*attribute)[3];
role->health += (*attribute)[4];
/*printf("prinselect中:%p\n", role);
printf("家境:%d\n", role->wealth);
printf("体质:%d\n", role->health);
printf("快乐:%d\n", role->happiness);
printf("智力:%d\n", role->intelligence);
printf("颜值:%d\n", role->apprance);*/
Startlife(role);
}
flushmessage();
/*
* 颜值
* 家境
* 智力
* 体质
typedef struct character {
int apprance; //颜值
int health; //体质
int wealth; //家境
int intelligence; //智力
int happiness; //快乐
}character;
*/
}
}
//点击加点并打印点击后页面
//其他按键点击判断
bool SelectClickJG(int left, int top, int right, int bottom, ExMessage msg) {
bool b = false;
if (msg.x >= left && msg.x <= right && msg.y >= top && msg.y <= bottom && msg.message == WM_LBUTTONDOWN) {
b = true;
}
return b;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。