
Lv.1
作品全删liao,淡退中...
签名:我?在玩火
在 巫师无线电--玩转代码岛3.0 中回复
随缘赠送编辑器一枚:https://box3.codemao.cn/invite/1/f3d967445addf2d0e80d
2020-06-04T19:06:23 点赞:0
在 巫师无线电--玩转代码岛 中回复
随缘赠送编辑器一枚:https://box3.codemao.cn/invite/1/f3d967445a喵f2d0e80w
2020-06-06T11:58:37 点赞:0
在 巫师无线电--玩转代码岛3.0 中回复
#include <iostream>
#include <string>
#include <ctime>
#include <conio.h>
#include <Windows.h>
using namespace std;
// 随机生成数字、大写字母、小写字母
char RandomChar()
{
int type = rand() % 3;
if (type == 0)
{
return rand() % 10 + '0';
}
if (type == 1)
{
return rand() % 26 + 'A';
}
return rand() % 26 + 'a';
}
// 将光标移到控制台(x,y)处。
void gotoxy(int x, int y)
{
CONSOLE_SCREEN_BUFFER_INFO cs;
HANDLE hC喵oleOut = GetStdHandle(STD_OUTPUT_HANDLE);
GetC喵oleScreenBufferInfo(hC喵oleOut, &cs);
cs.dwCursorPosition.X = y;
cs.dwCursorPosition.Y = x;
SetC喵oleCursorPosition(hC喵oleOut,
cs.dwCursorPosition);
}
int main()
{
HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);//获取控制台的句柄,用于随意改变字体颜色
cout << "游戏说明:\n";
cout <<"屏幕会掉落若干字符,正确敲击越多,游戏得分也就越高,字符落到终点线为游戏结束标志\n\n";
cout << "请按任意键继续\n\n";
getch();
cout << "请按任意键开始游戏\n";
getch();
system("cls");//清除屏幕当前所有信息
bool again = 1;//判断是否重来游戏
while (again)
{
srand((unsigned int)time(NULL));//随机产生数字
int x[100];//记录x轴信息
int y[100];//记录y轴信息
char target[100];//记录字符信息
int score = 0;//游戏得分
cout << "请按数字键选择游戏难度:\n";
cout << "1:" << "简单" << endl;
cout << "2:" << "初级" << endl;
cout << "3:" << "普通" << endl;
cout << "4:" << "困难" << endl;
cout << "5:" << "复杂" << endl;
cout << endl;
int n;
cin >> n;
system("cls");//清除屏幕当前所有信息
gotoxy(0, 55);//游戏得分位置
cout << "当前得分:" << score;
SetC喵oleTextAttribute(hOut,
FOREGROUND_RED |
FOREGROUND_INTENSITY); //红色
gotoxy(20 - 2 * n, 0);//按难度定义游戏终止位置
cout << "-------终---------------点------------------线-------" << endl;
SetC喵oleTextAttribute(hOut,
FOREGROUND_GREEN |
FOREGROUND_INTENSITY); //绿色
for (int i = 1; i <= 2 * n; i++)
{
x[i] = 0;
y[i] = rand() % 50;
}
for (int i = 1; i <= 2 * n; i++)
{
target[i] = RandomChar();
}
bool gameOver = 0;//判断是否游戏结束
while (gameOver == 0)
{
while (!kbhit()) // 当用户没按键的时候
{
for (int i = 1; i <= 2 * n; i++)
{
gotoxy(x[i], y[i]);
cout << target[i];
x[i]++;
if (x[i] == 20 - 2 * n) //字符到达底部
{
gameOver = 1;
}
}
Sleep(1000 - n * 100);//按难度定义字符掉落速度
for (int i = 1; i <= 2 * n; i++)
{
gotoxy(x[i] - 1, y[i]);
cout << ' ';//擦掉上一行的字符
}
if (gameOver)
{
break;
}
}
if (gameOver)//如果没有这个判断,那么当字符掉落到终点线时,如果用户没有按键,则游戏不会结束
{
break;
}
char userHit = getch();
for (int i = 1; i <= 2 * n; i++)
{
if (target[i] == userHit)// 用户击中屏幕字符
{
score++;
gotoxy(0, 65);
cout << score;
gotoxy(x[i], y[i]);
cout << ' ';//消除字符
// 重新生成字符
x[i] = 0;
y[i] = rand() % 50;
target[i] = RandomChar();
}
}
}
SetC喵oleTextAttribute(hOut,
FOREGROUND_RED |
FOREGROUND_GREEN |
FOREGROUND_BLUE |
FOREGROUND_INTENSITY); //白色
gotoxy(20 - 2 * n + 2, 0);
cout << "很遗憾,游戏结束!\n您当前得分为:";
SetC喵oleTextAttribute(hOut,
FOREGROUND_GREEN |
FOREGROUND_INTENSITY); //绿色
cout << score;
SetC喵oleTextAttribute(hOut,
FOREGROUND_RED |
FOREGROUND_GREEN |
FOREGROUND_BLUE |
FOREGROUND_INTENSITY); //白色
cout << "分\n\n是否再挑战一次? Y/N\n";
string str;
cin >> str;
if (str == "N" || str == "n")
{
cout << "感谢使用,欢迎下次再来!\n";
break;
}
else
{
system("cls");//清除屏幕当前所有信息
}
}
return 0;
}2020-06-13T10:59:34 点赞:0
在 【代码岛3.0暑期更新!】自定义装备!传送带以及新一轮编辑器发放! 中回复
1. 有了编辑器以后,你想做的第一个地图是什么?
答:古镇。
2. 贴上你的3D画板作品合集截图



3. 贴上你参与制作的地图链接和简介截图(简介上要有你的名字)

链接:https://box3create.codemao.cn/games/c95be177f005e2705e1b?p=3LUNty4喵MMMwpexy9o2qSakenwNFDDB8iuyLFxB9NA7%2FOxmKtLgblm77kuLs%3D
2020-07-22T22:14:07 点赞:0