游戏开发日志支线2
2026-02-01 19:57:22
发布于:香港
接上回
游戏:Typing Game
更新版本:0.2
代码:李伙子ia
美术:也没美术啊
翻译:Artificial Intelligence
团队:新手团
这次更新了2条内容
· 关卡扩容
std::string levels[]={
"Typing Game",
"fj",
"f f j j f j f j f f f j j j f j j j j f",
"ffff jjjj fff jjj ff jj fjfj jfjf fjjf jffj",
"dk",
"d d k k d k d k d d d k k k d k k k k d",
"dddd kkkk ddd kkk dd kk dkdk kdkd dkkd kddk",
"ff jj fj dd kk dk jf jjff kd kkdd fjdk kdjf fkjd kfdj ffffjjjjddddkkkk",
"sl",
"s s l l s l s l s s s l l l s l l l l s",
"ssss llll sss lll ss ll slsl lsls slls lssl",
"a;",
"a a ; ; a ; a ; a a a ; ; ; a ; ; ; ; a",
"aaaa ;;;; aaa ;;; aa ;; a;a; ;a;a a;;a ;aa;",
"ss ll sl aa ;; a; sl ssll a; aa;; sla; ;als s;la ;sal ssssllllaaaa;;;;", //0.1版本
"gh",
"g g h h g h g h g g g h h h g h h h h g",
"gggg hhhh ggg hhh gg hh ghgh hghg ghhg hggh",
"glad dad had half a glass as salad; dad shall ask glass flags had glass ask shall flask had slash jaff" //Level 18
"ru",
"r r u u r u r u r r r u u u r u u u u r",
"rrrr uuuu rrr uuu rr uu ruru urur ruur urru",
"ei",
"e e i i e i e i e e e i i i e i i i i e",
"eeee iiii eee iii ee ii eiei ieie eiie ieei",
"rr uu ru ee ii ei ru rruu ei eeii ruei ieur riue ireu rrrruuuueeeeiiii",
};
const int32_t L=1,R=25; //选择关卡范围:1~14 -> 1~25
· 游戏设置
unsigned char main_menu_key,game_setting_key;
//system_key -> main_meun_key, 新增了 game_setting_key
std::string timing_unit="s"; //计时单位
//...
int32_t type_word_cnt=0,pass_level_cnt=0; //新增了 pass_level_cnt,用于记录关卡通关数
if(timing_unit=="s"){ //判断设置的计时单位
auto use_time=std::chrono::duration_cast<std::chrono::seconds>(end-start).count();
if(wrong==-1)std::cout<<"Level cannot be find it"<<std::endl;
else{
std::cout<<std::endl<<"Congratulation on pass the level!"<<std::endl;
std::cout<<"Used time: "<<use_time<<"s, Wrong words: "<<wrong<<std::endl;
pass_level_cnt++; //增加关卡通关数
}
}else if(timing_unit=="ms"){
auto use_time=std::chrono::duration_cast<std::chrono::milliseconds>(end-start).count();
if(wrong==-1)std::cout<<"Level cannot be find it"<<std::endl;
else{
std::cout<<std::endl<<"Congratulation on pass the level!"<<std::endl;
std::cout<<"Used time: "<<use_time<<"ms, Wrong words: "<<wrong<<std::endl;
pass_level_cnt++;
}
}else if(timing_unit=="mus"){
auto use_time=std::chrono::duration_cast<std::chrono::microseconds>(end-start).count();
if(wrong==-1)std::cout<<"Level cannot be find it"<<std::endl;
else{
std::cout<<std::endl<<"Congratulation on pass the level!"<<std::endl;
std::cout<<"Used time: "<<use_time<<"mus, Wrong words: "<<wrong<<std::endl;
pass_level_cnt++;
}
}else if(timing_unit=="ns"){
auto use_time=std::chrono::duration_cast<std::chrono::nanoseconds>(end-start).count();
if(wrong==-1)std::cout<<"Level cannot be find it"<<std::endl;
else{
std::cout<<std::endl<<"Congratulation on pass the level!"<<std::endl;
std::cout<<"Used time: "<<use_time<<"ns, Wrong words: "<<wrong<<std::endl;
pass_level_cnt++;
}
}else{ //默认second
auto use_time=std::chrono::duration_cast<std::chrono::seconds>(end-start).count();
if(wrong==-1)std::cout<<"Level cannot be find it"<<std::endl;
else{
std::cout<<std::endl<<"Congratulation on pass the level!"<<std::endl;
std::cout<<"Used time: "<<use_time<<"s, Wrong words: "<<wrong<<std::endl;
pass_level_cnt++;
}
}
case 83: //'S'的ascii码是83
case 115:{ //'s'的ascii码是115
std::cout<<"Game Settings"<<std::endl;
std::cout<<"Credits"<<std::endl;
std::cout<<"Author: Li Huozi IA"<<std::endl;
std::cout<<"Art: No"<<std::endl;
std::cout<<"English translation: Artificial Intelligence"<<std::endl;
std::cout<<std::endl;
std::cout<<"Change setting"<<std::endl;
std::cout<<"Palse 't' change the timing unit"<<std::endl;
std::cout<<"Palse [Esc] exit the game setting"<<std::endl;
std::cout<<std::endl;
std::cout<<"Suffer"<<std::endl;
std::cout<<"Typed Words: "<<type_word_cnt<<std::endl; //显示打过夺少字
std::cout<<"Passed Levels: "<<pass_level_cnt<<std::endl; //显示关卡通关数
game_setting_key=_getch();
system("cls");
switch(game_setting_key){
case 'T': //'T'不用管
case 't':{ //'t'不用管
std::cout<<"Using timing unit: "<<timing_unit<<std::endl;
std::cout<<"Support units"<<std::endl;
std::cout<<"- s: second"<<std::endl;
std::cout<<"- ms: millisecond (1/1,000s)"<<std::endl;
std::cout<<"- mus: microsecond (1/1,000,000s)"<<std::endl;
std::cout<<"- ns: nanosecond (1/1,000,000,000s)"<<std::endl;
std::cout<<"Change to (s, ms, mus, ns): ";
std::cin>>timing_unit; //修改计时单位(暂无错误单位检测)
std::cout<<"Setting finish!"<<std::endl;
std::cout<<"Palse any keys to contiune . . . ";
_getch();
system("cls");
break;
}
case 27:{break;}
}
break;
}
成品:
#include<iostream>
#include<string>
#include<conio.h>
#include<windows.h>
#include<chrono>
unsigned char main_menu_key,game_setting_key;
std::string timing_unit="s";
std::string name="";
int32_t type_word_cnt=0,pass_level_cnt=0;
std::string levels[]={
"Typing Game",
"fj",
"f f j j f j f j f f f j j j f j j j j f",
"ffff jjjj fff jjj ff jj fjfj jfjf fjjf jffj",
"dk",
"d d k k d k d k d d d k k k d k k k k d",
"dddd kkkk ddd kkk dd kk dkdk kdkd dkkd kddk",
"ff jj fj dd kk dk jf jjff kd kkdd fjdk kdjf fkjd kfdj ffffjjjjddddkkkk",
"sl",
"s s l l s l s l s s s l l l s l l l l s",
"ssss llll sss lll ss ll slsl lsls slls lssl",
"a;",
"a a ; ; a ; a ; a a a ; ; ; a ; ; ; ; a",
"aaaa ;;;; aaa ;;; aa ;; a;a; ;a;a a;;a ;aa;",
"ss ll sl aa ;; a; sl ssll a; aa;; sla; ;als s;la ;sal ssssllllaaaa;;;;",
"gh",
"g g h h g h g h g g g h h h g h h h h g",
"gggg hhhh ggg hhh gg hh ghgh hghg ghhg hggh",
"glad dad had half a glass as salad; dad shall ask glass flags had glass ask shall flask had slash jaff" //Level 18
"ru",
"r r u u r u r u r r r u u u r u u u u r",
"rrrr uuuu rrr uuu rr uu ruru urur ruur urru",
"ei",
"e e i i e i e i e e e i i i e i i i i e",
"eeee iiii eee iii ee ii eiei ieie eiie ieei",
"rr uu ru ee ii ei ru rruu ei eeii ruei ieur riue ireu rrrruuuueeeeiiii",
};
const int32_t L=1,R=25;
std::string _levels_[]={
"Typing Game",
"???"
};
int32_t typing_level(int32_t level){
int32_t wrong=0;
if(level<L||level>R)return -1;
std::string typing_words=levels[level];
size_t len=typing_words.size();
std::cout<<typing_words<<std::endl;
for(size_t i=0;i<len;){
unsigned char typing_key=_getch();
if(typing_key==typing_words.at(i)){std::cout<<"_";i++;}
else wrong++;
type_word_cnt++;
}
return wrong;
}
int main(){
std::cout<<"What is your name?"<<std::endl;
std::cout<<"Your answer: ";
std::getline(std::cin,name);
system("cls");
while(1){
std::cout<<"Typing Game"<<std::endl;
std::cout<<"Version: 0.2"<<std::endl;
std::cout<<"ID: 001"<<std::endl;
std::cout<<"Name: "+name<<std::endl;
std::cout<<"Main Menu"<<std::endl;
std::cout<<"Palse [space] start the game"<<std::endl;
std::cout<<"Palse [Esc] exit the game"<<std::endl;
std::cout<<"Palse 's' change game settings"<<std::endl;
main_menu_key=_getch();
system("cls");
switch(main_menu_key){
case 32:{
std::cout<<"Please choose a level."<<std::endl;
std::cout<<"Level "<<L<<"~"<<R<<": ";
int32_t level;
std::cin>>level;
std::cin.ignore();
system("cls");
std::cout<<"level "<<level<<std::endl;
auto start=std::chrono::high_resolution_clock::now();
int32_t wrong=typing_level(level);
auto end=std::chrono::high_resolution_clock::now();
if(timing_unit=="s"){
auto use_time=std::chrono::duration_cast<std::chrono::seconds>(end-start).count();
if(wrong==-1)std::cout<<"Level cannot be find it"<<std::endl;
else{
std::cout<<std::endl<<"Congratulation on pass the level!"<<std::endl;
std::cout<<"Used time: "<<use_time<<"s, Wrong words: "<<wrong<<std::endl;
pass_level_cnt++;
}
}else if(timing_unit=="ms"){
auto use_time=std::chrono::duration_cast<std::chrono::milliseconds>(end-start).count();
if(wrong==-1)std::cout<<"Level cannot be find it"<<std::endl;
else{
std::cout<<std::endl<<"Congratulation on pass the level!"<<std::endl;
std::cout<<"Used time: "<<use_time<<"ms, Wrong words: "<<wrong<<std::endl;
pass_level_cnt++;
}
}else if(timing_unit=="mus"){
auto use_time=std::chrono::duration_cast<std::chrono::microseconds>(end-start).count();
if(wrong==-1)std::cout<<"Level cannot be find it"<<std::endl;
else{
std::cout<<std::endl<<"Congratulation on pass the level!"<<std::endl;
std::cout<<"Used time: "<<use_time<<"mus, Wrong words: "<<wrong<<std::endl;
pass_level_cnt++;
}
}else if(timing_unit=="ns"){
auto use_time=std::chrono::duration_cast<std::chrono::nanoseconds>(end-start).count();
if(wrong==-1)std::cout<<"Level cannot be find it"<<std::endl;
else{
std::cout<<std::endl<<"Congratulation on pass the level!"<<std::endl;
std::cout<<"Used time: "<<use_time<<"ns, Wrong words: "<<wrong<<std::endl;
pass_level_cnt++;
}
}else{
auto use_time=std::chrono::duration_cast<std::chrono::seconds>(end-start).count();
if(wrong==-1)std::cout<<"Level cannot be find it"<<std::endl;
else{
std::cout<<std::endl<<"Congratulation on pass the level!"<<std::endl;
std::cout<<"Used time: "<<use_time<<"s, Wrong words: "<<wrong<<std::endl;
pass_level_cnt++;
}
}
std::cout<<"Palse any keys to contiune . . . ";
_getch();
system("cls");
break;
}
case 83:
case 115:{
std::cout<<"Game Settings"<<std::endl;
std::cout<<"Credits"<<std::endl;
std::cout<<"Author: Li Huozi IA"<<std::endl;
std::cout<<"Art: No"<<std::endl;
std::cout<<"English translation: Artificial Intelligence"<<std::endl;
std::cout<<std::endl;
std::cout<<"Change setting"<<std::endl;
std::cout<<"Palse 't' change the timing unit"<<std::endl;
std::cout<<"Palse [Esc] exit the game setting"<<std::endl;
std::cout<<std::endl;
std::cout<<"Suffer"<<std::endl;
std::cout<<"Typed Words: "<<type_word_cnt<<std::endl;
std::cout<<"Passed Levels: "<<pass_level_cnt<<std::endl;
game_setting_key=_getch();
system("cls");
switch(game_setting_key){
case 'T':
case 't':{
std::cout<<"Using timing unit: "<<timing_unit<<std::endl;
std::cout<<"Support units"<<std::endl;
std::cout<<"- s: second"<<std::endl;
std::cout<<"- ms: millisecond (1/1,000s)"<<std::endl;
std::cout<<"- mus: microsecond (1/1,000,000s)"<<std::endl;
std::cout<<"- ns: nanosecond (1/1,000,000,000s)"<<std::endl;
std::cout<<"Change to (s, ms, mus, ns): ";
std::cin>>timing_unit;
std::cout<<"Setting finish!"<<std::endl;
std::cout<<"Palse any keys to contiune . . . ";
_getch();
system("cls");
break;
}
case 27:{break;}
}
break;
}
case 27:{
std::cout<<"Goodbye!";
return 0;
}
}
}
}
最后你能打出'µ'吗?
这里揭晓
全部评论 1
Windows答案:按住[Alt]->键盘右侧数字键打0181->松开[Alt]->就打出'µ'了!
2天前 来自 香港
1















有帮助,赞一个