AC RPG!
2025-07-30 18:10:25
发布于:上海
原创《AC RPG》
1.2.1Beta Zeta版*
*(Zeta:有bug的版本 Beta:预发布 Alph:小更新)
作者:你猜
提示:这是个RPG,但作者太懒了,只写了第2章Beta(预发布)(第2章预发布,没有对战)
敬请期待
此游戏有存档功能,但存档如果是1.1版的,请在GdataB.data的最前面写一个0
兼用所有std版本(也可以直接编译)
#include<bits/stdc++.h>
#include<windows.h>
#include <tchar.h>
using namespace std;
#define intmax 1e6+5;
#include <windows.h>
#define KEY_DOWN(VK_KEY) (GetAsyncKeyState(VK_KEY) & 0x8000)
#define KEYEnter VK_RETURN
#define KEYESC VK_ESCAPE
#if __cplusplus >= 201103L
#else
#include <sstream>
string JustForWaitForEnter;
template <typename T>
std::string to_string(T value) {
std::ostringstream os;
os << value;
return os.str();
}
#endif
void cls();
int sleep_(double time,bool stop=false){
double s=time*CLOCKS_PER_SEC+clock();
for(int i=clock();i<s;i=clock()){
if(KEY_DOWN(KEYEnter)){
if(stop){
return 1;
}
}
}
return 0;
}
struct player{
string name;
int health;
int Defense;
int mxhealth;
}player_self={"%% mz",10,0,10},loop={"循环结构",12,1,12};
struct E{
string type;
string name;
int health;
int mxhealth;
};
//战斗类!!
struct fight{
player p[10];
E xg[10];
};
int push_at_good_time(){
for(int i=0;i<10;i++){
cout<<"请在>移到Y时按Enter\n";
for(int j=0;j<10;j++){
if(i==j&&i==5){
cout<<">Y ";
if(KEY_DOWN(KEYEnter)){
cls();
getline(cin,JustForWaitForEnter);
return -1;
}
}else if(j==5){
cout<<" Y ";
if(KEY_DOWN(KEYEnter)){
cls();
getline(cin,JustForWaitForEnter);
return abs(5-i);
}
}else if(i==j){
if(KEY_DOWN(KEYEnter)){
cls();
getline(cin,JustForWaitForEnter);
return abs(5-i);
}
cout<<">- ";
}else{
if(KEY_DOWN(KEYEnter)){
cls();
getline(cin,JustForWaitForEnter);
return abs(5-i);
}
cout<<" - ";
}
}
int clocks=clock()+CLOCKS_PER_SEC*0.5;
for(int i=clock();i<=clocks;i=clock()){
if(KEY_DOWN(KEYEnter)) {
cls();
return (i==5?-1:abs(5-i));
}
}
cls();
}
return 0;
}
/*
介绍道具
ACDog's bone
对方单个单位-2血对CE/WA有特效(用此击败CE不会变成WA,WA-3血)
chocolate milk
喝了后血+3
long long bomb
对方所有单位-2血对RE/WA有特效(WA-3血,RE-3血),会给MLE回1滴血
std11
吃了后血+1,FP+3
/*
Gdata.data:
第0~1位:巧克力牛奶(0补位)
第2~3位:AC狗的骨头(0补位)
第4~5位:long long炸弹(0补位)
第6~7位:std11(0补位)
GdataB.data
0~10位:位置(场景) (0补位)
11~12位:章节(01~99)
GdataC.data
0~3位:fastset(文字速度)
GdataB-N.data
0~N位:玩家名
*/
//文字速度
double fastset=1;
//道具
short qklnn=0; //巧克力牛奶
short acdog_bone=0;//
short longlongbomb=0;//
short std11=0;//
//字符类型 错误/布尔值
const string strtrue_="@True string type";
const string strfalse_="@False string type";
const string strerror_="@Error string type";
//int error
const int interror=-0xC0001;
typedef long long ll;
#include <limits>
#include <conio.h>
int waitFor2(int k1,int k2,int timeout=10){
int o=clock()+timeout*CLOCKS_PER_SEC;
while(clock()<o){
if(KEY_DOWN(k1)||KEY_DOWN(k2)){
cin.ignore();
return KEY_DOWN(k1)*10+KEY_DOWN(k2);
}
}
return 1;
}int waitForn2(int k1,int k2,int timeout=10){
int o=clock()+timeout*CLOCKS_PER_SEC;
while(clock()<o){
if(!(KEY_DOWN(k1)||KEY_DOWN(k2))){
return 0;
}
}
return 1;
}
void coutw(string th,double wait=0.1,int i=0,bool stop=true){
if(i>=th.size()) return;
char n=th[i];
cout<<n;
if(sleep_(wait,stop)){
wait=0;
}
coutw(th,wait,i+1);
}
void say(string th,double wait=0.1,int i=0,bool stop=true){
coutw(th,wait,i,stop);
sleep_(0.2);
cout<<"(按下Enter继续)\n";
int stc=clock();
int edc=stc-10;
while((stc-edc)<100){
stc=clock();
getline(cin,JustForWaitForEnter);
edc=clock();
if((edc-stc)>100)
break;
}
sleep_(0.1);
system("cls");
}
bool isfile(string name) {
TCHAR filePath[256];
_tcscpy(filePath, name.c_str());
DWORD attrib = GetFileAttributes(filePath);
if (attrib != INVALID_FILE_ATTRIBUTES && !(attrib & FILE_ATTRIBUTE_DIRECTORY)) {
return true;
} else {
return false;
}
}
string GetData(string fp){
string retu="";
ifstream file(fp.c_str()); // 打开文件
if (file.is_open()) {
string line;
while (getline(file, line)) {
retu+=line+"\n";
}
file.close();
} else {
cout<<"打开文件出错!"<<"\n";
while(true){
char isY;
cout<<"继续游玩将会清空存档!(Y/N)";
cin>>isY;
cout<<"\n";
if(isY=='Y'){
return strerror_+strtrue_;
}if(isY=='N'){
return strerror_+strfalse_;
}else{
cout<<"输入错误!"<<'\n';
}
}
}
return retu;
}
void savedata(const string& filename, const string& content) {
ofstream file(filename.c_str());
if(file) {
file << content;
} else {
cerr << "错误!无法保存: " << filename << endl;
}
}
void cls(){
system("cls");
}
double stodouble(const char* str) {
char* end;
double val = strtod(str, &end);
return (end != str && *end == '\0') ? val : 0.0;
}
bool newf=false;
string wz,zj;
string Data1,Data2,Data,Data1N;
void speak(string name,string th){
if(name==""){
cout<<Data1N<<":\n";
say(" "+th,0.03*fastset);
}else{
cout<<name<<":\n";
say(" "+th,0.03*fastset);
}
}
void said(string name,string th){
speak(name,"cout<<\""+th+"\";\n");
}
void text01(bool hy=false){
say("第一章: 误入AC领地");
say("你不小心在写csp-J复赛的时候UKE(unkown error)\n并且还掉入这个神奇的代码世界\n",0.05*fastset);
say("你来到了一个完全由代码组成世界\n",0.05*fastset);
say("你发现了一群... AC小方块?\n他们用cout交流\n",0.05*fastset);
cout<<"AC???:\n";
say(" cout<<\"你是谁?!\";\n",0.03*fastset);
cout<<Data1N<<":\n";
say(" cout<<\"这是哪,我不是在考CSP-J吗?\";\n",0.03*fastset);
cout<<"AC???:\n";
say(" cout<<\"CSP-J!\\n你是怎么知道的?\";\n",0.03*fastset);
cout<<"AC???:\n";
say(" cout<<\"我看你也不是AC或WA的人啊\";\n",0.03*fastset);
cout<<Data1N<<":\n";
say(" cout<<\"我这是到平行宇宙了?\";\n",0.03*fastset);
cout<<"AC???:\n";
say(" cout<<\"你问我,我问谁?\";\n",0.03*fastset);
cout<<Data1N<<":\n";
say(" printf(\"这还能用printf!\");\n",0.03*fastset);
cout<<"AC???:"<<"\n";
say(" cout<<\"看来你因该无害\";\n",0.03*fastset);
cout<<Data1N<<":\n";
say(" cout<<\"我能打你不成?\";\n",0.03*fastset);
cout<<"AC???:"<<"\n";
say(" cout<<\"最近有UKE率领WA,CE,RE...攻占我们的领地\";\n",0.03*fastset);
cout<<Data1N<<":\n";
say(" cout<<\"UKE...是不是unknow error\";\n",0.03*fastset);
cout<<"AC???:"<<"\n";
say(" cout<<\"你难道是他们的人?!\";\n",0.03*fastset);
cout<<Data1N<<":\n";
say(" cout<<\"No No No\";\n",0.03*fastset);
cout<<"AC???:"<<"\n";
say(" cout<<\"你会printf,好像不是\";\n",0.03*fastset);
cout<<Data1N<<":\n";
say(" cout<<\"UKE是WA他们的首领\";\n",0.03*fastset);
speak("","cout<<\"我就是因为UKE来到这的\";");
speak("AC???","cout<<\"UKE?你是来打败UKE的吗?\";\n");
speak("","cout<<\"YES\"\n;");
if(!hy){
zj="02";
savedata("GdataB.data",wz+zj);
speak("你不用知道我是谁,因为我是python卧底!"," print('温馨提示:数据以保存',end='。\\n')#你猜我为什么能用python");
}
}
void text02(bool hy=false){
say("第一章第2章节");
speak("","cout<<\"对了,我是"+Data1N+"\";\n");
speak("AC???","cout<<\"说了这么久都忘了自我介绍了\";\n");
said("AK村村长","我是AK村村长");
said("AK村村长","我已经帮你分配好住所了");
said("AK村村长","在这");
if(!hy){
zj="03";
savedata("GdataB.data",wz+zj);
speak("python卧底","恭喜,<家>功能以开启\n");
speak("你不用知道我是谁,因为我是python卧底!"," print('温馨提示:数据以保存',end='。\\n')\n");
speak("python卧底","你可以进去看看\n");
speak("python卧底","或者继续挑战主线\n");
speak("python卧底","我先帮你退回标题\n");
}
}void text03(bool hy=false){
say("第二章: 听取WA声一片");
said("AK村村长","勇者,既然你要挑战UKE,帮忙解决我们AC一族的难题");
said("AK村村长","我会将我们的村庄勇者-循环结构 给你");
said("AK村村长","不过请帮忙把村落外的WA/CE打败");
said("AK村村长","这是一本图鉴,交给你了");
said("","OK");
speak("python卧底","获得图鉴!\n");
speak("python卧底","暂时不给你看图鉴\n");
speak("python卧底","提示:CE死后会变成WA\n");
speak("python卧底","教学一下,请在>指向Y时按Enter\n");
int xdx=push_at_good_time();
xdx=(xdx<0?3:(xdx-2>=1?xdx-3:0));
speak("python卧底","你得了"+to_string(xdx)+"分");
speak("python卧底","战斗马上开始!\n");
if(!hy){
zj="04";
//savedata("GdataB.data",wz+zj);#########################
}
}
void game(){
if (newf){
coutw("你可以用换行让这种文字快速加载完,试试吧!!!!!!!\n",0.5);
}
sleep_(1);
if(zj=="01"){
if(newf){
cout<<"请输入玩家名:";
cin>>Data1N;
if (Data1N=="ac_doge"){
cout<<"欢迎回来,管理员";
}
savedata("GdataB-N.data",Data1N);
}
cls();
sleep_(1);
text01();
return;
}
if(zj=="02"){
text02();
return;
}if(zj=="03"){
text03();
return;
}else{
cout<<zj;
sleep_(10);
}
}
int main(){
cls();
bool running=true;
if(isfile("Gdata.data")){
Data=GetData("Gdata.data");
qklnn=(Data[0]-'0')*10+(Data[1]-'0');
acdog_bone=(Data[2]-'0')*10+(Data[3]-'0');
longlongbomb=(Data[4]-'0')*10+(Data[5]-'0');
std11=(Data[6]-'0')*10+(Data[7]-'0');
}else{
}
if(isfile("GdataB.data")){
Data1=GetData("GdataB.data");
wz=Data1.substr(0,11);
string str1(1,Data1[11]);
string str2(1,Data1[12]);
zj=str1+str2;//章节
}else{
newf=true;
}
if(isfile("GdataC.data")){
Data2=GetData("GdataC.data");
fastset=stodouble(Data2.substr(0,3).c_str());
}else{
newf=true;
}if(isfile("GdataB-N.data")){
Data1N=GetData("GdataB-N.data");
Data1N=Data1N.substr(0,Data1N.size()-1);
player_self.name=Data1N;
}else{
newf=true;
}
coutw("感谢游玩《AC RPG》ver.1.0\n",0.05*fastset);
sleep_(0.2);
cout<<"版权所有 @python卧底 保留所有权利"<<"\n";
cout<<"制作者/鸣谢:"<<"\n";
cout<<"@python卧底--代码"<<"\n";
cout<<"@Jason--赞助&提供建议"<<"\n";
cout<<"@打印机各自天涯--赞助&提供建议\n\n";
while (running){
sleep_(0.1);
int chose=-1;
while (chose<=0||chose>5){
if(newf){
cout<<"1.新的游戏"<<endl;
savedata("Gdata.data","000000");
savedata("GdataB.data","0000000000001");
savedata("GdataC.data","1.0");
wz="00000000000"; //位置(场景)
zj="01";
}else{
cout<<"1.继续游戏"<<endl;
}
cout<<"2.设置"<<"\n";
cout<<"3.Changelog"<<"\n";
cout<<"4.家\n";
cout<<"5.图鉴\n";
cout<<":";
cin>>chose;
if(chose<=0||chose>5){
coutw("输入错误!",0.1*fastset);
}
system("cls");
}
sleep_(0.2);
if(chose==4){
if(newf||(zj[0]=='0'&&zj[1]<'3')){
cout<<"第2章后解锁!";
}else{
coutw("在这可以预览道具,角色!\n");
cout<<"--------角色--------\n";
cout<<Data1N<<'\n';
cout<<"血量:"<<player_self.health<<'\n';
cout<<"防御:"<<player_self.Defense<<'\n';
cout<<wz<<endl;
if(zj[0]>'1')cout<<loop.name<<endl;
if(zj[0]>'1')cout<<"血量:"<<loop.health<<endl;
if(zj[0]>'1')cout<<"防御:"<<loop.Defense<<endl;
cout<<"--------道具--------\n";
cout<<"AC dog的骨头:"<<acdog_bone<<"个\n";
cout<<" 让AC dog帮你修代码!\n";
cout<<" 对方单个单位-2血对CE/WA有特效(用此击败CE不会变成WA,WA-3血)\n";
cout<<"巧克力牛奶:"<<qklnn<<"个\n";
cout<<" 巧克力牛奶真好喝,听说巧克力都是取自struct Cocoa_tree\n";
cout<<" 血量+3\n";
cout<<"long long 炸弹!:"<<longlongbomb<<'\n';
cout<<" 家里请long long也没用了!(MLE)\n";
cout<<" 对方所有单位-2血对RE/WA有特效(WA-3血,RE-3血),会给MLE回1滴血\n";
system("pause");
}
}
else if(chose==5){
if(newf||(zj[0]=='0'&&zj[1]<'4')){
cout<<"第一章第3章节后解锁!";
}
}
else if(chose==3){
cout<<"Zeta:有bug的版本 Beta:预发布 Alph:小更新\n";
coutw("1.0 游戏横空出世\n",0.03*fastset);
coutw("1.1Alph 加入剧情\n");
coutw("1.2Beta 加入第2章&道具");
coutw("1.2.1 更新战斗系统",0.03*fastset);
coutw("1.2.1Beta Zeta 完善& WA小怪 & CE 怪\n",0.03*fastset);
sleep_(2);
system("cls");
continue;
}else if(chose==2){
cout<<"1.字体出现速度(0.0~3)="<<fastset<<endl;
cout<<"2.back\n";
cin>>chose;
system("cls");
if(chose>2||chose<1){
cout<<"输入错误!";
sleep_(1);
}else if(chose==1){
cout<<"速度(0~3.0):";
double st;
cin>>st;
if(st<=0.01||st>3){
cout<<"输入错误!";
sleep_(1);
}else{
fastset=st;
savedata("GdataC.data",to_string(round(fastset * 10) / 10).substr(0,3));//GdataC
}
}
system("cls");
}else if(chose==1){
newf=false;
game();
}
sleep_(0.4);
cls();
}
return 0;
}
全部评论 2
顶
21小时前 来自 上海
2🙏🙏🙏
21小时前 来自 上海
0期待第二章节%%%
21小时前 来自 上海
1作为第2个支持我的人,我会吧你的昵称写人游戏开头,(Yes/No)
21小时前 来自 上海
0
147行咋报错了
昨天 来自 上海
0OK(因为c++版本不同),现在修好了不会再有问题了
23小时前 来自 上海
0OK
23小时前 来自 上海
0
有帮助,赞一个