猫史档案馆


happy_chicken

happy_chicken

Lv.1

This guy is very lazy, leaving nothing behind

获赞:1385收藏:318浏览:11086作品收藏:798

签名:发烧了怎么办?直接退火降温。

回复帖子评论
上一页2 页 / 共 17下一页

【求回答】nemo的屏幕大小是多大? 中回复

我是学kitchen的,不是学nemo的,我也不知道,但可以去百度搜索

2022-05-14T21:15:10 点赞:0

逼迫做noc 中回复

Me to

2022-05-14T21:16:31 点赞:0

如何举报工作室? 中回复

你要举报那个工作室,为什么要举报工作室?

2022-05-15T12:43:07 点赞:0

一个大无语事件 中回复

哪里无语了?这是你问我答论坛,怎么有诉说起无语了?

2022-05-15T12:44:37 点赞:1

求攻略.. 中回复

这也太简单了!

2022-05-15T12:46:34 点赞:0

????编程猫的软件这么有名的吗???? 中回复

好家伙

2022-05-16T07:54:36 点赞:0

咋没有人累???????? 中回复

我的账号被解封了!!!!!

2022-05-25T21:23:32 点赞:0

我源码编辑器3.0作品突然打不开了,他说打开默认文件失败,为什么?求大佬解答 中回复

恭喜你,你的作品已丢失。

2022-05-26T07:15:53 点赞:0

成功害喵一个人 中回复

呵呵

2022-05-26T07:19:20 点赞:0

成功害喵一个人 中回复

我也被封过7天,但不知道为什么被封。

2022-05-26T07:19:58 点赞:0

求助!!!!!!!!!!!!!! 中回复

把排行榜截图让我康康

2022-05-26T18:32:14 点赞:0

求助!!!!!!!!!!!!!! 中回复

你用的是云列表做的还是云变量做的,云变量的就没有这情况,我感觉你是用列表做的

2022-05-26T18:33:27 点赞:1

求助!!!!!!!!!!!!!! 中回复

你代码出问题了,你在反复查看你的程序有没有问题

2022-05-26T19:09:09 点赞:0

谁能告诉我源码精灵兑换码? 中回复

对呀,谁能啊?

2022-05-27T20:37:03 点赞:0

我要加入工作室 中回复

来我们的工作室,我让你当副市长

2022-05-28T07:03:22 点赞:0

谁帮我做图啊 备注:测试也行啊 中回复

这喵的是3D代码岛!

2022-05-28T08:05:36 点赞:0

教你如何免费下载音乐 中回复

看不懂。

2022-05-28T15:40:45 点赞:0

初学C++ 中回复

#include <iostream>
#include <windows.h>
#include <time.h>
#include <stdlib.h>
#include <conio.h>
using namespace std;

char Hide() {
	HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
	CONSOLE_CURSOR_INFO CursorInfo;
	GetConsoleCursorInfo(handle, &CursorInfo);
	CursorInfo.bVisible = false;
	SetConsoleCursorInfo(handle, &CursorInfo);
	return 0;
}



#define high 20  //定义地图的高度 
#define width 70   //定义地图的宽度 
#define snake_maxlength 100000  //蛇长最大值 
int snake_x[snake_maxlength], snake_y[snake_maxlength]; //蛇的坐标
int snake_length;  //蛇现在的长度
int map[high][width] = {0}; //初始化地图,0表示空格,1表示蛇身,2表示食物。
//3表示墙,4表示蛇头,现在地图中什么也没有
int food_x, food_y; //食物的坐标
int score;  //本局分数
char input;  //读取用户键入的字符
//数据的初始化函数
void setdata() {
	snake_x[0] = high / 2;
	snake_y[0] = width / 3; //初始化蛇头,在地图内的位置随意
	snake_x[1] = high / 2;
	snake_y[1] = width / 3 + 1; //初始化蛇身
	snake_length = 2; //蛇的原始尺寸(一格头一格身子)
	food_x = high / 3, food_y = width / 3; //初始化食物的位置,在地图内位置随意
	score = 0;
	int i, j;
	map[snake_x[0]][snake_y[0]] = 4; //蛇头
	map[snake_x[1]][snake_y[1]] = 1; //蛇身
	map[food_x][food_y] = 2; //食物
	for (i = 0; i < high; i++) //墙
		for (j = 0; j < width; j++)
			if (i == 0 || j == 0 || i == high - 1 || j == width - 1)
				map[i][j] = 3;
}

