Mathematics(未完成)

news2024/9/20 0:37:18

 点击字母M有惊喜

/*
	Mathematics
*/
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <easyx.h>
#include <math.h>
#define L 4
#define H 80
#define T 0.3141592653589793
#define T0 10
#define PI 3.1415926535897932
HWND hwnd;
int len;
short time;
double counter;
int iop[32] = { 0, 512, 1024 };
TCHAR text[32][64] = { L"按D控制火柴人向右", L"按A控制火柴人向左", L"按W控制火柴人跳跃"};
struct Node {
	double r;
};
struct Point3 {
	double x[3];
};
struct Player {
	short x;
	short y;
	short stl;		// 0 静止 1 向左 2 向右 3 跳跃
					// 0 左; 1 右;
	Node arm[2][2];
	Node leg[2][2];
}player;
static inline bool KEYDOWN(int vk_code) {
	return ((GetAsyncKeyState(vk_code) & 0x8000) ? true : false);
}
static inline int ab(int a, int b) {
	return a * a + b * b;
}
static inline double abc(double a, double b, double c) {
	return sqrt(a * a + b * b + c * c);
}
static void init() {
	hwnd = initgraph(512, 512);
	SetWindowText(hwnd, L"Mathematics");
	releasecapture();
	BeginBatchDraw();
	player.x = 255;
	player.y = 360;
	player.stl = 0;
	counter = 0.0;
	return;
}
static void display(short num) {
	short x1, x2, x3, y1, y2, y3;
	clearrectangle(0, 0, 512, 512);
	outtextxy(4, 4, L"关卡:");
	if (num > 10)
	outtextxy(40, 4, TCHAR(48 + num / 10));
	outtextxy(48, 4, TCHAR(48 + num % 10));
	setlinestyle(PS_SOLID, 2);
	if (player.stl == 0)	circle(player.x, player.y - 8 * L, 2 * L);
	if (player.stl == 3)	circle(player.x, player.y - 8 * L, 2 * L);
	if (player.stl == 1)	circle(player.x - int(sin(PI / 12) * 8 * L + 0.5), player.y - int(cos(PI / 12) * 8 * L + 0.5), 2 * L);
	if (player.stl == 2)	circle(player.x + int(sin(PI / 12) * 8 * L + 0.5), player.y - int(cos(PI / 12) * 8 * L + 0.5), 2 * L);
	if (player.stl == 0)	x1 = player.x;
	if (player.stl == 3)	x1 = player.x;
	if (player.stl == 1)	x1 = player.x - int(sin(PI / 12) * 6 * L + 0.5);
	if (player.stl == 2)	x1 = player.x + int(sin(PI / 12) * 6 * L + 0.5);
	x2 = x1 + short(sin(player.arm[0][0].r) * 4 * L + 0.5);
	x3 = x2 + short(sin(player.arm[0][1].r) * 4 * L + 0.5);
	y1 = player.y - 6 * L;
	y2 = y1 + short(cos(player.arm[0][0].r) * 4 * L + 0.5);
	y3 = y2 + short(cos(player.arm[0][1].r) * 4 * L + 0.5);
	line(x1, y1, player.x, player.y);
	line(x1, y1, x2, y2);
	line(x2, y2, x3, y3);
	if (player.stl == 0)	x1 = player.x;
	if (player.stl == 3)	x1 = player.x;
	if (player.stl == 1)	x1 = player.x - int(sin(PI / 12) * 6 * L + 0.5);
	if (player.stl == 2)	x1 = player.x + int(sin(PI / 12) * 6 * L + 0.5);
	x2 = x1 + short(sin(player.arm[1][0].r) * 4 * L + 0.5);
	x3 = x2 + short(sin(player.arm[1][1].r) * 4 * L + 0.5);
	y1 = player.y - 6 * L;
	y2 = y1 + short(cos(player.arm[1][0].r) * 4 * L + 0.5);
	y3 = y2 + short(cos(player.arm[1][1].r) * 4 * L + 0.5);
	line(x1, y1, x2, y2);
	line(x2, y2, x3, y3);
	x1 = player.x;
	x2 = x1 + short(sin(player.leg[0][0].r) * 5 * L + 0.5);
	x3 = x2 + short(sin(player.leg[0][1].r) * 5 * L + 0.5);
	y1 = player.y;
	y2 = y1 + short(cos(player.leg[0][0].r) * 5 * L + 0.5);
	y3 = y2 + short(cos(player.leg[0][1].r) * 5 * L + 0.5);
	line(x1, y1, x2, y2);
	line(x2, y2, x3, y3);
	x1 = player.x;
	x2 = x1 + short(sin(player.leg[1][0].r) * 5 * L + 0.5);
	x3 = x2 + short(sin(player.leg[1][1].r) * 5 * L + 0.5);
	y1 = player.y ;
	y2 = y1 + short(cos(player.leg[1][0].r) * 5 * L + 0.5);
	y3 = y2 + short(cos(player.leg[1][1].r) * 5 * L + 0.5);
	line(x1, y1, x2, y2);
	line(x2, y2, x3, y3);
	setlinestyle(PS_SOLID, 1);
	line(0, 400, 512, 400);
	FlushBatchDraw();
	return;
}
static void rotate(short right) {
	player.arm[0][0].r = right * (-PI / 12.0 - sin(counter) * PI / 3.0);
	player.arm[1][0].r = right * (-PI / 12.0 + sin(counter) * PI / 3.0);
	player.arm[0][1].r = right * (PI / 3.0 - sin(counter) * PI / 3.0);
	player.arm[1][1].r = right * (PI / 3.0 + sin(counter) * PI / 3.0);
	player.leg[0][0].r = right * (PI / 12.0 - sin(counter) * PI / 6.0);
	player.leg[1][0].r = right * (PI / 12.0 + sin(counter) * PI / 6.0);
	player.leg[0][1].r = right * (-PI / 6.0 - sin(counter) * PI / 3.0);
	player.leg[1][1].r = right * (-PI / 6.0 + sin(counter) * PI / 3.0);
	return;
}
static void jump() {
	player.y = 360 + H * time * time / T0 / T0 - H;
	if (time == T0) player.stl = 0;
	else time++;
}
static void reset() {
	player.arm[0][0].r /= 1.5;
	player.arm[1][0].r /= 1.5;
	player.arm[0][1].r /= 1.5;
	player.arm[1][1].r /= 1.5;
	player.leg[0][0].r /= 1.5;
	player.leg[1][0].r /= 1.5;
	player.leg[0][1].r /= 1.5;
	player.leg[1][1].r /= 1.5;
	return;
}
static void input() {
	if (KEYDOWN('W')) {
		if (player.stl != 3) {
			time = -T0;
			player.stl = 3;
		}
	}
	else if (player.y == 360){ player.stl = 0; reset(); }
	if (KEYDOWN('A') && player.stl != 3) { counter -= T; player.stl = 1; rotate(-1); }
	if (KEYDOWN('D') && player.stl != 3) { counter += T; player.stl = 2; rotate(1); }
	if (player.stl == 3) jump();
	return;
}
static void game(short num) {
	while (true) {
		input();
		display(num);
		Sleep(40);
	}
	return;
}
static void regular_twenty_aspect() {
	double k = (sqrt(5) - 1.0) / 2.0;
	Point3 P[] = {
		{-k, -1, 0}, {k ,-1, 0}, {-k, 1, 0}, {k, 1, 0},
		{-1, 0, -k}, {-1, 0, k}, {1, 0, -k}, {1, 0, k},
		{0, -k, -1}, {0, -k, 1}, {0, k, -1}, {0, k, 1}
	};
	double a = 0, b = 0, c = 0;
	while (true) {
		Point3 R[12]{};
		double A[3][3] = {
			{cos(a) * cos(b), -sin(a) * cos(c) - cos(a) * sin(b) * sin(c), sin(a) * sin(c) - cos(a) * sin(b) * cos(c)},
			{sin(a) * cos(b), cos (a) * cos(c) - sin(a) * sin(b) * sin(c), -cos(a)* sin(c) - sin(a) * sin(b) * cos(c)},
			{sin(b), cos(b) * sin(c), cos(b) * cos(c)}
		};
		for (short l = 0; l < 12; l++) {
			for (short i = 0; i < 3; i++)
				for (short u = 0; u < 3; u++)
					R[l].x[i] += A[i][u] * P[l].x[u];
		}
		clearrectangle(0, 0, 512, 512);
		for (short i = 0; i < 12; i++) {
			for (short j = 0; j < 12; j++) {
				if (i != j && R[i].x[2] >= -0.45 && R[j].x[2] >= -0.45 && abc(R[i].x[0] - R[j].x[0], R[i].x[1] - R[j].x[1], R[i].x[2] - R[j].x[2]) <= 2 * k + 0.01) {
					line(int(R[i].x[0] * 64 + 0.5) + 255, int(R[i].x[1] * 64 + 0.5) + 255, int(R[j].x[0] * 64 + 0.5) + 255, int(R[j].x[1] * 64 + 0.5) + 255);
				}
			}
		}
		FlushBatchDraw();
		a += PI / 180;
		b += PI / 90;
		c += PI / 60;
		if (KEYDOWN(VK_ESCAPE))	break;
		if (KEYDOWN(VK_SPACE))	Sleep(4000);
		Sleep(40);
	}
	return;
}
static void xOy() {
	ExMessage msg;
	POINT ptx[] = { {480, 253}, {480, 257}, {484, 255} };
	POINT pty[] = { {253, 32}, {257, 32}, {255, 28} };
	BEGIN:
	clearrectangle(0, 0, 512, 512);
	setlinecolor(RGB(255, 255, 255));
	setfillcolor(RGB(255, 255, 255));
	setlinestyle(PS_SOLID, 1);
	line(32, 255, 480, 255);
	line(255, 32, 255, 480);
	outtextxy(251, 8, L'Y');
	outtextxy(488, 247, L'X');
	outtextxy(239, 260, L'O');
	outtextxy(4, 4, L"Mathematics");
	fillpolygon(ptx, 3);
	fillpolygon(pty, 3);
	for (short i = -4; i <= 4; i++) {
		putpixel(255 + i * 50, 254, RGB(255, 255, 255));
		if (i < 0) {
			outtextxy(247 + i * 50, 238, L'-');
			outtextxy(255 + i * 50, 238, TCHAR(48 - i));
		}
		if (i > 0) {
			outtextxy(251 + i * 50, 238, TCHAR(48 + i));
		}
	}
	for (short i = -4; i <= 4; i++) {
		putpixel(256, 255 + i * 50, RGB(255, 255, 255));
		if (i < 0) {
			outtextxy(260, 247 + i * 50, TCHAR(48 - i));
			outtextxy(268, 247 + i * 50, L'i');
		}
		if (i > 0) {
			outtextxy(260, 247 + i * 50, L'-');
			outtextxy(268, 247 + i * 50, TCHAR(48 + i));
			outtextxy(276, 247 + i * 50, L'i');
		}
	}
	FlushBatchDraw();
	while (true) {
		if (KEYDOWN(VK_ESCAPE)) {
			goto END;
		}
		if (peekmessage(&msg, EX_MOUSE)) {
			if (!msg.lbutton) continue;
			short num = -1;
			for (short i = -4; i <= 4; i++) {
				if (i == 0) continue;
				int r2 = ab(int(msg.x - 255 - i * 50), int(msg.y - 255));
				if (r2 <= 16) {
					if (i > 0) num = i;
					else num = 4 - i;
				}

			}
			for (short i = -4; i <= 4; i++) {
				if (i == 0) continue;
				int r2 = ab(int(msg.y - 255 + i * 50), int(msg.x - 255));
				if (r2 <= 16) {
					if (i > 0) num = 8 + i;
					else num = 12 - i;
				}
			}
			if (ab(msg.x, msg.y) <= 1024) {
				regular_twenty_aspect();
				Sleep(1000);
				break;
			}
			if (num != -1) {
				setfillcolor(RGB(0, 0, 0));
				len = 0;
				game(num);
				Sleep(1000);
				break;
			}
		}
	}
	goto BEGIN;
	END:
	return;
}
static void close() {
	EndBatchDraw();
	closegraph();
}
int main() {
	init();
	xOy();
	close();
	return 0;
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2141403.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

fiddler抓包01:工具介绍

课程大纲 fiddler是一款常见的抓包工具&#xff0c;可以对web端和移动端的接口请求进行抓包&#xff08;截获&#xff09;、分析、编辑、模拟等&#xff0c;还可以导出jmeter、Loadrunner测试脚本。 1、原理 fiddler作为代理服务器&#xff0c;拦截请求和服务器响应。 2、使用…

图像放大的软件PhotoZoom 9新功能介绍及安装激活使用指南

最近&#xff0c;全世界大量巨头企业都在人工智能领域投入大笔的科研经费&#xff0c;而和有关人工智能的话题也一直吸引着人们的眼球。像“无人驾驶”、“智能交互”、“物联网”等新兴行业&#xff0c;也对人工智能有着迫切的需求。 AI人工智能影响了社会的方方面面。 之前有…

sqlgun靶场攻略

步骤一&#xff1a;打开页面 步骤二&#xff1a;测试回显点 -1union select 1,2,3# 步骤三&#xff1a;查看数据库名 -1union select 1,2,database()# 步骤四&#xff1a;查看表名 -1union select 1,2,group_concat(table_name) from information_schema.tables where table…

【IP协议】IP协议报头结构

文章目录 IP 协议报头结构4位版本4位首部长度8位服务类型16位总长度16位标识、3位标志、13位片偏移8位生存时间8位协议16位首部校验和32源 IP 地址、32位目的 IP 地址 IP 协议报头结构 4位版本 实际上只有两个取值 4 > IPv4&#xff08;主流&#xff09;6 > IPv6 IPv2&…

electron-updater实现electron全量版本更新

在 Electron 应用中使用 electron-updater 来实现自动更新功能时&#xff0c;通常你会在一个专门的模块或文件中管理更新逻辑。如果你想要使用 ES6 的 import 语法来引入 electron-updater&#xff0c;你需要确保你的项目已经配置好了支持 ES6 模块的构建工具&#xff08;如 We…

MiniBlogum项目简介

MiniBlogum项目简介 文章目录 MiniBlogum项目简介一、引言二、技术栈与开发环境三、主要功能&#xff08;一&#xff09;用户注册与登录&#xff08;二&#xff09;查看当前登录用户/作者头像、昵称、Gitee仓库地址&#xff08;三&#xff09;查看博客列表&#xff08;四&#…

HAL库STM32常用外设教程(四)—— 定时器 基本定时

HAL库STM32常用外设教程&#xff08;四&#xff09;—— 定时器 基本定时 文章目录 HAL库STM32常用外设教程&#xff08;四&#xff09;—— 定时器 基本定时前言一、定时器特性概述二、基础定时器的结构和功能1、基本特征2、基础定时器相关寄存器3、基础定时器工作流程4、基础…

基于python+django+vue的家居全屋定制系统

作者&#xff1a;计算机学姐 开发技术&#xff1a;SpringBoot、SSM、Vue、MySQL、JSP、ElementUI、Python、小程序等&#xff0c;“文末源码”。 专栏推荐&#xff1a;前后端分离项目源码、SpringBoot项目源码、SSM项目源码 系统展示 【2025最新】基于协同过滤pythondjangovue…

文件误删除后的数据救援实战指南

在数字化时代&#xff0c;文件误删除成为了许多用户心头挥之不去的阴影。无论是手误点击了“删除”键&#xff0c;还是系统崩溃导致的数据丢失&#xff0c;文件一旦从我们的视线中消失&#xff0c;往往伴随着重要信息的流失和工作的中断。本文将深入探讨文件误删除的现象&#…

kubernetes技术详解,带你深入了解k8s

目录 一、Kubernetes简介 1.1 容器编排应用 1.2 Kubernetes简介 1.3 k8s的设计架构 1.3.1 k8s各个组件的用途 1.3.2 k8s各组件之间的调用关系 1.3.3 k8s的常用名词概念 1.3.4 k8s的分层结构 二、k8s集群环境搭建 2.1 k8s中容器的管理方式 2.2 k8s环境部署 2.2.1 禁用…

如何在GitHub上克隆仓库:HTTPS、SSH和GitHub CLI的区别

GitHub是开发者的天堂&#xff0c;提供了丰富的工具和功能来管理代码和项目。在克隆GitHub仓库时&#xff0c;你可能会遇到三种常见的方法&#xff1a;HTTPS、SSH和GitHub CLI。每种方法都有其独特的优势和适用场景。本文将深入探讨这三种克隆方式的区别&#xff0c;帮助你选择…

AI助力遥感影像智能分析计算,基于高精度YOLOv5全系列参数【n/s/m/l/x】模型开发构建卫星遥感拍摄场景下地面建筑物智能化分割检测识别系统

随着科技的飞速发展&#xff0c;卫星遥感技术已成为获取地球表面信息的重要手段之一。卫星遥感图像以其覆盖范围广、数据量大、信息丰富等特点&#xff0c;在环境监测、城市规划、灾害评估等多个领域发挥着不可替代的作用。然而&#xff0c;面对海量的卫星图像数据&#xff0c;…

react hooks--useLayoutEffect

概述 ◼ useLayoutEffect看起来和useEffect非常的相似&#xff0c;事实上他们也只有一点区别而已&#xff1a;  useEffect会在渲染的内容更新到DOM上后执行&#xff0c;不会阻塞DOM的更新&#xff1b;  useLayoutEffect会在渲染的内容更新到DOM上之前执行&#xff0c;会…

JUC学习笔记(二)

提示&#xff1a;文章写完后&#xff0c;目录可以自动生成&#xff0c;如何生成可参考右边的帮助文档 文章目录 四、共享模型之内存4.1 Java 内存模型4.2 可见性退不出的循环解决方法可见性 vs 原子性模式之 Balking1.定义2.实现 4.3 有序性原理之指令级并行1. 名词2.鱼罐头的故…

STM32巡回研讨会总结(2024)

前言 本次ST公司可以说是推出了7大方面&#xff0c;几乎可以说是覆盖到了目前生活中的方方面面&#xff0c;下面总结下我的感受。无线类 支持多种调制模式&#xff08;LoRa、(G)FSK、(G)MSK 和 BPSK&#xff09;满足工业和消费物联网 (IoT) 中各种低功耗广域网 (LPWAN) 无线应…

【Android 13源码分析】WindowContainer窗口层级-4-Layer树

在安卓源码的设计中&#xff0c;将将屏幕分为了37层&#xff0c;不同的窗口将在不同的层级中显示。 对这一块的概念以及相关源码做了详细分析&#xff0c;整理出以下几篇。 【Android 13源码分析】WindowContainer窗口层级-1-初识窗口层级树 【Android 13源码分析】WindowCon…

计算机的错误计算(九十五)

摘要 从计算机的错误计算&#xff08;八十六&#xff09;至&#xff08;九十四&#xff09;&#xff0c;其主题均涉及对数运算。本节用错数解释&#xff08;九十四&#xff09;中的错误计算的原因。其余类似。 首先&#xff0c;由计算机的错误计算&#xff08;二十七&#xf…

QUIC的loss detection学习

PTO backoff backoff 补偿 /ˈbkɒf/PTO backoff 是QUIC&#xff08;Quick UDP Internet Connections&#xff09;协议中的一种机制&#xff0c;用于处理探测超时&#xff08;Probe Timeout, PTO&#xff09;重传策略 它逐步增加探测超时的等待时间&#xff0c;以避免网络拥塞…

外网(公网)访问VMware workstation 虚拟机内web网站的配置方法---端口转发总是不成功的原因

问题背景&#xff1a;客户提供的服务器操作系统配置web程序时&#xff0c;总是显示莫名其妙的问题&#xff0c;发现是高版本操作系统的.net库已经对低版本.net库进行了大范围修订&#xff0c;导致在安全检测上、软件代码规范上更加苛刻&#xff0c;最终导致部署不成功。于是想到…

使用Qt 搭建简单雷达

目录 1.简易雷达图思维导图 2.结果展示图 3.制作流程 3.1表盘的绘制 3.1.1 绘制底色 ​编辑 3.1.2 绘制大圆 3.3.3绘制小圆 3.3.4 绘制小圆的内容 3.3.5 绘制表盘刻度和数字标注 3.3.6 绘制指针 3.3.7 绘制扇形 3.2 设置定时器让表盘动起来 3.3.1 设置动态指针…