自创游戏

自创游戏代码 自创游戏

直接上代码

#include <bits/stdc++.h> using namespace std; int main() { int l; cout << "请输入" << 0 << "或" << 1 << endl; sleep(1); cout << "推荐" << 1 << endl; sleep(1); cin >> l; if (l == 0) { cout << "欢迎来到游戏间1" << endl; cout << endl; sleep(1); cout << "你的目标是找到宝藏" << endl; sleep(1); srand(time(0)); int bg = time(0); int score = 0; clear(); cout << "你想要几次机会?" << endl; int b; cin >> b; while(b > 10) { cout << "宝藏寻找次数不能超过10次"; cin >> b; } clear(); for (int i = 1; i <= b; i++) { cout << "这是你第" << i << "次寻找宝藏, 请输入宝藏序号(10-100)" << endl; int a; cin >> a; int dis = rand() % 100 + 10; if(!(cin >> a)) { a = 0; i = b + 100; } if(abs(a-b) == dis ||abs(a - b)== dis - 5 || abs(a-b) == dis + 5) { cout << "恭喜找到宝藏" << endl; score++; } else { cout << "没找到,请继续寻找宝藏" << endl; cout << "宝藏是" << dis << endl; } sleep(1); clear(); int now = time(0); if(now - bg >= 60 || score >= 50 || i >= b) { i = b + 100; } } cout << "本次得分:" << score << endl; return 0; } else { if(l != 1) { cout << "下次再见" << endl; return 0; } else { cout << "欢迎来到游戏间2" << endl; cout << endl; sleep(1); cout << "你的目标是避开地雷" << endl; sleep(1); srand(time(0)); int bg = time(0); int score = 0; clear(); cout << "你想要几次机会?" << endl; int x; cin >> x; while(x > 100) { cout << "躲避地雷次数不能超过100次"; cin >> x; } clear(); for (int i = 1; i <= x; i++) { cout << "这是你第" << i << "次避开地雷" << endl; int a; cin >> a; int d = rand() % 100 + 1; int de = rand() % 50 + 1; int del = rand() % 25 + 1; int dele = rand() % 200 + 1; int delei = rand() % 400 + 1; if(!(cin >> a)) { a = 0; i = x + 100; } if(a != d && a != de && a != del && a != dele && a != delei) { cout << "恭喜避开地雷" << endl; score++; } else { cout << "Ouch" << endl; cout << "真不幸运,再见" << endl; cout << "你的分数是" << score << endl; return 0; } sleep(1); clear(); int now = time(0); if(now - bg >= 60 || score >= 50 || i >= x) { i = x + 100; } } cout << score << endl; } } return 0; }

今天的文章 自创游戏分享到此就结束了,感谢您的阅读。
编程小号
上一篇 2024-12-05 12:46
下一篇 2024-12-05 12:30

相关推荐

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:https://bianchenghao.cn/bian-cheng-ji-chu/78620.html