声明:本作为1.01更新版,上线防沉迷。
//1.01
#include<algorithm>
#include<fstream>
#include<iostream>
#include<stdio.h>
#include<cstdio>
#include<iostream>
#include<windows.h>
#include<conio.h>
#include <time.h>
#include <stdlib.h>
#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include <windows.h>
#include <stdlib.h>
#include <time.h>
using namespace std;
int blue=100;
int HP=1000;
int hurt=100;
int x=10,y=1;
int Boss_HP=2000;
int Boss_hurt=200;
int Boss_x=10,Boss_y=20;
int monsters_HP=200;
int monsters_hurt=20;
int monsters_x,monsters_y;
int hj=0;
int fj=0;
int bx,by;
int money=0;
int x_what(int x) {//取随机数
srand((unsigned)time(NULL));
return( rand() % x);
}
int sc(){
system("cls");
char cz;
cout<<"金钱"<<money<<endl;
cout<<"1反甲(1个100反),200R金钱"<<endl;
cout<<"2护甲(1个100护),100R金钱"<<endl;
cout<<"3屠龙宝刀(1个100攻击),100金钱"<<endl;
while(!kbhit()){
}
cz=getch();
if(cz=='1'&&money>=200){
money-=200;
fj+=100;
}
if(cz=='2'&&money>=100){
money-=100;
hj+=100;
}
if(cz=='3'&&money>=100){
money-=100;
hurt+=100;
}
}
int open(){
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED| FOREGROUND_GREEN);
cout<<" 传奇(DEVC++阳光版)";
cout<<"by:黑客小C"<<endl;
cout<<"wasd移动,f攻击,e技能(输出加回血,100蓝一次),q商城(请开英文输入法并调成小写)"<<endl;
cout<<"规则:打小怪加攻击,打败BOSS胜利"<<endl;
cout<<"按任意键开始";
while(!kbhit()) {
}
system("cls");
monsters_x=x_what(18);
monsters_x++;
monsters_y=x+1;
}
int out(){
system("cls");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_BLUE);
cout<<"血量:"<<HP<<"蓝量"<<blue<<"攻击"<<hurt<<"金钱"<<money<<"反甲"<<fj<<"护甲"<<hj<<endl;
for(int i=0;i<=21;i++){
for(int j=0;j<=21;j++){
if(i==0||i==21){
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED| FOREGROUND_GREEN);
cout<<"+";
}
else if(j==0||j==21){
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED| FOREGROUND_GREEN);
cout<<"+";
}
else if(i==x&&j==y){
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_GREEN);
cout<<"8";
}
else if(i==monsters_x&&j==monsters_y){
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED);
cout<<"o";
}
else if(i==Boss_x&&j==Boss_y){
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED);
cout<<"M";
}
else{
cout<<" ";
}
}
cout<<endl;
}
}
int play(){
char cz;
if(kbhit())
{
cz=getch();
if(cz=='w'){
x--;
}
if(cz=='s'){
x++;
}
if(cz=='a'){
y--;
}
if(cz=='d'){
y++;
}
if(cz=='f'){
if(x==monsters_x&&y==monsters_y-1){
monsters_HP-=hurt;
}
if(x==Boss_x&&y==Boss_y-1){
Boss_HP-=hurt;
}
}
if(cz=='e'){
if(blue>=100){
blue-=100;
HP+=200;
if(x==monsters_x&&y==monsters_y-1){
monsters_HP-=(hurt*2);
}
if(x==Boss_x&&y==Boss_y-1){
Boss_HP-=(hurt*2);
}
}
}
if(cz=='q'){
sc();
}
}
}
int main(){
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED| FOREGROUND_GREEN);
int f,b,i;
char name[101];
cout<<"请输入名字:"<<endl;
gets(name);
int name_long=strlen(name);
if(name_long<4||name_long>16){
cout<<"请输入真名";
return 0;
}
long long sfz;
long long sfz2;
cout<<"请输入身份证号:"<<endl;
cin>>sfz;
SYSTEMTIME sys;
GetLocalTime(&sys);
time_t now=time(0);
tm *gmtm = gmtime(&now);
tm *ltm = localtime(&now);
f=1900 + ltm->tm_year;
b=1 + ltm->tm_mon;
i=y-2022;
i*=4;
system("cls");
sfz2=sfz%1000000000000/100000000;
if((f-sfz2)<18&&(sys.wDayOfWeek<5||sys.wHour<8||sys.wHour>9)) {
cout<<"由于你是未成年且没到游戏时间,所以强制退出。";
return 0;
}
open();
while(true){
out();
play();
if(Boss_HP<=0){
system("cls");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED| FOREGROUND_GREEN);
cout<<"游戏胜利";
Sleep(2000);
return 0;
}
if(HP<=0){
system("cls");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED);
cout<<"你死了";
Sleep(2000);
return 0;
}
if(monsters_HP<=0){
monsters_HP=200;
money+=100;
hurt+=100;
monsters_x=x_what(18);
monsters_x++;
monsters_y=x+1;
}
if(x==monsters_x&&y==monsters_y-1){
HP-=monsters_hurt;
HP+=hj;
monsters_HP-=fj;
}
if(x==Boss_x&&y==Boss_y-1){
HP-=Boss_hurt;
HP+=hj;
Boss_HP-=fj;
}
blue+=10;
Sleep(100);
}
return 0;
}