c++小游戏《抢银行模拟器》
2026-03-04 22:00:27
发布于:上海
团队"绝世 (ง •_•)ง"链接
团队"猫武士"链接
团队"天龙八部"链接
团队"十日终焉"链接
团队"我不是戏神"链接
#include <bits/stdc++.h>
#include <windows.h>
#include <conio.h>
using namespace std;
long long bankMoney;
long long myMoney;
long long totalStolen;
int k = 0;
int wantedLevel = 0;
int health = 100;
int policeChance = 0;
long long getRandomLong(long long min, long long max) {
return min + (rand() % (max - min + 1));
}
void loading() {
system("cls");
cout << "╔════════════════════════════════════╗" << endl;
cout << "║ 抢银行模拟器 - 加载 ║" << endl;
cout << "╚════════════════════════════════════╝" << endl;
cout << endl;
cout << " " << k << "%" << endl;
cout << endl;
cout << " [";
for(int i = 0; i < 50; i++) {
if(i < k/2) cout << "█";
else cout << "?";
}
cout << "]" << endl;
cout << endl;
string tips[] = {
"踩点中...",
"准备工具...",
"观察监控...",
"规划路线...",
"等待时机..."
};
cout << " " << tips[k/20] << endl;
k++;
int delay;
if(k < 20) delay = 200;
else if(k < 40) delay = 50;
else if(k < 60) delay = 300;
else if(k < 80) delay = 100 + rand() % 400;
else delay = rand() % 500;
Sleep(delay);
}
void showStatus() {
cout << "\n═══════════════════════════════════════" << endl;
cout << "?? 银行现金: $" << bankMoney << endl;
cout << "?? 你的赃款: $" << myMoney << endl;
cout << "?? 通缉等级: " << wantedLevel << "级";
if(wantedLevel > 0) {
for(int i = 0; i < wantedLevel; i++) cout << "★";
}
cout << endl;
cout << "?? 生命值: " << health;
if(health > 70) cout << " (健康)";
else if(health > 30) cout << " (受伤)";
else cout << " (危急)";
cout << "\n═══════════════════════════════════════" << endl;
}
void randomEvent() {
int event = rand() % 20;
if(event == 0) {
cout << "\n?? 炸弹爆炸!你被炸伤了!" << endl;
health -= 30;
Sleep(1000);
}
else if(event == 1) {
cout << "\n?? 捡到金库钥匙!额外获得 $10000" << endl;
myMoney += 10000;
Sleep(1000);
}
else if(event == 2) {
cout << "\n?? 警报响起!通缉等级上升!" << endl;
wantedLevel++;
policeChance += 20;
Sleep(1000);
}
else if(event == 3) {
cout << "\n?? 找到医疗包!生命+20" << endl;
health = min(100, health + 20);
Sleep(1000);
}
else if(event == 4) {
cout << "\n?? 监控死角!抢钱效率翻倍!" << endl;
Sleep(1000);
}
}
void policeEncounter() {
cout << "\n?? 警察来了!战斗开始!" << endl;
Sleep(1000);
int policeHealth = 50 + wantedLevel * 20;
while(policeHealth > 0 && health > 0) {
system("cls");
cout << "╔════════════════════════════════════╗" << endl;
cout << "║ 警察战斗! ║" << endl;
cout << "╚════════════════════════════════════╝" << endl;
cout << endl;
cout << "警察生命: ";
for(int i = 0; i < policeHealth/10; i++) cout << "█";
for(int i = policeHealth/10; i < 10; i++) cout << "?";
cout << " " << policeHealth << endl;
cout << "你的生命: ";
for(int i = 0; i < health/10; i++) cout << "█";
for(int i = health/10; i < 10; i++) cout << "?";
cout << " " << health << endl;
cout << endl;
cout << "1. 开枪 ??" << endl;
cout << "2. 躲闪 ??" << endl;
cout << "3. 逃跑 ??" << endl;
char choice = getch();
if(choice == '1') {
int damage = getRandomLong(10, 30);
policeHealth -= damage;
cout << "你造成 " << damage << " 点伤害!" << endl;
if(policeHealth > 0) {
int policeDamage = getRandomLong(5, 15) + wantedLevel * 2;
health -= policeDamage;
cout << "警察反击!受到 " << policeDamage << " 点伤害!" << endl;
}
}
else if(choice == '2') {
int evade = rand() % 3;
if(evade == 0) {
cout << "完美躲闪!没受伤!" << endl;
}
else {
int damage = getRandomLong(3, 8);
health -= damage;
cout << "躲闪失败!受到 " << damage << " 点伤害!" << endl;
}
}
else if(choice == '3') {
int escape = rand() % 100;
if(escape > 50) {
cout << "成功逃跑!" << endl;
wantedLevel = max(0, wantedLevel - 1);
Sleep(1000);
return;
}
else {
cout << "逃跑失败!" << endl;
health -= 20;
}
}
Sleep(1000);
}
if(health <= 0) {
cout << "\n? 你被警察抓住了!游戏结束!" << endl;
cout << "总共抢到: $" << totalStolen << endl;
exit(0);
}
else {
cout << "\n? 击败警察!通缉等级下降!" << endl;
wantedLevel = max(0, wantedLevel - 1);
policeChance = max(0, policeChance - 30);
Sleep(1000);
}
}
void rob() {
system("cls");
cout << "╔════════════════════════════════════╗" << endl;
cout << "║ 抢银行时间! ║" << endl;
cout << "╚════════════════════════════════════╝" << endl;
cout << endl;
showStatus();
cout << "\n抢多少? ($100 - $100000): ";
long long amount;
cin >> amount;
if(amount < 100) amount = 100;
if(amount > 100000) amount = 100000;
if(amount > bankMoney) amount = bankMoney;
cout << "\n正在抢钱..." << endl;
Sleep(1000);
int success = rand() % 100;
int successRate = 90 - wantedLevel * 10;
if(success < successRate) {
cout << "? 抢钱成功! +$" << amount << endl;
if(rand() % 5 == 0) {
int bonus = amount * (rand() % 50 + 50) / 100;
cout << "? 额外发现金库! +$" << bonus << endl;
amount += bonus;
}
bankMoney -= amount;
myMoney += amount;
totalStolen += amount;
wantedLevel += amount / 100000;
if(wantedLevel > 5) wantedLevel = 5;
policeChance += amount / 5000;
}
else {
cout << "? 抢钱失败!触发警报!" << endl;
wantedLevel++;
policeChance += 30;
int damage = getRandomLong(10, 30);
health -= damage;
cout << "受伤!生命 -" << damage << endl;
}
if(rand() % 100 < 20) {
randomEvent();
}
if(policeChance > 100 || (rand() % 100 < policeChance)) {
policeEncounter();
}
Sleep(1500);
}
void escape() {
cout << "\n?? 正在逃离现场..." << endl;
Sleep(1500);
int escapeChance = rand() % 100;
if(escapeChance > wantedLevel * 15) {
cout << "? 成功逃脱!" << endl;
cout << "本轮抢到: $" << myMoney << endl;
totalStolen += myMoney;
myMoney = 0;
wantedLevel = max(0, wantedLevel - 2);
policeChance = max(0, policeChance - 50);
cout << "总赃款: $" << totalStolen << endl;
}
else {
cout << "? 被警察堵截!" << endl;
policeEncounter();
}
Sleep(1500);
}
void shop() {
system("cls");
cout << "╔════════════════════════════════════╗" << endl;
cout << "║ 黑市商店 ║" << endl;
cout << "╚════════════════════════════════════╝" << endl;
cout << endl;
cout << "你的赃款: $" << myMoney << endl;
cout << endl;
cout << "1. 医疗包 - $5000 (恢复30生命)" << endl;
cout << "2. 防弹衣 - $10000 (减少伤害50%)" << endl;
cout << "3. 烟雾弹 - $8000 (降低通缉等级1级)" << endl;
cout << "4. 黑客工具 - $15000 (提高抢钱成功率)" << endl;
cout << "5. 离开" << endl;
cout << endl;
char choice = getch();
switch(choice) {
case '1':
if(myMoney >= 5000) {
myMoney -= 5000;
health = min(100, health + 30);
cout << "? 购买成功!生命+" << endl;
}
else cout << "? 钱不够!" << endl;
break;
case '2':
if(myMoney >= 10000) {
myMoney -= 10000;
cout << "? 购买成功!伤害减半(下一场战斗)" << endl;
}
else cout << "? 钱不够!" << endl;
break;
case '3':
if(myMoney >= 8000) {
myMoney -= 8000;
wantedLevel = max(0, wantedLevel - 1);
cout << "? 购买成功!通缉等级-" << endl;
}
else cout << "? 钱不够!" << endl;
break;
case '4':
if(myMoney >= 15000) {
myMoney -= 15000;
cout << "? 购买成功!抢钱成功率提升" << endl;
}
else cout << "? 钱不够!" << endl;
break;
}
Sleep(1000);
}
void showMenu() {
system("cls");
cout << "╔════════════════════════════════════╗" << endl;
cout << "║ 抢银行模拟器 v1.0 ║" << endl;
cout << "╚════════════════════════════════════╝" << endl;
cout << endl;
showStatus();
cout << endl;
cout << "1. 抢银行 ??" << endl;
cout << "2. 逃离现场 ??" << endl;
cout << "3. 黑市商店 ??" << endl;
cout << "4. 查看排行榜 ??" << endl;
cout << "5. 退出游戏 ??" << endl;
cout << "(按 H 键打开作弊菜单)" << endl;
cout << endl;
cout << "选择: ";
}
void cheatMenu() {
system("cls");
cout << "╔════════════════════════════════════╗" << endl;
cout << "║ 作弊菜单 ?? ║" << endl;
cout << "╚════════════════════════════════════╝" << endl;
cout << endl;
cout << "当前状态:" << endl;
cout << "?? 生命值: " << health << "/100" << endl;
cout << "?? 赃款: $" << myMoney << endl;
cout << "?? 通缉等级: " << wantedLevel << endl;
cout << "?? 银行剩余: $" << bankMoney << endl;
cout << endl;
cout << "1. 生命值 +50" << endl;
cout << "2. 生命值回满 (100)" << endl;
cout << "3. 增加 $100000" << endl;
cout << "4. 增加 $1000000" << endl;
cout << "5. 降低通缉等级 2级" << endl;
cout << "6. 通缉等级清零" << endl;
cout << "7. 银行现金减半 (欺负银行)" << endl;
cout << "8. 直接抢光银行" << endl;
cout << "9. 无敌模式 (生命锁定100)" << endl;
cout << "0. 返回游戏" << endl;
cout << endl;
cout << "选择: ";
char cheat = getch();
switch(cheat) {
case '1':
health = min(100, health + 50);
cout << "\n? 生命 +50!当前生命: " << health << endl;
break;
case '2':
health = 100;
cout << "\n? 生命回满!" << endl;
break;
case '3':
myMoney += 100000;
cout << "\n? 获得 $100000!当前赃款: $" << myMoney << endl;
break;
case '4':
myMoney += 1000000;
cout << "\n? 获得 $1000000!当前赃款: $" << myMoney << endl;
break;
case '5':
wantedLevel = max(0, wantedLevel - 2);
policeChance = max(0, policeChance - 40);
cout << "\n? 通缉等级降低!当前等级: " << wantedLevel << endl;
break;
case '6':
wantedLevel = 0;
policeChance = 0;
cout << "\n? 通缉等级清零!" << endl;
break;
case '7':
bankMoney /= 2;
cout << "\n? 银行现金减半!当前银行: $" << bankMoney << endl;
break;
case '8':
myMoney += bankMoney;
totalStolen += bankMoney;
bankMoney = 0;
cout << "\n? 银行被抢光!获得 $" << myMoney << endl;
break;
case '9':
health = 100;
cout << "\n? 无敌模式激活!生命锁定100" << endl;
break;
case '0':
return;
}
Sleep(1500);
}
int main() {
srand(time(0));
bankMoney = getRandomLong(1000000, 999999999);
myMoney = 0;
totalStolen = 0;
health = 100;
wantedLevel = 0;
policeChance = 0;
cout << "╔════════════════════════════════════╗" << endl;
cout << "║ 抢银行模拟器 v1.0 ║" << endl;
cout << "╚════════════════════════════════════╝" << endl;
cout << endl;
cout << "今天银行有 $" << bankMoney << " 现金" << endl;
cout << endl;
cout << "开始抢劫?(y/n): ";
char start;
cin >> start;
if(start == 'n' || start == 'N') {
cout << "胆小鬼!" << endl;
return 0;
}
cout << "\n准备抢劫..." << endl;
while(k < 100) {
loading();
}
cout << "\n? 准备就绪!开始抢劫!" << endl;
Sleep(1500);
while(health > 0 && bankMoney > 0) {
showMenu();
char choice = getch();
cout << choice << endl;
if(choice == 'h' || choice == 'H') {
cheatMenu();
continue;
}
switch(choice) {
case '1':
rob();
break;
case '2':
escape();
break;
case '3':
shop();
break;
case '4':
system("cls");
cout << "╔════════════════════════════════════╗" << endl;
cout << "║ 排行榜 ║" << endl;
cout << "╚════════════════════════════════════╝" << endl;
cout << endl;
cout << "你总共抢到: $" << totalStolen << endl;
cout << "最高通缉等级: " << wantedLevel << "级" << endl;
cout << endl;
cout << "按任意键继续...";
getch();
break;
case '5':
cout << "\n游戏结束!最终战绩:" << endl;
cout << "总共抢到: $" << totalStolen << endl;
cout << "存活天数: 牛逼!" << endl;
return 0;
}
if(health <= 0) {
cout << "\n? 你死了!游戏结束!" << endl;
cout << "总共抢到: $" << totalStolen << endl;
break;
}
if(bankMoney <= 0) {
cout << "\n?? 恭喜!你把银行抢光了!" << endl;
cout << "总共抢到: $" << totalStolen << endl;
break;
}
}
cout << "\n按任意键退出...";
getch();
return 0;
}
这里空空如也


















有帮助,赞一个