欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 财经 > 产业 > C++之文字修仙小游戏

C++之文字修仙小游戏

2025/3/15 19:09:28 来源:https://blog.csdn.net/Lucky_Glory/article/details/146256358  浏览:    关键词:C++之文字修仙小游戏

1 效果

1.1 截图

游戏运行:

存档:

 1.2 游玩警告

注意!不要修改装备概率,装备的概率都是凑好的数字。如果想要速升,修改灵石数量

2 代码

2.1 代码大纲

1. 游戏框架与初始化

  • 控制台操作:通过 gotoxy() 和 hide_cursor() 控制光标位置与可见性,color() 函数设置颜色,实现动态界面。

  • 全局变量:管理玩家等级(Lv)、经验(Exp)、关卡(G)、灵石(SpiritStone)等核心数据,以及装备稀有度概率(如 GreyGreen)。

  • 初始化函数 init():重置装备数据、加载存档、设置控制台颜色并隐藏光标。


2. 装备系统

  • 结构体 equipment

    • 属性 稀有度(rare)、等级(lv)、类型(type)、名称(name)、伤害(damage)、生命值(HP)和威力(power)。

    • 动态颜色 (ecolor()):根据稀有度显示不同颜色(如灰色、绿色),高稀有度装备(如红色、彩虹)使用 HSL 动态渐变。

    • 装备生成 (init()):基于类型和稀有度生成名称(如“玄铁重剑”)、计算属性,稀有度越高加成越大(如彩虹装备伤害+80%)。


3. 战斗与关卡

  • 战斗循环:玩家与敌人轮流攻击,血量(HPnowMHPnow)实时更新,伤害由装备属性累加计算。

  • 关卡推进:击败敌人后关卡(G)递增,敌人血量根据公式 MHP = G * G 动态增长。

  • 装备掉落:击败敌人随机生成新装备,玩家可选择替换或分解,分解获得灵石和经验。


4. 成长与升级

  • 角色升级:经验值(Exp)满后提升等级,解锁更高境界(如筑基期、金丹期)。

  • 仙树升级:消耗灵石升级仙树(TreeLV),调用 TreeUP() 调整稀有度概率(如减少灰色装备概率,增加橙色概率)。

  • 属性计算:玩家总血量(HP)和伤害(damage)由装备属性累加,功力(power)进行装备战力估算。


5. 存档与颜色处理

  • 存档机制SaveRecord() 和 LoadRecord() 将装备数据、等级、灵石等保存至文件(equipment.save 和 Tree.save)。

  • HSL转RGBHSLtoRGB() 函数实现动态颜色效果(如至宝装备颜色渐变),增强视觉表现。


6. 关键逻辑细节

  • 装备生成概率:根据 GreyGreen 等全局变量加权随机,高关卡解锁更稀有装备。

  • 时间控制times 变量控制攻击动画节奏,Sleep(20) 调节循环速度。

2.2 游戏代码

