AndyEggy的代码
2025-01-22 13:31:45
发布于:上海
#include<iostream>
#include<cstdlib>
#include<ctime>
#include<string>
#include<windows.h>
#include<cstdio>
#include<cmath>
#include<fstream>
#include <bits/stdc++.h>
using namespace std;
int randcnt=0;
bool isKeyPressed(int key){
return (GetAsyncKeyState(key)&0x8000)!=0;
}
int random(int a,int b){
randcnt++;
srand(time(0)+randcnt*randcnt-4*randcnt);
return a+rand()%(b-a+1);
}
//Important valuables
int showL=1244;
int showU=1244;
char arr[2550][2550];
double Stats[10]={100.0,100.0,20.0,8.0,4.0,1,0.0,100.0};
double MstStats[10]={40.0,40.0,6.0,1.25,1.0,1,0.0,100.0};
int posp1=showL+6;
int posp2=showU+6;
// Importand functions which are able to understand.
int StGen(){
for (int i=1; i<=2500; i++){
for (int j=1; j<=2500; j++){
int R1=random(1,1000);
if (R1<=850){
arr[i][j]='*';
}else if (R1<=975){
int R2=random(1,100);
if (R2<=40){
arr[i][j]='C';
}else if (R2<=70){
arr[i][j]='B';
}else if (R2<=85){
arr[i][j]='A';
}else if (R2<=95){
arr[i][j]='R';
}else{
arr[i][j]='S';
}
}else{
arr[i][j]='T';
}
}
}
}
void show(){
system("cls");
for (int i=showU; i<=showU+10; i++){
for (int j=showL; j<=showL+10; j++){
if (i==showU+5 && j==showL+5){
cout << '@';
}else{
cout << arr[i][j];
}
}
cout << endl;
}
posp1=showL+5;
posp2=showU+5;
cout << "Your Posision is (" << posp1 << " ," << posp2 << ").\n-------------\n";
cout << "Your Stats \nHealth " << Stats[0] << "\nMax Health " << Stats[1] << endl;
cout << "Attact " << Stats[2] << "\nDefence " << Stats[3] << endl;
cout << "Luck " << Stats[4] << "\nLevel " << Stats[5] << endl;
cout << "Current Exp " << Stats[6] << "\nRequiered Exp " << Stats[7] << endl;
}
void TrigExp(int a,int b){
Stats[6]+=random(a,b)*random(1,1+0.04*Stats[4]);
while (Stats[6]>=Stats[7]){
Stats[5]++;
Stats[6]-=Stats[7];
for (int i=0; i<=7; i++){
if (i!=5 && i!=6 && i!=4){
Stats[i]*=1.1;
}
}
}
//
MstStats[6]+=random(0.8*a,0.9*b)*random(100,1+4*MstStats[4])/100;
while (MstStats[6]>=MstStats[7]){
MstStats[5]++;
MstStats[6]-=MstStats[7];
for (int i=0; i<=7; i++){
if (i!=5 && i!=6 && i!=4){
MstStats[i]*=1.05;
}
}
}
}
void TrigMst(){
if (arr[posp2][posp1]=='C'){
while (Stats[0]>0 && MstStats[0]>0){
MstStats[0]-=(Stats[1]-MstStats[2])*random(100,1+4*Stats[4])/100;
Stats[0]-=(MstStats[1]-Stats[2])*random(100,1+4*MstStats[4])/100;
show();
}
}
MstStats[0]=40.0;
MstStats[1]=40.0;
MstStats[2]=6.0;
MstStats[3]=1.25;
MstStats[4]=1.0;
MstStats[5]=1.0;
MstStats[6]=0.0;
MstStats[7]=100.0;
}
void Trig(){
if (arr[posp2][posp1]=='*'){
return ;
}else if(arr[posp2][posp1]=='T'){
TrigExp(50,100);
}else {
TrigMst();
}
arr[posp2][posp1]='*';
show();
}
//Main Function
int main(){
StGen();
show();
while (1){
if (isKeyPressed('W')){
if (showU>1){
showU--;
show();
}
Sleep(1000/7);
Trig();
}
if (isKeyPressed('A')){
if (showL>1){
showL--;
show();
}
Sleep(1000/7);
Trig();
}
if (isKeyPressed('S')){
if (showU<2140){
showU++;
show();
}
Sleep(1000/7);
Trig();
}
if (isKeyPressed('D')){
if (showL<2140){
showL++;
show();
}
Sleep(1000/7);
Trig();
}
}
}
全部评论 1
nm
2025-01-22 来自 上海
02025-01-22 来自 上海
0
有帮助,赞一个