0
已解决
王牌工作室官方
新手光能
新手光能
WPCRAFT是一个类似MC的,开源的游戏,目前只做了开始界面
源码:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<ctime>
#include<sstream>
#include<windows.h>
#include<conio.h>
//#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)
using namespace std;
int width=100,height=30;
HANDLE hout=GetStdHandle(STD_OUTPUT_HANDLE),hin=GetStdHandle(STD_INPUT_HANDLE);
struct
{
string username;
}database;
const struct
{
int white_black=15*16+0;
int gray_white =8*16+15;
}colors;
void color(int col)
{
SetConsoleTextAttribute(hout,col);
}
void gotoxy(short x, short y)
{
COORD coord = {x, y};
SetConsoleCursorPosition(hout,coord);
}
void cursor(bool visible)
{
CONSOLE_CURSOR_INFO CursorInfo;
GetConsoleCursorInfo(hout,&CursorInfo);
CursorInfo.bVisible = visible;
SetConsoleCursorInfo(hout,&CursorInfo);
}
void cls()
{
gotoxy(0,0);
}
COORD getCursorPos()
{
CONSOLE_SCREEN_BUFFER_INFO csbi;
GetConsoleScreenBufferInfo(hout,&csbi);
return csbi.dwCursorPosition;
}
template<class Type>
string toString(Type t)
{
ostringstream sout;
sout<<t;
return sout.str();
}
void Line(string str,int col=colors.white_black)
{
int start=(width-str.size())/2;
for(int i=1;i<=start;i++) cout<<" ";
color(col);
cout<<str<<endl;
color(colors.white_black);
}
string GetTime()
{
time_t timep;
time (&timep);
char tmp[64];
strftime(tmp,sizeof(tmp),"%Y%m%d",localtime(&timep));
return tmp;
}
bool endDay()
{
string endday="20230701";
if(GetTime()>endday)
{
return true;
}
return false;
}
void LeftLine(string s)
{
cout<<s<<endl;
}
void RightLine(string s)
{
for(int i=1;i<=width-s.size();i++) cout<<" ";
cout<<s<<endl;
}
void showMainMenu()
{
if(database.username=="") RightLine("Login[L]");
else RightLine("Welcome "+database.username);
Line("W W W PPPPPP CCCCC RRRRRR A FFFFFF TTTTTTT");
Line(" W W W W P P C R R A A F T ");
Line(" W W W W PPPPPP C RRRRRR A A FFFFFF T ");
Line(" W W W W P C RRR AAAAAAA F T ");
Line(" WW W P CCCCC R RRR A A F T ");
cout<<endl<<endl<<endl<<endl;
Line("Start Play[F]",colors.gray_white);
cout<<endl<<endl;
Line("Online Play [V]",colors.gray_white);
cout<<endl<<endl;
Line("WP_Studio Community[G]",colors.gray_white);
cout<<endl<<endl;
Line("Feedback[T]",colors.gray_white);
gotoxy(0,height-1);
cout<<("All rights reserved by WP-Studio");
}
void login()
{
cout<<"Waiting...";
getch();
}
void playGame()
{
cout<<"Waiting...";
getch();
}
void onlineGame()
{
cout<<"Waiting...";
getch();
}
int main()
{
if(endDay()) return 0;
cursor(false);
system("color f0");
system(("mode con cols="+toString(width)+" lines="+toString(height)).c_str());
system("title WPCRAFT 1.0");
while(1)
{
int com='?';
cls();
showMainMenu();
com=getch();
switch(com)
{
case 'l':
case 'L': {
system("cls");
login();
break;
}
case 'f':
case 'F': {
system("cls");
playGame();
break;
}
case 'v':
case 'V': {
system("cls");
onlineGame();
break;
}
case 'g':
case 'G': {
system("start https://www.luogu.com.cn/team/41333");
break;
}
case 't':
case 'T': {
system("start https://www.luogu.com.cn/chat?uid=671715");
break;
}
}
}
return 0;
}
同时,也希望大家能踊跃加入王牌工作室(加入王牌工作室社区也行)
王牌工作室官方在2022-09-27 12:37:15追加了内容
改编请获得作者授权,游戏是英文版,哪天我出个翻译
王牌工作室官方在2022-09-27 12:56:49追加了内容
加入王牌工作室请参加此比赛
https://www.luogu.com.cn/contest/84846
邀请码:ggtz
王牌工作室官方在2022-09-27 12:57:20追加了内容
错版了!!!!!望谅解
王牌工作室官方在2022-10-02 15:37:28追加了内容
其实呢,我们很想搞个中文,但是中文占格两格,strlen函数只把它算一个字符,会打乱居中输出函数的动作,我们正在研究如何计算占格数
0
0
0
0
0
0