#include <iostream>
#include <Windows.h>
#include <conio.h>
#include <time.h>
#include <string>
#include <fstream>
#include <sstream>
#include <vector>#define Rgrey 1
#define Rgreen 2
#define Rblue 3
#define Rpurple 4
#define Rorange 5
#define Rred 6
#define Rgold 7
#define Rlightblue  8
#define Rrainbow 9
#define RRrainbow 10
#define Rblack 11
#define RRblack 12using namespace std;int Lv = 0, Exp = 0, Exp2 = 50;
int times = 0;int G = 1;
int TreeLV = 1;
int Grey = 33;
int Green = 31;
int Blue = 25;
int Purple = 11;
int Orange = 0;
int Red = 0;
int Gold = 0;
int Lightblue = 0;
float Rainbow = 0;
float Rainbow2 = 0;
float Black = 0;
float Black2 = 0;int EquipmentLV = 1;
long long SpiritStone = 0;struct equipment;
struct COLORRGB;
int getrand(int min, int max);
void gotoxy(int x, int y);
void hide_cursor();
void color(int r, int g, int b);
void color2(COLORRGB c);
void init();
void TreeUP();
void SaveRecord();
void LoadRecord();
void ecolor(short rare);COLORRGB HSLtoRGB(float h, float s, float l);struct COLORRGB { int r, g, b; };
struct equipment
{short rare = 0;int lv = 1;char type[20] = { "" };char name[20] = { "" };int damage = 0;long long HP = 0;long long power = 0;void ecolor(){switch (rare){case Rgrey: color(140, 140, 140); break;case Rgreen: color(0, 153, 0); break;case Rblue: color(0, 0, 153); break;case Rpurple: color(102, 0, 204); break;case Rorange: color(255, 153, 51); break;case Rred:color(175 + (times / 2) % 80, 0, 0);if ((times / 2) % 160 >= 80) color(255 - (times / 2) % 80, 0, 0);break;case Rgold:color(220 + (times / 3) % 20, 220 + (times / 3) % 20, 0);if ((times / 3) % 40 >= 20) color(240 - (times / 3) % 20, 240 - (times / 3) % 20, 0);break;case Rlightblue:{float H = 211;float S = 1;if (times % 200 >= 100) color2(HSLtoRGB(H, S, 0.85f - float(times % 100) / 500));else color2(HSLtoRGB(H, S, 0.65f + float(times % 100) / 500));break;}case Rrainbow:{float S = 1;float L = 0.5f;color2(HSLtoRGB(times % 720 / 2, S, L));break;}case RRrainbow:{float S = 1;float L = 0.5f;color2(HSLtoRGB(times % 360, S, L));break;}case Rblack:{float H = 0;float S = 0;if (times % 200 >= 100){color2(HSLtoRGB(H, S, 0.25f - float(times % 100) / 400));}else{color2(HSLtoRGB(H, S, float(times % 100) / 400));}break;}case RRblack:{float H = 0;float S = 0;if (times % 200 >= 100){color2(HSLtoRGB(H, S, 0.5f - float(times % 100) / 200));}else{color2(HSLtoRGB(H, S, float(times % 100) / 200));}break;}default: color(245, 245, 245);}}void init(short _rare, short _type){lv = Lv + 1;rare = _rare;const char* types[9] = { "头盔", "护甲", "护腿", "披风", "护臂", "护腕", "武器", "宝物" };strcpy_s(type, types[_type]);const char* names[8][13] = {{"", "铜盔", "玄铁帽", "岩骨护盔", "星玄流云盔", "淬星龙鳞冠", "紫淬寰宇冠", "鸿蒙太虚冠", "九转星璇盔", "灭世星辰冠", "灵宝-星辰冠", "玄龙", "道"},{"", "布衣", "藤心软甲", "玄龟灵甲", "金丝蟠龙铠", "九霄雷纹甲", "紫淬龙宇铠", "无相法身袍", "混元星璇袍", "寰宇灭世铠", "灵宝-寰宇铠", "破天", "法"},{"", "草编护腿", "铁锁护腿", "青蟒护腿", "玄冰踏云腿", "金乌焚尘腿", "流风逐月腿", "八荒六合腿", "太乙青冥腿", "日月琼天腿", "灵宝-日月腿", "神霄", "神"},{"", "布织斗篷", "狼裘披风", "玄鹤羽氅", "赤霞飞云帔", "金乌焰翎", "乾坤一气幡", "八荒太极袍", "太虚寰宇氅", "万象归墟幡", "灵宝-归墟幡", "护道", "霄"},{"", "灰布缠臂", "铜虎臂", "赤蛟吞云臂", "玄铁护心臂", "紫电惊雷臂", "龙魂缚天臂", "盘龙天蚕扣", "阴阳两仪环", "寂灭轮回臂", "灵宝-轮回臂", "踏仙", "寂"},{"", "草绳腕带", "铁纹护腕", "冰魄玉环", "玄火缠丝扣", "金乌焚天腕", "太阴锁灵环", "须弥太极腕", "造化寰宇腕", "玄天寂灭腕", "灵宝-玄天腕", "寂世", "世"},{"", "生锈短刀", "青锋短匕", "玄铁重剑", "赤霄斩月刀", "九幽噬魂枪", "太虚星辰剑", "破界碎空戟", "混沌太虚剑", "轮回灭世戟", "灵宝-灭世戟", "万道", "墟"},{"", "聚灵珠", "琉璃钟", "三昧真火珠", "玄冰凝魂镜", "金乌炎阳珠", "太虚玄火钟", "周天星辰珠", "鸿蒙造化珠", "万象归墟镜", "灵宝-归墟镜", "太虚", "灵"}};strcpy_s(name, names[_type][_rare]);damage = getrand(lv * 14, lv * 14 + 10);HP = getrand(lv * 50, lv * 50 + 10);if (_type == 6){damage *= 1.3;HP /= 1.1;}if (_type == 7){damage /= 1.1;HP *= 1.3;}switch (rare){case Rblue: damage *= 1.05; HP *= 1.2; break;case Rpurple: damage *= 1.15; HP *= 1.35; break;case Rorange: damage *= 1.25; HP *= 1.65; break;case Rred: damage *= 1.4; HP *= 1.95; break;case Rgold: damage *= 1.5; HP *= 2.1; break;case Rlightblue: damage *= 1.6; HP *= 2.3; break;case Rrainbow: damage *= 1.7; HP *= 2.5; break;case RRrainbow: damage *= 1.8; HP *= 2.7; break;case Rblack: damage *= 2.0; HP *= 3.1; break;case RRblack: damage *= 2.2; HP *= 5.0; break;}if (_rare == 0){strcpy_s(name, type);HP = 0;damage = 0;}else{power = rare * 84 + lv * 104 + HP * 15 + damage * 45;}}
} E[15];int main()
{bool NewEquipment = false;short randtype = 0;int MHPnow = 10, MHP = 10, damage = 1;int _damage = 1, _power = 0;long long _HP = 0;long long HPnow = 100, HP = 100, power = 0;equipment equ;init();for (short i = 0; i < 8; i++){_HP += E[i].HP;_damage += E[i].damage;_power += E[i].power;}HP = _HP + 100;HPnow = HP;power = _power;damage = _damage;MHP = G * 2 * G;if (G >= 100) MHP = max(G * 1.5 * G, 100 * 2 * 100);else if (G >= 150) MHP = max(G * 1.3 * G, G * 1.5 * G);else if (G >= 200) MHP = max(G * G, G * 1.3 * G);else if (G >= 250) MHP = max(G * G / 1.1, G * G);else if (G >= 300) MHP = max(G * G / 1.3, G * G / 1.1);else MHP = max(G * G / 1.5, G * G / 1.3);if (MHP <= 5) MHP = 5;MHPnow = MHP;bool upgrade = false;int UpgradeTimes = 10, UpgradeTimes2 = 10;UpgradeTimes = TreeLV * 10 + (TreeLV - 1) * 15;UpgradeTimes2 = UpgradeTimes;while (1) {while (HPnow > 0){for (short i = 0; i < 8; i++){E[i].ecolor();gotoxy(4, 2 + i * 2);printf("[%d级]%s  ", E[i].lv, E[i].name);}color(0, 0, 0);if (Red > 0 || Orange > 0 || Purple > 0){gotoxy(100, 2); ecolor(1);printf("凡品概率 %d%%  ", Grey);gotoxy(100, 4); ecolor(2);printf("下品概率 %d%%  ", Green);gotoxy(100, 6); ecolor(3);printf("中品概率 %d%%  ", Blue);gotoxy(100, 8); ecolor(4);printf("上品概率 %d%%  ", Purple);gotoxy(100, 10); ecolor(5);printf("极品概率 %d%%  ", Orange);gotoxy(100, 12); ecolor(6);printf("仙品概率 %d%%  ", Red);gotoxy(100, 14); ecolor(7);printf("完美概率 %d%%  ", Gold);gotoxy(100, 16); ecolor(8);printf("先天概率 %d%%  ", Lightblue);gotoxy(100, 18); ecolor(9);printf("至宝概率 %.2f%%  ", Rainbow);}else{gotoxy(100, 2); ecolor(6);printf("仙品概率 %d%%  ", Red);gotoxy(100, 4); ecolor(7);printf("完美概率 %d%%  ", Gold);gotoxy(100, 6); ecolor(8);printf("先天概率 %d%%  ", Lightblue);gotoxy(100, 8); ecolor(9);printf("至宝概率 %.2f%%  ", Rainbow);gotoxy(100, 10); ecolor(10);printf("灵宝概率 %.2f%%  ", Rainbow2);gotoxy(100, 12); ecolor(11);printf("神器概率 %.2f%%  ", Black);gotoxy(100, 14); ecolor(12);printf("仙器概率 %.2f%%  ", Black2);}color(0, 0, 0);gotoxy(4, 18);printf("血量:%d  ", HP);gotoxy(4, 19);printf("攻击:%d  ", damage);gotoxy(4, 20);if (Lv < 10) printf("练气期");else if (Lv < 20) printf("筑基期");else if (Lv < 30) printf("金丹期");else if (Lv < 40) printf("元婴期");else if (Lv < 50) printf("化神期");else if (Lv < 60) printf("炼虚期");else if (Lv < 70) printf("合体期");else if (Lv < 80) printf("大乘期");else if (Lv < 90) printf("渡劫期");else if (Lv < 100) printf("金仙期");else if (Lv < 110) printf("真仙期");else if (Lv < 120) printf("地仙期");else if (Lv < 130) printf("天仙期");else  printf("玄仙期%d级", (Lv - 130) / 10 + 1);printf("%d阶 (%d/%d)      ", Lv % 10 + 1, Exp, Exp2);gotoxy(4, 21);printf("功力:%lld  ", power + (Lv - 1) * 203);gotoxy(4, 22);printf("灵石:%lld  ", SpiritStone);gotoxy(4, 23);printf("仙树等级:%d", TreeLV);if (!(SpiritStone >= TreeLV * 322 + (TreeLV - 1) * 638)){gotoxy(4, 24);color(90, 90, 90);if (TreeLV < 87)printf("(需%d灵石可升级)  ", TreeLV * 322 + (TreeLV - 1) * 638);}else{if (upgrade == false){gotoxy(4, 24);color(0, 153, 0);if (TreeLV < 87){printf("(可升级 按F键升级)     ");if (GetAsyncKeyState('F') & 0x8000){upgrade = true;SpiritStone -= TreeLV * 322 + (TreeLV - 1) * 638;}}else{color(90, 90, 90);printf("已满级");}}else if (!(GetAsyncKeyState('F') & 0x8000)){if (UpgradeTimes <= 0){UpgradeTimes = TreeLV * 5 + UpgradeTimes2 / 2 + (TreeLV - 1) * 10;UpgradeTimes2 = UpgradeTimes;upgrade = false;gotoxy(4, 24);printf("                                             ");TreeUP();TreeLV++;}else{gotoxy(4, 24);color(0, 0, 0);printf("正在升级 需%d秒 按P花费%d灵石立刻升级", UpgradeTimes, UpgradeTimes * 50);if (times % 30 == 0){if (upgrade) UpgradeTimes--;}if (GetAsyncKeyState('P') & 0x8000){if (SpiritStone >= UpgradeTimes * 50){SpiritStone -= UpgradeTimes * 50;UpgradeTimes = 0;}else{SpiritStone = 0;UpgradeTimes -= SpiritStone / 50;}}}}}color(0, 0, 0);gotoxy(58, 1);printf("关卡 %d", G);color(0, 153, 0);gotoxy(50, 8); printf("我");gotoxy(44, 9);printf("HP:%d / %d   ", HPnow, HP);color(153, 0, 0);gotoxy(72, 8); printf("敌");gotoxy(66, 9);printf("HP:%d / %d   ", MHPnow, MHP);if (NewEquipment == true){equ.ecolor();gotoxy(45, 12);printf("获得新装备:[%d级]%s", equ.lv, equ.name);gotoxy(45, 13);printf("功力 %d(%+d)", equ.power, equ.power - E[randtype].power);gotoxy(45, 14);printf("血量 %d(%+d)", equ.HP, equ.HP - E[randtype].HP);gotoxy(45, 15);printf("伤害 %d(%+d)", equ.damage, equ.damage - E[randtype].damage);gotoxy(45, 16);printf("替换并分解原装备(y) 分解(n)", equ.damage, equ.damage - E[randtype].damage);if (GetAsyncKeyState('Y') & 0x8000){Exp = Exp + 10 + equ.power / 1000;SpiritStone += E[randtype].power / 10;E[randtype] = equ;NewEquipment = false;long long _HP = 100;int _damage = 1;int _power = 0;for (short i = 0; i < 8; i++){_HP += E[i].HP;_damage += E[i].damage;_power += E[i].power;}HP = _HP + 100;HPnow = HP;power = _power;damage = _damage;SaveRecord();system("cls");}else if (GetAsyncKeyState('N') & 0x8000){Exp = Exp + 10 + E[randtype].power / 1000;SpiritStone += equ.power / 10;NewEquipment = false;system("cls");HPnow = HP;}}if (NewEquipment == false){if (times % 30 == 1){color(240, 240, 240);gotoxy(72, 8); printf("敌");Exp++;}if (times % 30 == 16){color(240, 240, 240);gotoxy(50, 8); printf("我");Exp++;}if (times % 15 == 0){if (times % 30 == 15){HPnow -= G * G / 10;color(240, 240, 240);gotoxy(50, 8); printf("我");}else{MHPnow -= damage;color(240, 240, 240);gotoxy(72, 8); printf("敌");}}if (Exp >= Exp2){Exp -= Exp2;Exp2 = Exp2 += Lv * 5;Lv++;if (Lv % 10 == 0) Exp2 -= 100;}}if (MHPnow <= 0){Sleep(200);G++;MHP = G * 2 * G;if (G >= 100) MHP = max(G * 1.5 * G, 100 * 2 * 100);else if (G >= 150) MHP = max(G * 1.3 * G, G * 1.5 * G);else if (G >= 200) MHP = max(G * G, G * 1.3 * G);else if (G >= 250) MHP = max(G * G / 1.1, G * G);else if (G >= 300) MHP = max(G * G / 1.3, G * G / 1.1);else MHP = max(G * G / 1.5, G * G / 1.3);if (MHP <= 5) MHP = 5;MHPnow = MHP;randtype = getrand(0, 7);int EquipmentRand = getrand(1, 100);if (EquipmentRand <= Grey)equ.init(Rgrey, randtype);else if (EquipmentRand - Grey <= Green)equ.init(Rgreen, randtype);else if (EquipmentRand - Grey - Green <= Blue)equ.init(Rblue, randtype);else if (EquipmentRand - Grey - Green - Blue <= Purple)equ.init(Rpurple, randtype);else if (EquipmentRand - Grey - Green - Blue - Purple <= Orange)equ.init(Rorange, randtype);else if (EquipmentRand - Green - Blue - Purple - Orange <= Red)equ.init(Rred, randtype);else if (EquipmentRand - Blue - Purple - Orange - Red <= Gold)equ.init(Rgold, randtype);else if (EquipmentRand - Purple - Orange - Red - Gold <= Lightblue)equ.init(Rlightblue, randtype);else if (EquipmentRand - Orange - Red - Gold - Lightblue <= Rainbow)equ.init(Rrainbow, randtype);else if (EquipmentRand - Red - Gold - Lightblue - Rainbow <= Rainbow2)equ.init(RRrainbow, randtype);else if (EquipmentRand - Gold - Lightblue - Rainbow - Rainbow2 <= Black)equ.init(Rblack, randtype);else if (EquipmentRand - Gold - Lightblue - Rainbow - Rainbow2 - Black <= Black2)equ.init(RRblack, randtype);if (G == 51){strcpy_s(equ.type, "");equ.rare = Rorange;equ.HP = 9999;equ.damage = 2999;}NewEquipment = true;system("cls");}times++;if (times == 3000) times = 0;Sleep(20);}init();for (short i = 0; i < 8; i++){_HP += E[i].HP;_damage += E[i].damage;_power += E[i].power;}HP = _HP + 100;HPnow = HP;power = _power;damage = _damage;MHPnow = MHP;system("cls");gotoxy(58, 4);color(0, 0, 0);printf("GA"); Sleep(1000);printf("ME"); Sleep(1000);printf(" OV"); Sleep(1000);printf("ER"); Sleep(1000);}
}void init()
{srand(time(0));for (short i = 0; i < 8; i++){E[i].init(0, i);}LoadRecord();system("color F0");hide_cursor();Lv++;
}int getrand(int min, int max)
{return (rand() % (max - min + 1)) + min;
}void gotoxy(int x, int y)
{COORD c;c.X = x;c.Y = y;SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), c);
}void hide_cursor()
{HANDLE h_GAME = GetStdHandle(STD_OUTPUT_HANDLE);CONSOLE_CURSOR_INFO cursor_info;GetConsoleCursorInfo(h_GAME, &cursor_info);cursor_info.bVisible = false;SetConsoleCursorInfo(h_GAME, &cursor_info);
}void color(int r, int g, int b)
{wprintf(L"\x1b[38;2;%d;%d;%dm", r, g, b);
}
void color2(COLORRGB c)
{wprintf(L"\x1b[38;2;%d;%d;%dm", c.r, c.g, c.b);
}
void TreeUP()
{if (Grey > 0){if (Grey > 3){Grey -= 6;Green += 2;Blue += 2;Purple += 2;}else{Grey -= 3;Green += 1;Blue += 1;Purple += 1;}}else if (Green > 0){Green -= 6;Blue += 2;Purple += 2;Orange += 2;}else if (Blue > 0){Blue -= 5;Purple++;Orange += 2;Red += 2;}else if (Purple > 0){if (Purple > 2){Purple -= 4;Red += 2;Gold += 2;}else{Purple -= 2;Red += 1;Gold += 1;}}else if (Orange > 0){if (Purple > 2){Orange -= 4;Gold += 2;Lightblue += 2;}else{Orange -= 2;Gold += 1;Lightblue += 1;}}else if (Red > 0){if (Red == 43){Red -= 3;Rainbow += 3;}else{Red -= 5;Gold += 1;Lightblue += 2;Rainbow += 2;}}else if (Gold > 0){Gold -= 6;Lightblue += 2;Rainbow += 3.5;Rainbow2 += 0.5;}else if (Lightblue > 0){Lightblue -= 7;Rainbow += 5.2;Rainbow2 += 1.3;Black += 0.4;Black2 += 0.1;}else if (Rainbow > 0){Rainbow -= 8.34;Rainbow2 += 2.34;Black += 4;Black2 += 2;if (TreeLV == 86) Rainbow = 0;}
}
// 文件操作:保存记录
void SaveRecord() {ofstream file("equipment.save");for (short i = 0; i < 8; i++){file << E[i].HP << " ";file << E[i].damage << " ";file << E[i].lv << " ";file << E[i].rare << " ";file << E[i].power << endl;file << E[i].type << " ";file << E[i].name << endl;}ofstream file2("Tree.save");file2 << Grey << " ";file2 << Green << " ";file2 << Blue << " ";file2 << Purple << " ";file2 << Orange << " ";file2 << Red << " ";file2 << Gold << " ";file2 << Lightblue << " ";file2 << Rainbow << " ";file2 << Rainbow2 << " ";file2 << Black << " ";file2 << Black2 << " ";file2 << Lv << " ";file2 << Exp << " ";file2 << Exp2 << " ";file2 << TreeLV << " ";file2 << SpiritStone << " ";file2 << G << " ";
}// 文件操作:加载记录
void LoadRecord() {ifstream file("equipment.save");if (file) {for (short i = 0; i < 8; i++){file >> E[i].HP;file >> E[i].damage;file >> E[i].lv;file >> E[i].rare;file >> E[i].power;file >> E[i].type;file >> E[i].name;}}ifstream file2("Tree.save");if (file2){file2 >> Grey;file2 >> Green;file2 >> Blue;file2 >> Purple;file2 >> Orange;file2 >> Red;file2 >> Gold;file2 >> Lightblue;file2 >> Rainbow;file2 >> Rainbow2;file2 >> Black;file2 >> Black2;file2 >> Lv;file2 >> Exp;file2 >> Exp2;file2 >> TreeLV;file2 >> SpiritStone;file2 >> G;}
}COLORRGB HSLtoRGB(float h, float s, float l) {COLORRGB C;float r, g, b;if (s == 0) {r = g = b = static_cast<int>(l * 255);}else {float m2;if (l < 0.5) {m2 = l * (1 + s);}else {m2 = l + s - l * s;}float m1 = 2 * l - m2;float t_r = h / 360.0f + 1.0f / 3.0f;float t_g = h / 360.0f;float t_b = h / 360.0f - 1.0f / 3.0f;std::vector<float> color_list = { t_r, t_g, t_b };for (float& color : color_list) {if (color < 0) color += 1.0f;if (color > 1) color -= 1.0f;}std::vector<float> rgb_values;for (float t : color_list) {float c_i;if (t < 1.0f / 6.0f) {c_i = m1 + (m2 - m1) * 6.0f * t;}else if (t < 3.0f / 6.0f) {c_i = m2;}else if (t < 4.0f / 6.0f) {c_i = m1 + (m2 - m1) * (4.0f - 6.0f * t);}else {c_i = m1;}rgb_values.push_back(c_i);}r = static_cast<int>(rgb_values[0] * 255);g = static_cast<int>(rgb_values[1] * 255);b = static_cast<int>(rgb_values[2] * 255);}C.r = r;C.g = g;C.b = b;return C;
}void ecolor(short rare)
{switch (rare){case Rgrey: color(140, 140, 140); break;case Rgreen: color(0, 153, 0); break;case Rblue: color(0, 0, 153); break;case Rpurple: color(102, 0, 204); break;case Rorange: color(255, 153, 51); break;case Rred:color(175 + (times / 2) % 80, 0, 0);if ((times / 2) % 160 >= 80) color(255 - (times / 2) % 80, 0, 0);break;case Rgold:color(220 + (times / 3) % 20, 220 + (times / 3) % 20, 0);if ((times / 3) % 40 >= 20) color(240 - (times / 3) % 20, 240 - (times / 3) % 20, 0);break;case Rlightblue:{float H = 211;float S = 1;if (times % 200 >= 100) color2(HSLtoRGB(H, S, 0.85f - float(times % 100) / 500));else color2(HSLtoRGB(H, S, 0.65f + float(times % 100) / 500));break;}case Rrainbow:{float S = 1;float L = 0.5f;color2(HSLtoRGB(times % 720 / 2, S, L));break;}case RRrainbow:{float S = 1;float L = 0.5f;color2(HSLtoRGB(times % 360, S, L));break;}case Rblack:{float H = 0;float S = 0;if (times % 200 >= 100){color2(HSLtoRGB(H, S, 0.25f - float(times % 100) / 400));}else{color2(HSLtoRGB(H, S, float(times % 100) / 400));}break;}case RRblack:{float H = 0;float S = 0;if (times % 200 >= 100){color2(HSLtoRGB(H, S, 0.5f - float(times % 100) / 200));}else{color2(HSLtoRGB(H, S, float(times % 100) / 200));}break;}default: color(245, 245, 245);}
}

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词