#include<bits/stdc++.h>
#include<windows.h>
#include<conio.h>
#define cls system("cls")
#define et cout<<endl
#define pause system("pause")
using namespace std;
mt19937 myrng(time(0));
int rd(int l,int r){
return myrng()%(r-l+1)+l;
}
string to_string(auto n){
if(n==0)return "0";
string t;
bool f=false;
if(n<0){
f=true;
n=-n;
}
while(n){
t=char(n%10+'0')+t;
n/=10;
}
return ((f)?"-":"")+t;
}
void pr(string s,int t=25){
for(int i=0;i<s.size();i++){
cout<<s[i];
Sleep(t);
}
}
void cp(string s,int fc=15,int bc=0,bool slow=0,int t=25,int _setw=0){
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|bc*16|FOREGROUND_INTENSITY|fc);
if(slow)pr(s,t);
else cout<<left<<setw(_setw)<<s;
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|7);
return;
}
inline int ___ti(float a) {
return ((int)(a*10+5))/10;
}
void Setpos(float x,float y){
COORD pos;y/=2;y-=0.5;
pos.X=___ti(y*4)/2;
pos.Y=___ti(x);
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),pos);
}
bool KEY(auto kkk){
return GetAsyncKeyState(kkk)&0x8000;
}
void Map(int type){
cls;
for(int i=1;i<=51;i++)cp("#");
for(int i=1;i<=20;i++){
et;cp("#");
Setpos(i,51);cp("#");
}et;for(int i=1;i<=51;i++)cp("#");
int y=7,x=10;Setpos(x,y);cp("P");
if(type==1){
Setpos(10,40);cp("G",4);
}
while(1){
while(1){
if(KEY(VK_LEFT)||KEY('a')){
Setpos(x,y);cp(" ");
y-=2;
y=max(y,2);
break;
}
if(KEY(VK_UP)||KEY('w')){
Setpos(x,y);cp(" ");
x--;
x=max(x,1);
break;
}
if(KEY(VK_DOWN)||KEY('s')){
Setpos(x,y);cp(" ");
x++;
x=min(x,20);
break;
}
if(KEY(VK_RIGHT)||KEY('d')){
Setpos(x,y);cp(" ");
y+=2;
y=min(y,50);
break;
}
if(KEY(' ')){
if(type==1&&(x-10)*(x-10)+(y-40)*(y-40)<18){
return;
}
}
}
Setpos(x,y);cp("P");
Sleep(100);
}
}
class Player{
public:
string name;
int maxHealth,health;
int defence,damage;
int zjjcn=100;
int critical_hit_probability,critical_hit_damage;
Player(){
maxHealth=health=5000;
defence=damage=1000;//每1防御力减伤0.01%
critical_hit_probability=5;
critical_hit_damage=50;
}
void show(){
cp(name,3,0,0,25,15);
}
}player;
string enam[]={"敌人1"};
double level=2;
class Enemy{
public:
string name;
int maxHealth,health;
int defence,damage,base;
void update(Player t,int base){
maxHealth=health=t.maxHealth*level;
defence=t.defence*level;
damage=t.damage*level;
}
void show(){
cp(name,4,0,0,25,15);
if(health>0){
cp(" [",4);
int t=double(health)/maxHealth*10;
int t2=10-t;
while(t--){
cp("▄",4);
}
while(t2--){
cp(" ",4);
}
cp(" ] ",4);
t=double(health)/maxHealth*100;
cp(" (",4);
cp(to_string(t),4);
cp("% ",4);
cp(to_string(health),4);
cp("/",4);
cp(to_string(maxHealth),4);
cp(")",4);
}
}
};
string _enemies[1000];
void init(){
player.name="角色";
//*******************************//
_enemies[1]="怪物1";
_enemies[2]="怪物2";
_enemies[3]="怪物3";
_enemies[4]="怪物4";
_enemies[5]="怪物5";
}
void Fight(vector<int>enem,int base=1.5){
vector<Enemy>enemies;
for(int i=0;i<enem.size();i++){
Enemy kkksc;
enemies.push_back(kkksc);
enemies[i].name=_enemies[enem[i]];
enemies[i].update(player,base);
}int zjd=3;
while(1){
cls;
player.show();
if(player.health>0){
cp(" [",3);
int t=double(player.health)/player.maxHealth*10;
int t2=10-t;
while(t--){
cp("▄",3);
}
while(t2--){
cp(" ",3);
}
cp(" ] ",3);
t=double(player.health)/player.maxHealth*100;
cp(" (",3);
cp(to_string(t),3);
cp("% ",3);
cp(to_string(player.health),3);
cp("/",3);
cp(to_string(player.maxHealth),3);
cp(")",3);
}else{
cp("已死亡",12);
}et;
for(int i=0;i<enem.size();i++){
enemies[i].show();et;
}et;
cp("1.普攻 2.战技 3.终结技(");cp(to_string(player.zjjcn));cp("/100) 战技点:");
for(int i=1;i<=zjd;i++){
cp("★");
}for(int i=zjd+1;i<=5;i++){
cp("☆");
}et;
string s;
cin>>s;
}
}
int _main(){
init();
while(1){
cls;
cp("1.开始游戏");et;
string s;
cin>>s;
if(s=="1"){
Map(1);
Fight({1,2,3});
}
}
}
int main(){
CONSOLE_CURSOR_INFO cursor_info={1,0};
SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE),&cursor_info);
SetConsoleTitle("BC20260086");
cp(" Welcome to\n",8,0,1,30);
cp(" Game\n",1,0);
cp(" by BC20260086\n",12,0);
for(int i=1;i<=15;i++)
cp("--",i,0,1);
et;
cp("C:怪物 B:祝福 N:NPC"); et;
cp("空格:攻击/交互");et;
et;et;cp("按1开始");et;
string s;
cin>>s;
if(s=="1")_main();
else{
cls;
cp("你真无聊\n",12,0,1,30);
cp("输入2开始都不愿意吗?\n",12,0,1,50);
cp("啊?\n",12,0,1,100);
for(int i=120;i>=0;i--){
cls;
cp("秒后进入游戏\n");
Sleep(1000);
}
}
main();
}