//画面打印
void gotoxy(int x, int y) { //解释1
	HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
	COORD pos;
	pos.X = x;
	pos.Y = y;
	SetConsoleCursorPosition(handle, pos);
}

void show() {
	gotoxy(0, 0);
	int i, j;
	for (i = 0; i < high; i++) {
		for (j = 0; j < width; j++) {
			HANDLE hout = GetStdHandle(STD_OUTPUT_HANDLE);
			if (map[i][j] == 0)
				cout << " ";
			else if (map[i][j] == 1) {
				SetConsoleTextAttribute(hout, FOREGROUND_INTENSITY |
				                        FOREGROUND_RED);
				cout << "*";
			} else if (map[i][j] == 2) {
				SetConsoleTextAttribute(hout, FOREGROUND_INTENSITY |
				                        FOREGROUND_RED |
				                        FOREGROUND_GREEN);
				cout << "@";
			} else if (map[i][j] == 3) {
				SetConsoleTextAttribute(hout, FOREGROUND_INTENSITY |
				                        FOREGROUND_GREEN |
				                        FOREGROUND_BLUE);
				cout << "#";
			} else if (map[i][j] == 4) {
				SetConsoleTextAttribute(hout, FOREGROUND_INTENSITY |
				                        FOREGROUND_RED);
				cout << "O";
			}
		}
		printf("\n");
	}
	printf("得分:%d", score);
}

//与输入无关的更新
void updatewithoutinput() {
	int i;
	if (snake_x[0] == food_x && snake_y[0] == food_y) {
		score++;
		srand((unsigned)time(NULL));  //srand和rand函数连用产生随机数,一般以时间作为产生随机数的种子
		food_x = rand() % (high - 3) + 1; //解释2
		food_y = rand() % (width - 3) + 1;
		map[food_x][food_y] = 2;
		snake_length++;
	}
	if (snake_x[0] == 0 || snake_x[0] == high - 1 || snake_y[0] == 0 || snake_y[0] == width - 1) { //碰墙了
		HANDLE hout = GetStdHandle(STD_OUTPUT_HANDLE);
		system("cls");
		SetConsoleTextAttribute(hout, FOREGROUND_INTENSITY |
		                        FOREGROUND_RED);
		cout << "                                              游戏结束!" << endl;
		getch();
		exit(1);  //解释3
	}
	for (i = 1; i < snake_length; i++) //碰到自己了 ,遍历蛇身找是否和蛇头重复
		if (snake_x[0] == snake_x[i] && snake_y[0] == snake_y[i]) {
			HANDLE hout = GetStdHandle(STD_OUTPUT_HANDLE);
			system("cls");
			SetConsoleTextAttribute(hout, FOREGROUND_INTENSITY |
			                        FOREGROUND_RED);
			cout << "                                               游戏结束!" << endl;
			getch();
			exit(1);
		}
}

void updatewithinput() {
	int i = 1;
	short p = 0;
	if (kbhit()) //解释4
		input = getch();
	if (input == 'w' || input == 'a' || input == 's' || input == 'd') {
		if (p == 1) {
			system("cls");
			p == 0;
		}
		map[snake_x[snake_length - 1]][snake_y[snake_length - 1]] = 0; //蛇走过一格,蛇尾处变为空格
		for (i = snake_length - 1; i > 0; i--) {
			snake_x[i] = snake_x[i - 1]; //走过一格后蛇身的坐标覆盖前面的坐标 (从后往前覆盖,蛇头也会被蛇身覆盖)
			snake_y[i] = snake_y[i - 1]; //解释5
			map[snake_x[i]][snake_y[i]] = 1;
		}

	}
	if (input == 'w')
		snake_x[0]--;
	else if (input == 's')
		snake_x[0]++;
	else if (input == 'a')
		snake_y[0]--;
	else if (input == 'd')
		snake_y[0]++;
	else {
		cout << "     已暂停";
		p = 1;
	}
	map[snake_x[0]][snake_y[0]] = 4; //蛇头的坐标覆盖前面的坐标
}

