打字游戏c++版(自创)······求赞
2026-10-11 15:35:02
发布于:浙江
打字游戏
废话不多说直接上代码
#include"stdio.h"
#include"stdlib.h"
#include"windows.h"
#include"conio.h"
#include<bits/stdc++.h>
#include<climits>
using namespace std;
void kong(int num){
for(int i = 0; i < num; i++){
printf(" ");
}
}
void enter(int num){
int i;
for(i = 0; i < num; i++){
printf("\n");
}
}
int main(){
long long life;
enter(15);
kong(10);
printf("请选择模式:a.入门, b.新手, c.中等, d.高手, e.大佬, f.递进, g.自定义");
char xx;
xx = getch();
if(xx != 'g'){
life = 3;
}
kong(40);
int shi;
if(xx == 'g'){
system("cls");
enter(15);
kong(40);
cout << "请输入时间隔(ms):";
cin >> shi;
kong(40);
cout << "请输入生命数:";
cin >> life;
}
system("cls");
char xuan = 'y';
int mxscore = 0;
int levels = 1;
int score = 0;
int num = 0;
int col = 0;
while(xuan == 'y'){
int lines = 0;
mxscore = max(mxscore, score);
system("cls");
for(int i = 0; i < 15; i++) {
printf(" ");
}
if(xx == 'f'){
for(int i = 0; i < 5; i++) {
printf(" ");
}
}
printf("levels:%d", levels);
kong(5);
printf("score:%d", score);
kong(5);
printf("highscore:%d", mxscore);
kong(5);
printf("life:%d", life);
printf("\n");
kong(30);
printf("1---Pause");
kong(9);
printf("0---Exit");
printf("\n");
for(int i = 0; i < 80; i++){
printf("_");
}
enter(1);
srand(static_cast<unsigned int>(time(0)));
num = rand() % 26;
col = rand() % 80;
while(xuan == 'y'){
lines++;
if(lines > 25){
lines = 0;
life--;
break;
}
kong(col);
printf("%c", 'a' + num);
if(xx == 'a'){
Sleep(200);
}else if(xx == 'b'){
Sleep(158);
}else if(xx == 'c'){
Sleep(100);
}else if(xx == 'd'){
Sleep(50);
}else if(xx == 'e'){
Sleep(25);
}else if(xx == 'f'){
if(score <= 50){
levels = 1;
Sleep(180);
}else if(score <= 200){
levels = 2;
Sleep(150);
}else if(score <= 500){
levels = 3;
Sleep(110);
}else if(score <= 1000){
levels = 4;
Sleep(70);
}else if(score <= 1750){
levels = 5;
Sleep(50);
}else{
levels = 6;
Sleep(30);
}
}else{
Sleep(shi);
}
printf("\b \n");
if(kbhit()){
char c = getch();
if(c == 'a' + num){
score += 10;
break;
}else if(c == '0'){
exit(0);
}else if(c == '1'){
c = getch();
}else{
life--;
}
}
if(life <= 0){
system("cls");
enter(14);
kong(40);
printf("game over!");
printf("\n");
kong(40);
printf("your score is:%d", mxscore);
printf("\n");
kong(40);
char sure = 'n';
int flag = 1;
while(sure == 'n'){
if(flag){
flag = 0;
}else{
printf("\n");
kong(40);
}
printf("again?(y or n)");
xuan = getch();
if(xuan == 'y'){
system("cls");
life = 3;
levels = 1;
score = 0;
num = 0;
break;
}
system("cls");
enter(15);
kong(40);
printf("are you sure?(y or n)");
sure = getch();
if(sure == 'y'){
exit(0);
}
}
system("cls");
enter(15);
kong(10);
printf("请选择模式:a.入门, b.新手, c.中等, d.高手, e.大佬, f.递进, g.自定义");
xx = getch();
if(xx == 'g'){
system("cls");
enter(15);
kong(40);
cout << "请输入时间隔(ms):";
cin >> shi;
}
break;
}
}
}
return 0;
}
求赞 !!!!!!!!!!!!!!!!!!!!!!!!!!!
这里空空如也
















有帮助,赞一个