這個小游戲就是原來的坑人小游戲,原來是1.0版本,2.0.1測驗版本增加了
1.“漂亮”的首頁面
2.猜數字游戲
2.0.2版本預告:增加剪刀石頭布、高精度演算法
1.0版本就是今天剛出的,我更新快吧?
呵呵......
對了,代碼忘出了
(新版本更新了,快去看看吧!!!)
/*
Name:
Copyright:
Author:
Date: 01/01/22 18:16
Description:
*/
#include<iostream>
#include<windows.h>
#include<ctime>
#include<cmath>
#include<cstring>
#include<conio.h>
#include <vector>
#include <mmsystem.h>
#include <cstdio>
#pragma comment(lib, "winmm.lib")
#include<stdio.h>
#include<stdlib.h>
#include<windows.h>
#include<conio.h>
#include<time.h>
#include<cstdio>
#define high 25
#define width 80
#define bullet_num 5
#define up 1
#define down 2
#define left 3
#define right 4
using namespace std;
#define GameW 10
#define GameH 20
int color(int a)//顏色函式
{
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hConsole, a); //更改文字顏色
return 0;
}
void printinit()//首頁字體
{
printf("\n");
printf("\n");
printf("\n");
color(5);
printf(" ◆ ◆ \n");
printf(" ◆ ◆ \n");
printf(" ◆ \n");
printf(" ◆ \n");
printf(" ◆ \n");
printf(" ◆ \n");
printf(" ◆ \n");
printf(" ◆ \n");
printf(" \n");
printf(" ◆ ◆ \n");
printf(" ◆ ◆ \n");
printf(" ◆ ◆ \n");
printf(" ◆ \n");
printf(" ◆ ◆ \n");
printf(" ◆ ◆ \n\n");
color(5);
printf(" Y X:按任意鍵解凍");
}
//病毒1(游標亂跑)
//病毒1解除方法:Alt+F4 或 Ctrl+c
void move()
{
int x = GetSystemMetrics(SM_CXSCREEN);
int y = GetSystemMetrics(SM_CYSCREEN);
srand(time(0));
while (1)
{
SetCursorPos(rand()%x,rand()%y);
}
}
//螢屏亂閃
void pc()
{
for(int sws = 0;sws<10;sws++)
{
system("color A0");
Sleep(100);
system("color B0");
Sleep(100);
system("color C1");
Sleep(100);
system("color D0");
Sleep(100);
system("color E0");
Sleep(100);
system("color F0");
Sleep(100);
}
}
void sl()
{
int x1,y1;
while(!_kbhit())
{
x1 = 1;
y1 = 1;
SetCursorPos(x1,y1);
}
}
int main()
{
printinit();
sl();
system("cls");
system("color F0");
cout<<"等螢屏閃一會......";
pc();
cout<<"\n_____________________________________\n";Sleep(2000);
cout<<" \n";Sleep(2000);
cout<<" 歡迎來到“坑的就是你”小程式 \n";Sleep(2000);
cout<<" 作為一個下載了反詐App的人... \n";Sleep(2000);
cout<<" 請慎重進入, \n";Sleep(2000);
cout<<"______________________________________\n";
cout<<"\n1.現在進入\n2.退出\n";
int h;
cin>>h;
if ((h==1) || (h==2))
{
if (h==1)
{
cout<<"現在進入";
Sleep(4000);
system("cls");
}
if (h == 2)
{
cout<<"現在退出已經來不及了";
Sleep(4000);
system("cls");
}
cout<<"現在開始!!!";
cout<<endl<<"請問:你認為接下來的程式中會有病毒嗎?";
cout<<endl<<"不要輸入!!!";
Sleep(4000);
cout<<"有沒有發現輸入不了?現在開始";
Sleep(4000);
system("start");
system("start");
system("start");
system("start");
system("start");
Sleep(5000);
cout<<endl<<"關完了嗎?";
cout<<endl<<"1.關完了\n2.沒有";
int a;
cin>>a;
cout<<"你終于關完了,繼續,"<<endl;
Sleep(5000);
cout<<"想不想再體驗一個?";
Sleep(2000);
cout<<endl<<"太好了,我正愁沒地方施展呢"<<endl;
Sleep(3000);
cout<<endl<<"休息一下";
Sleep(4000);
system("rundll32.exe user32.dll,LockWorkStation");
cout<<"再見!!!";
Sleep(4000);
system("cls");
cout<<"------------分割線\n經過了幾輪病毒的洗禮,你竟然活到了這里!";
cout<<"這......其實是一個游戲,意想不到吧?\n\n";
cout<<"_____________________________\n";
cout<<"| 1. 2. 3. 4. 5. 6. 7. 8. 9. |\n";
cout<<"-----------------------------|\n";
int op;
while(1)
{
cin>>op;
if (op==1)
{
cout<<"\n\n\n猜數字\n";
srand((int)time(NULL));
int n=rand()%1000;
int op_1=0;
int temp_1=0;
cout<<"from 0 to 1000.";
while(true)
{
cin>>op_1;
if (op_1>n)
{
cout<<"大了!";
temp_1++;
continue;
}
if (op_1<n)
{
cout<<"小了";
temp_1++;
continue;
}
if (op_1==n)
{
cout<<"你已經得到了它"<<temp_1<<"times";
break;
}
}
}
if(op==2)
{
cout<<"\n\n\n剪刀石頭布\n";
}
}
return 0;
}
}
——————————————————華麗的分割線———————————————————
不要復制舊版本的代碼了,看看新版本!!!
c++小游戲2.2版本更新了!
這次更新增加了
1.高精度計算加法、減法
2.修復了3個bug
3.走迷宮游戲
因為不想在這么簡單的程式上逗留太長時間,所以我在更新這個程式的同時,也會發一些c++、html、python的教程(畢竟作者還學過幾年python)
......額,好像扯遠了,
上代碼!!!
Dev c++運行通過,
/*
Name:
Copyright:
Author:
Date: 02/01/22 09:07
Description:
*/
#include<iostream>
#include<windows.h>
#include<ctime>
#include<cmath>
#include<cstring>
#include<conio.h>
#include <vector>
#include <mmsystem.h>
#include <cstdio>
#pragma comment(lib, "winmm.lib")
#include<stdio.h>
#include<stdlib.h>
#include<windows.h>
#include<conio.h>
#include<time.h>
#include<cstdio>
#define high 25
#define width 80
#define bullet_num 5
#define up 1
#define down 2
#define left 3
#define right 4
using namespace std;
#define GameW 10
#define GameH 20
int color(int a)//顏色函式
{
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hConsole, a); //更改文字顏色
return 0;
}
void printinit()//首頁字體
{
printf("\n");
printf("\n");
printf("\n");
color(5);
printf(" ◆ ◆ \n");
printf(" ◆ ◆ \n");
printf(" ◆ \n");
printf(" ◆ \n");
printf(" ◆ \n");
printf(" ◆ \n");
printf(" ◆ \n");
printf(" ◆ \n");
printf(" \n");
printf(" ◆ ◆ \n");
printf(" ◆ ◆ \n");
printf(" ◆ ◆ \n");
printf(" ◆ \n");
printf(" ◆ ◆ \n");
printf(" ◆ ◆ \n\n");
color(5);
printf(" Y X:按任意鍵解凍");
}
//病毒1(游標亂跑)
//病毒1解除方法:Alt+F4 或 Ctrl+c
void move()
{
int x = GetSystemMetrics(SM_CXSCREEN);
int y = GetSystemMetrics(SM_CYSCREEN);
srand(time(0));
while (1)
{
SetCursorPos(rand()%x,rand()%y);
}
}
//螢屏亂閃
void pc()
{
for(int sws = 0;sws<10;sws++)
{
system("color A0");
Sleep(100);
system("color B0");
Sleep(100);
system("color C1");
Sleep(100);
system("color D0");
Sleep(100);
system("color E0");
Sleep(100);
system("color F0");
Sleep(100);
}
}
void sl()
{
int x1,y1;
while(!_kbhit())
{
x1 = 1;
y1 = 1;
SetCursorPos(x1,y1);
}
}
int main()
{
printinit();
sl();
system("cls");
system("color F0");
cout<<"等螢屏閃一會......";
pc();
cout<<"\n_____________________________________\n";Sleep(2000);
cout<<" \n";Sleep(2000);
cout<<" 歡迎來到“坑的就是你”小程式 \n";Sleep(2000);
cout<<" 作為一個下載了反詐App的人... \n";Sleep(2000);
cout<<" 請慎重進入, \n";Sleep(2000);
cout<<"______________________________________\n";
cout<<"\n1.現在進入\n2.退出\n";
int h;
cin>>h;
if ((h==1) || (h==2))
{
if (h==1)
{
cout<<"現在進入";
Sleep(4000);
system("cls");
}
if (h == 2)
{
cout<<"現在退出已經來不及了";
Sleep(4000);
system("cls");
}
cout<<"現在開始!!!";
cout<<endl<<"請問:你認為接下來的程式中會有病毒嗎?";
cout<<endl<<"不要輸入!!!";
Sleep(4000);
cout<<"有沒有發現輸入不了?現在開始";
Sleep(4000);
system("start");
system("start");
system("start");
system("start");
system("start");
Sleep(5000);
cout<<endl<<"關完了嗎?";
cout<<endl<<"1.關完了\n2.沒有";
int a;
cin>>a;
cout<<"你終于關完了,繼續,"<<endl;
Sleep(5000);
cout<<"想不想再體驗一個?";
Sleep(2000);
cout<<endl<<"太好了,我正愁沒地方施展呢"<<endl;
Sleep(3000);
cout<<endl<<"休息一下";
Sleep(4000);
system("rundll32.exe user32.dll,LockWorkStation");
cout<<"再見!!!";
Sleep(4000);
system("cls");
cout<<"------------分割線\n經過了幾輪病毒的洗禮,你竟然活到了這里!";
cout<<"這......其實是一個游戲,意想不到吧?\n\n";
cout<<"_____________________________\n";
cout<<"| 1. 2. 3. 4. 5. 6. 7. 8. 9. |\n";
cout<<"-----------------------------|\n";
int op;
while(1)
{
cin>>op;
if (op==1)
{
cout<<"\n\n\n猜數字\n";
srand((int)time(NULL));
int n=rand()%1000;
int op_1=0;
int temp_1=0;
cout<<"from 0 to 1000.";
while(true)
{
cin>>op_1;
if (op_1>n)
{
cout<<"大了!";
temp_1++;
continue;
}
if (op_1<n)
{
cout<<"小了";
temp_1++;
continue;
}
if (op_1==n)
{
cout<<"你已經得到了它"<<temp_1<<"times";
system("cls");
cout<<"_____________________________\n";
cout<<"| 1. 2. 3. 4. 5. 6. 7. 8. 9. |\n";
cout<<"-----------------------------|\n";
break;
}
}
}
if(op==2)
{
cout<<"\n\n\n高精度加法 依次輸入兩個加數,高精度 算出結果后可繼續選擇數字\n";
char a[202]={0}, b[202]={0};
scanf("%s%s", a, b);
int alen = strlen(a), blen = strlen(b), t = 0, i;
int a1[202]={0}, b1[202]={0};
for (i = 0; i < alen; i++) a1[i] = a[alen-1-i]-'0';
for (i = 0; i < blen; i++) b1[i] = b[blen-1-i]-'0';
alen = (alen > blen) ? alen : blen;
for (i = 0; i <= alen; i++)
t = a1[i]+b1[i], a1[i] = t%10, a1[i+1] += t/10;
while (!a1[i] && i) i--;
for(; i >= 0; i--) printf("%d", a1[i]);
Sleep(5000);
system("cls");
cout<<"_____________________________\n";
cout<<"| 1. 2. 3. 4. 5. 6. 7. 8. 9. |\n";
cout<<"-----------------------------|\n";
}
if (op==3)
{
cout<<"\n\n\n高精度減法 依次輸入被減數和減數(被減數>=減數) 算出結果后可繼續選擇數字\n";
char a[202]={0}, b[202]={0};
scanf("%s%s", a, b);
int alen = strlen(a), blen = strlen(b), t = 0, i;
int a1[202]={0}, b1[202]={0};
for (i = 0; i < alen; i++) a1[i] = a[alen-1-i]-'0';
for (i = 0; i < blen; i++) b1[i] = b[blen-1-i]-'0';
alen = (alen > blen) ? alen : blen;
for (i = 0; i <= alen; i++)
t = a1[i]-b1[i], t<0?(t+=10,a1[i+1]--):t, a1[i] = t;
while (!a1[i] && i) i--;
for(; i >= 0; i--) printf("%d", a1[i]);
Sleep(5000);
system("cls");
cout<<"_____________________________\n";
cout<<"| 1. 2. 3. 4. 5. 6. 7. 8. 9. |\n";
cout<<"-----------------------------|\n";
//減法
}
if (op==4)
{
cout<<"\n迷宮\n";
cout<<"簡簡單單,x開門(|是門),wasd移動\n";
char a[1000][1000]={
"######@############$#",
"#*# # # | ### #",
"# # # ###### # ## #",
"## # # # # # #",
"## # | ##### | ##",
"# # ^############",
"#######"
};
for(int i=0;i<=10;i++)
puts(a[i]);
char ch;
int x=1,y=1;
while(1)
{
ch=_getch();
if(ch=='a'){
if(a[x][y-1]!='#' && a[x][y-1]!='|'){
a[x][y]=' ';
y--;
a[x][y]='*';
}
}
if(ch=='s'){
if(a[x+1][y]!='#' && a[x+1][y]!='|'){
a[x][y]=' ';
x++;
a[x][y]='*';
}
}
if(ch=='d'){
if(a[x][y+1]!='#' && a[x][y+1]!='|'){
a[x][y]=' ';
y++;
a[x][y]='*';
}
}
if(ch=='x'){
if(a[x][y+1]=='|'){
a[x][y]=' ';
y++;
a[x][y]='*';
}
}
if(ch=='w'){
if(a[x-1][y]!='#' && a[x-1][y]!='@' && a[x-1][y]!='|'){
a[x][y]=' ';
x--;
a[x][y]='*';
}
if(a[x-1][y] == '$')
{
cout<<"you win!!!";
Sleep(5000);
system("cls");
cout<<"_____________________________\n";
cout<<"| 1. 2. 3. 4. 5. 6. 7. 8. 9. |\n";
cout<<"-----------------------------|\n";
break;
}
}
system("cls");
for(int i=0;i<=10;i++)
puts(a[i]);
}
}
}
return 0;
}
歡迎點贊關注!!!
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/403125.html
標籤:其他
下一篇:讀書筆記《Deep Learning for Computer Vision with Python》- 第三卷 第13章 Faster R-CNNs