int main() {
	setdata();//数据初始化
	Hide();//隐藏光标
	while (1) {
		show();  //画面打印
		updatewithoutinput();   //与输入无关的更新
		updatewithinput();      //与输入有关的更新
		Sleep(100);
	}


	return 0;
}

 

2022-05-28T20:55:41 点赞:0

Box3_这段JavaScript代码为什么超时 中回复

while(ture){
    //语句块
}//这是重复无线次执行!!!

2022-05-29T11:27:02 点赞:0

初学C++做的小游戏:贪吃蛇 中回复

#include <iostream>
#include <windows.h>
#include <time.h>
#include <stdlib.h>
#include <conio.h>
using namespace std;

char Hide() {
	HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
	CONSOLE_CURSOR_INFO CursorInfo;
	GetConsoleCursorInfo(handle, &CursorInfo);
	CursorInfo.bVisible = false;
	SetConsoleCursorInfo(handle, &CursorInfo);
	return 0;
}



#define high 20  //定义地图的高度 
#define width 70   //定义地图的宽度 
#define snake_maxlength 100000  //蛇长最大值 
int snake_x[snake_maxlength], snake_y[snake_maxlength]; //蛇的坐标
int snake_length;  //蛇现在的长度
int map[high][width] = {0}; //初始化地图,0表示空格,1表示蛇身,2表示食物。
//3表示墙,4表示蛇头,现在地图中什么也没有
int food_x, food_y; //食物的坐标
int score;  //本局分数
char input;  //读取用户键入的字符
//数据的初始化函数
void setdata() {
	snake_x[0] = high / 2;
	snake_y[0] = width / 3; //初始化蛇头,在地图内的位置随意
	snake_x[1] = high / 2;
	snake_y[1] = width / 3 + 1; //初始化蛇身
	snake_length = 2; //蛇的原始尺寸(一格头一格身子)
	food_x = high / 3, food_y = width / 3; //初始化食物的位置,在地图内位置随意
	score = 0;
	int i, j;
	map[snake_x[0]][snake_y[0]] = 4; //蛇头
	map[snake_x[1]][snake_y[1]] = 1; //蛇身
	map[food_x][food_y] = 2; //食物
	for (i = 0; i < high; i++) //墙
		for (j = 0; j < width; j++)
			if (i == 0 || j == 0 || i == high - 1 || j == width - 1)
				map[i][j] = 3;
}

//画面打印
void gotoxy(int x, int y) { //解释1
	HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
	COORD pos;
	pos.X = x;
	pos.Y = y;
	SetConsoleCursorPosition(handle, pos);
}

void show() {
	gotoxy(0, 0);
	int i, j;
	for (i = 0; i < high; i++) {
		for (j = 0; j < width; j++) {
			HANDLE hout = GetStdHandle(STD_OUTPUT_HANDLE);
			if (map[i][j] == 0)
				cout << " ";
			else if (map[i][j] == 1) {
				SetConsoleTextAttribute(hout, FOREGROUND_INTENSITY |
				                        FOREGROUND_RED);
				cout << "*";
			} else if (map[i][j] == 2) {
				SetConsoleTextAttribute(hout, FOREGROUND_INTENSITY |
				                        FOREGROUND_RED |
				                        FOREGROUND_GREEN);
				cout << "@";
			} else if (map[i][j] == 3) {
				SetConsoleTextAttribute(hout, FOREGROUND_INTENSITY |
				                        FOREGROUND_GREEN |
				                        FOREGROUND_BLUE);
				cout << "#";
			} else if (map[i][j] == 4) {
				SetConsoleTextAttribute(hout, FOREGROUND_INTENSITY |
				                        FOREGROUND_RED);
				cout << "O";
			}
		}
		printf("\n");
	}
	printf("得分:%d", score);
}

