目录
上期回顾
本期目标
实现讲解
成功实现
代码源码
上期回顾
上次通过system成功将标题改为生活大冒险,我在预告中曾说,这只是一个临时名,如果谁有更好的名字。实现加载
本期目标
登录完成
实现讲解
第一问先弄出来
system("pause");
system("cls");
cout << "欢迎来到生活大冒险" << endl;
cout << endl;
cout << "查看前言 [1] 不查看 [2]" << endl;
接下来,就要把无Enter选择做出来了
先定义
char ch;
输入
ch = getch();
getch就是输入并判断字符用的
ch就是在那个变量作输入
下一步就要注意了
if(ch == '1'){
system("cls");
while(1){
cout << "欢迎来到生活大冒险" << endl;
cout << endl;
cout << "版本:2.0版" << endl;
cout << "测试:否" << endl;
cout << "关于游戏:" << endl;
cout << " 本游戏为文字游戏,会有由文字或字符组成的图片。" << endl;
cout << "关于更新:" << endl;
cout << " 更新了数字按错会失败的问题" << endl;
cout << endl;
cout << "退出按1" << endl;
char ch2;
ch2 = getch();
if(ch2 == '1'){
system("cls");
cout << "欢迎来到生活大冒险" << endl;
cout << endl;
break;
}else{
system("cls");
}
}
}
使用使用while+system(“cls”);组合如果选择的数字在选项里,那么break退出循环,如果选的不是选项里的数字,那么就陷入下一层循环。
最后把else造出来,第一问就完事了
else{
system("cls");
}
将第二问造出来
cout << "你是?" << endl;
cout << endl;
cout << "1.玩过1.0版 [1] 2.没玩过1.0版[2]" << endl;
然后再次使用w+s(while+system(“cls”)的简称)实现选择
这就不多说了,前面讲过了
char ch3;
ch3 = getch();
if(ch3 == '1'){
system("cls");
}else if(ch3 == '2'){
cout << "建议你去玩一下1.0版~" << endl;
system("cls");
}else{
while(1){
if(ch3 == '1'){
system("cls");
break;
}else if(ch3 == '2'){
cout << "建议你去玩一下1.0版~" << endl;
system("cls");
}else{
system("cls");
}
}
}
然后就可以开始登陆了
简单的造一下
cout << "欢迎来到生活大冒险" << endl;
system("color 70");
cout << "先注册一下吧!" << endl;
string name;
cout << endl;
cout << " 名字:";
cin >> name;
cout << endl;
cout << " 性别:[1]男 [2]女" << endl;
然后也不用多说,想必大家都懂
char ch4;
int age;
ch4 = getch();
if(ch4 == '1'){
system("cls");
cout << "欢迎来到生活大冒险" << endl;
cout << "先注册一下吧!" << endl << endl;
cout << " 名字:" << name << endl << endl;
cout << " 性别:男" << endl;
age = 1;
}else if(ch4 == '2'){
system("cls");
cout << "欢迎来到生活大冒险" << endl;
cout << "先注册一下吧!" << endl << endl;
cout << " 名字:" << name << endl << endl;
cout << " 性别:女" << endl;
age = 2;
}else{
while(1){
cout << "欢迎来到生活大冒险" << endl;
cout << "先注册一下吧!" << endl << endl;
cout << " 名字:" << name << endl << endl;
cout << " 性别:[1]男 [2]女" << endl;
char ch5;
ch5 = getch();
if(ch5 == '1'){
system("cls");
cout << "欢迎来到生活大冒险" << endl;
cout << "先注册一下吧!" << endl << endl;
cout << " 名字:" << name << endl << endl;
cout << " 性别:男" << endl;
age = 1;
break;
}else if(ch5 == '2'){
system("cls");
cout << "欢迎来到生活大冒险" << endl;
cout << "先注册一下吧!" << endl << endl;
cout << " 名字:" << name << endl << endl;
cout << " 性别:女" << endl;
age = 2;
break;
}else{
system("cls");
}
}
}
今天先更到这
成功实现
成功完善登录
成功实现s+y放嗯错
代码源码
#include<bits/stdc++.h>
#include<windows.h>
#include<conio.h>
using namespace std;
int main(){
int sheng = 0;
system("title 生活大冒险");
system("color 90");
cout << "欢迎来到生活大冒险" << endl;
cout << endl << endl << endl << endl;
cout << " 加载中" << endl;
cout << "------------------------------------------" << endl;
cout << "| | %0" << endl;
cout << "------------------------------------------" << endl;
Sleep(300);
system("cls");
cout << "欢迎来到生活大冒险" << endl;
cout << endl << endl << endl << endl;
cout << " 加载中" << endl;
cout << "------------------------------------------" << endl;
cout << "|//| | %20" << endl;
cout << "------------------------------------------" << endl;
Sleep(300);
system("cls");
cout << "欢迎来到生活大冒险" << endl;
cout << endl << endl << endl << endl;
cout << " 加载中" << endl;
cout << "------------------------------------------" << endl;
cout << "|//| | %50" << endl;
cout << "------------------------------------------" << endl;
Sleep(500);
system("cls");
cout << "欢迎来到生活大冒险" << endl;
cout << endl << endl << endl << endl;
cout << " 加载中" << endl;
cout << "------------------------------------------" << endl;
cout << "|///| | %70" << endl;
cout << "------------------------------------------" << endl;
Sleep(700);
system("cls");
cout << "欢迎来到生活大冒险" << endl;
cout << endl << endl << endl << endl;
cout << " 加载中" << endl;
cout << "------------------------------------------" << endl;
cout << "|| %100" << endl;
cout << "------------------------------------------" << endl;
Sleep(1000);
system("pause");
system("cls");
cout << "欢迎来到生活大冒险" << endl;
cout << endl;
cout << "查看前言 [1] 不查看 [2]" << endl;
char ch;
cout << endl;
ch = getch();
if(ch == '1'){
system("cls");
while(1){
cout << "欢迎来到生活大冒险" << endl;
cout << endl;
cout << "版本:2.0版" << endl;
cout << "测试:否" << endl;
cout << "关于游戏:" << endl;
cout << " 本游戏为文字游戏,会有由文字或字符组成的图片。" << endl;
cout << "关于更新:" << endl;
cout << " 更新了数字按错会失败的问题" << endl;
cout << endl;
cout << "退出按1" << endl;
char ch2;
ch2 = getch();
if(ch2 == '1'){
system("cls");
cout << "欢迎来到生活大冒险" << endl;
cout << endl;
break;
}else{
system("cls");
}
}
}else{
system("cls");
}
cout << "你是?" << endl;
cout << endl;
cout << "1.玩过1.0版 [1] 2.没玩过1.0版[2]" << endl;
char ch3;
ch3 = getch();
if(ch3 == '1'){
system("cls");
}else if(ch3 == '2'){
cout << "建议你去玩一下1.0版~" << endl;
system("cls");
}else{
while(1){
if(ch3 == '1'){
system("cls");
break;
}else if(ch3 == '2'){
cout << "建议你去玩一下1.0版~" << endl;
system("cls");
}else{
system("cls");
}
}
}
cout << "欢迎来到生活大冒险" << endl;
system("color 70");
cout << "先注册一下吧!" << endl;
string name;
cout << endl;
cout << " 名字:";
cin >> name;
cout << endl;
cout << " 性别:[1]男 [2]女" << endl;
char ch4;
int age;
ch4 = getch();
if(ch4 == '1'){
system("cls");
cout << "欢迎来到生活大冒险" << endl;
cout << "先注册一下吧!" << endl << endl;
cout << " 名字:" << name << endl << endl;
cout << " 性别:男" << endl;
age = 1;
}else if(ch4 == '2'){
system("cls");
cout << "欢迎来到生活大冒险" << endl;
cout << "先注册一下吧!" << endl << endl;
cout << " 名字:" << name << endl << endl;
cout << " 性别:女" << endl;
age = 2;
}else{
while(1){
cout << "欢迎来到生活大冒险" << endl;
cout << "先注册一下吧!" << endl << endl;
cout << " 名字:" << name << endl << endl;
cout << " 性别:[1]男 [2]女" << endl;
char ch5;
ch5 = getch();
if(ch5 == '1'){
system("cls");
cout << "欢迎来到生活大冒险" << endl;
cout << "先注册一下吧!" << endl << endl;
cout << " 名字:" << name << endl << endl;
cout << " 性别:男" << endl;
age = 1;
break;
}else if(ch5 == '2'){
system("cls");
cout << "欢迎来到生活大冒险" << endl;
cout << "先注册一下吧!" << endl << endl;
cout << " 名字:" << name << endl << endl;
cout << " 性别:女" << endl;
age = 2;
break;
}else{
system("cls");
}
}
}
你看看我多好