//与输入无关的更新
void updatewithoutinput() {
	int i;
	if (snake_x[0] == food_x && snake_y[0] == food_y) {
		score++;
		srand((unsigned)time(NULL));  //srand和rand函数连用产生随机数,一般以时间作为产生随机数的种子
		food_x = rand() % (high - 3) + 1; //解释2
		food_y = rand() % (width - 3) + 1;
		map[food_x][food_y] = 2;
		snake_length++;
	}
	if (snake_x[0] == 0 || snake_x[0] == high - 1 || snake_y[0] == 0 || snake_y[0] == width - 1) { //碰墙了
		HANDLE hout = GetStdHandle(STD_OUTPUT_HANDLE);
		system("cls");
		SetConsoleTextAttribute(hout, FOREGROUND_INTENSITY |
		                        FOREGROUND_RED);
		cout << "                                              游戏结束!" << endl;
		getch();
		exit(1);  //解释3
	}
	for (i = 1; i < snake_length; i++) //碰到自己了 ,遍历蛇身找是否和蛇头重复
		if (snake_x[0] == snake_x[i] && snake_y[0] == snake_y[i]) {
			HANDLE hout = GetStdHandle(STD_OUTPUT_HANDLE);
			system("cls");
			SetConsoleTextAttribute(hout, FOREGROUND_INTENSITY |
			                        FOREGROUND_RED);
			cout << "                                               游戏结束!" << endl;
			getch();
			exit(1);
		}
}

void updatewithinput() {
	int i = 1;
	short p = 0;
	if (kbhit()) //解释4
		input = getch();
	if (input == 'w' || input == 'a' || input == 's' || input == 'd') {
		if (p == 1) {
			system("cls");
			p == 0;
		}
		map[snake_x[snake_length - 1]][snake_y[snake_length - 1]] = 0; //蛇走过一格,蛇尾处变为空格
		for (i = snake_length - 1; i > 0; i--) {
			snake_x[i] = snake_x[i - 1]; //走过一格后蛇身的坐标覆盖前面的坐标 (从后往前覆盖,蛇头也会被蛇身覆盖)
			snake_y[i] = snake_y[i - 1]; //解释5
			map[snake_x[i]][snake_y[i]] = 1;
		}

	}
	if (input == 'w')
		snake_x[0]--;
	else if (input == 's')
		snake_x[0]++;
	else if (input == 'a')
		snake_y[0]--;
	else if (input == 'd')
		snake_y[0]++;
	else {
		cout << "     已暂停";
		p = 1;
	}
	map[snake_x[0]][snake_y[0]] = 4; //蛇头的坐标覆盖前面的坐标
}

int main() {
	setdata();//数据初始化
	Hide();//隐藏光标
	while (1) {
		show();  //画面打印
		updatewithoutinput();   //与输入无关的更新
		updatewithinput();      //与输入有关的更新
		Sleep(100);
	}


	return 0;
}

2022-05-29T14:55:36 点赞:0

初学C++ 中回复

收徒了,C++至少会格式化输入输出即可。

2022-05-29T21:45:26 点赞:0

找合作伙伴 中回复

我可以吗??

2022-05-30T13:42:47 点赞:0

找合作伙伴 中回复

我会C++数组,格式化,cmath,定义函数......

2022-05-30T13:43:37 点赞:0

我想进工作室 中回复

world工作室欢迎你!!!

2022-05-30T13:45:20 点赞:0

mido音乐 中回复

我不会

2022-05-30T21:19:39 点赞:0

初学C++ 中回复

#include <iostream>
#include <windows.h>
using namespace std;
int main()
{
	HANDLE hout=GetStdHandle(STD_OUTPUT_HANDLE);
	SetConsoleTextAttribute(hout,FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);//三色相加,白色
	cout<<"white"<<endl;
	SetConsoleTextAttribute(hout,FOREGROUND_INTENSITY|
	FOREGROUND_RED);//红色
    cout<<"red"<<endl;
    SetConsoleTextAttribute(hout,FOREGROUND_INTENSITY|FOREGROUND_GREEN);//绿色
    cout<<"green"<<endl;
    SetConsoleTextAttribute(hout,FOREGROUND_INTENSITY|FOREGROUND_BLUE);//蓝色
    cout<<"blue"<<endl;
    SetConsoleTextAttribute(hout,FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN);//红色和绿色相加,黄色
    cout<<"yellow"<<endl;
    SetConsoleTextAttribute(hout,FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_BLUE);//红色和蓝色相加,粉色
    cout<<"pink"<<endl;
    SetConsoleTextAttribute(hout,FOREGROUND_INTENSITY|FOREGROUND_GREEN|FOREGROUND_BLUE);//绿色和蓝色相加,青色
    cout<<"cyan"<<endl;
    SetConsoleTextAttribute(hout,FOREGROUND_INTENSITY);//没有添加颜色,原色
    cout<<"grey"<<endl;
    SetConsoleTextAttribute(hout,FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);//三色相加,白色
    return 0;
}
//这些就是此函数所有颜色,system也行

2022-05-31T21:00:41 点赞:1

谁能帮我的幻想电脑画一个图标? 中回复

协作吗?

2022-06-01T06:52:44 点赞:1

谁能帮我的幻想电脑画一个图标? 中回复

可以呀!

2022-06-01T06:52:55 点赞:1

谁能帮我把这段代码改成左键的? 中回复

C++?

javaScript?

Python?

2022-06-01T06:59:10 点赞:0

初学C++ 中回复

#include <iostream>
#include <cstdlib>
#include <ctime>
#include <conio.h>
#include <iomanip>
#include <windows.h>

using namespace std;
char Hide() {
	HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
	CONSOLE_CURSOR_INFO CursorInfo;
	GetConsoleCursorInfo(handle, &CursorInfo);
	CursorInfo.bVisible = false;
	SetConsoleCursorInfo(handle, &CursorInfo);
	return 0;
}

void gotoxy(int x, int y) { //定位光标,x为行坐标,y为列坐标
	COORD pos = {x, y}; //(坐标  位置);
	HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);  //得到标准处理(标准输出处理);
	SetConsoleCursorPosition(hOut, pos);//设置控制台光标位置;
}

void hidden() { //隐藏光标
	HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
	CONSOLE_CURSOR_INFO cci;
	GetConsoleCursorInfo(hOut, &cci);
	cci.bVisible = 0; //赋1为显示,赋0为隐藏
	SetConsoleCursorInfo(hOut, &cci);
}

class Timer {
	private:
		long start_time;
		long pause_time;
		//两个bool值标记四种状态
		bool is_pause; //记录计时器的状态 (是否处于暂停状态)
		bool is_stop;//是否处于停止状态
	public:
		Timer();
		bool isPause(); //返回计时器状态
		bool isStop();
		//计时器的三种动作(功能)
		void Start();
		void Pause();
		void Stop();
		inline long getStartTime() {
			return start_time;
		}
		void show();
};

Timer::Timer() {
	is_pause = false; //初始化计时器状态
	is_stop = true;
}


bool Timer::isPause() {
	if (is_pause)
		return true;
	else
		return false;
}

bool Timer::isStop() {
	if (is_stop)
		return true;
	return false;
}

void Timer::Start() { //开始
	if (is_stop) {
		start_time = time(0);
		is_stop = false;
	} else if (is_pause) {
		is_pause = false;
		start_time += time(0) - pause_time; //更新开始时间:用此时的时间 - 暂停时所用的时间 + 上一次开始的时间 = 此时的开始时间
	}
}

void Timer::Pause() { //暂停
	if (is_stop || is_pause) //如果处于停止/暂停状态,此动作不做任何处理,直接返回
		return;
	else {  //否则调制为暂停状态
		is_pause = true;
		pause_time = time(0); //获取暂停时间
	}
}

void Timer::Stop() { //停止
	if (is_stop) //如果正处于停止状态(不是暂停状态),不做任何处理
		return ;
	else if (is_pause) { //改变计时器状态
		is_pause = false;
		is_stop = true;
	} else if (!is_stop) {
		is_stop = true;
	}
}

void Timer::show() {
	long t = time(0) - start_time;
	gotoxy(35, 12);
	cout << setw(2) << setfill('0') << t / 60 / 60 << ":"
	     << setw(2) << setfill('0') << t / 60 << ":"
	     << setw(2) << setfill('0') << t % 60 << endl;
}

int main() {
	Hide();
	Timer t;
	char ch;
	hidden();//隐藏光标
	system("color 02");
	gotoxy(35, 12);
	cout << "00:00:00";
	gotoxy(20, 18);
	cout << "按a开始,按空格暂停,按s停止";
	while (1) {
		if (kbhit()) {
			ch = getch();
			switch (ch) {
				case 'a':
					t.Start();
					break;
				case 's':
					t.Stop();
					break;
				case ' ':
					t.Pause();
					break;
				default :
					break;
			}
		}
		if (!t.isStop() && !t.isPause()) {
			t.show();
		}
	}

}
//简单计时器

2022-06-01T09:37:28 点赞:2