C#【进阶】俄罗斯方块

俄罗斯方块

文章目录

      • Test1_场景切换相关
        • BeginScene.cs
        • BegionOrEndScene.cs
        • EndScene.cs
        • Game.cs
        • GameScene.cs
        • ISceneUpdate.cs
      • Test2_绘制对象基类和枚举信息
        • DrawObject.cs
        • IDraw.cs
        • Position.cs
      • Test3_地图相关
        • Map.cs
      • Test4_坐标信息类
        • BlockInfo.cs
      • Test5_板砖工人类
        • BlockWorker.cs
      • Test6_输入模块
        • InputThread.cs
      • Program.cs

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

Test1_场景切换相关

BeginScene.cs
namespace CSharp俄罗斯方块
{internal class BeginScene : BegionOrEndScene{public BeginScene(){strTitle = "俄罗斯方块";strOne = "开始游戏";}public override void EnterJDoSomthing(){if (nowSelIndex == 0){Game.ChangeScene(E_SceneType.Game);}else{Environment.Exit(0);}}}
}
BegionOrEndScene.cs
namespace CSharp俄罗斯方块
{abstract internal class BegionOrEndScene : ISceneUpdate{protected int nowSelIndex = 0;protected string strTitle;protected string strOne;public abstract void EnterJDoSomthing();public void Update(){Console.ForegroundColor = ConsoleColor.White;Console.SetCursorPosition(Game.w / 2 - strTitle.Length, 5);Console.Write(strTitle);Console.SetCursorPosition(Game.w / 2 - strOne.Length, 8);Console.ForegroundColor = nowSelIndex == 0 ? ConsoleColor.Red : ConsoleColor.White;Console.Write(strOne);Console.SetCursorPosition(Game.w / 2 - 4, 10);Console.ForegroundColor = nowSelIndex == 1 ? ConsoleColor.Red : ConsoleColor.White;Console.Write("结束游戏");switch(Console.ReadKey(true).Key){case ConsoleKey.W:nowSelIndex--;if (nowSelIndex < 0){nowSelIndex = 1;}break;case ConsoleKey.S:nowSelIndex++;if (nowSelIndex > 1){nowSelIndex = 0;}break;case ConsoleKey.J:EnterJDoSomthing();break;}}}
}
EndScene.cs
namespace CSharp俄罗斯方块
{internal class EndScene : BegionOrEndScene{public EndScene(){strTitle = "结束游戏";strOne = "回到开始界面";}public override void EnterJDoSomthing(){if(nowSelIndex == 0){Game.ChangeScene(E_SceneType.Begin);}else{Environment.Exit(0);}}}
}
Game.cs
namespace CSharp俄罗斯方块
{enum E_SceneType{Begin,Game,End,}internal class Game{public const int w = 50;public const int h = 35;public static ISceneUpdate nowScene;public Game(){Console.CursorVisible = false;Console.SetWindowSize(w, h);Console.SetBufferSize(w, h);ChangeScene(E_SceneType.Begin);}public void start(){while (true){if (nowScene != null){nowScene.Update();}}}public static  void ChangeScene(E_SceneType type){Console.Clear();switch (type){case E_SceneType.Begin:nowScene = new BeginScene();break;case E_SceneType.Game:nowScene = new GameScene();break;case E_SceneType.End:nowScene = new EndScene();break;}}}}
GameScene.cs
namespace CSharp俄罗斯方块
{internal class GameScene : ISceneUpdate{Map map;BlockWorker blockWorker;//bool isRunning;//新开线程//Thread inputThread;public GameScene(){map = new Map(this);blockWorker = new BlockWorker();InputThread.Instance.inputEvent += CheckInputThread;//isRunning = true;//inputThread = new Thread(CheckInputThread);设置成后台线程(生命周期随主线程)//inputThread.IsBackground = true;开启线程//inputThread.Start();}public void StopThread(){//isRunning = false;//inputThread = null;//移除输入事件监听InputThread.Instance.inputEvent -= CheckInputThread;}private void CheckInputThread(){//while (isRunning)//{//检测输入,防止输入卡程序if (Console.KeyAvailable){//避免影响主线程,在输入后加锁lock (blockWorker){switch (Console.ReadKey(true).Key){case ConsoleKey.LeftArrow://判断变形if (blockWorker.CanChange(E_Change_Type.Left, map))blockWorker.Change(E_Change_Type.Left);break;case ConsoleKey.RightArrow:if (blockWorker.CanChange(E_Change_Type.Right, map))blockWorker.Change(E_Change_Type.Right);break;case ConsoleKey.A:if (blockWorker.CanMoveR_L(E_Change_Type.Left, map))blockWorker.MoveR_L(E_Change_Type.Left);break;case ConsoleKey.D:if (blockWorker.CanMoveR_L(E_Change_Type.Right, map))blockWorker.MoveR_L(E_Change_Type.Right);break;case ConsoleKey.S:if (blockWorker.CanDown(map))blockWorker.AutoMove();break;}}}//}}public void Update(){lock (blockWorker){map.Draw();blockWorker.Draw();if (blockWorker.CanDown(map))blockWorker.AutoMove();}//线程休眠减速Thread.Sleep(100);}}
}
ISceneUpdate.cs
namespace CSharp俄罗斯方块
{/// <summary>/// 场景更新接口/// </summary>internal interface ISceneUpdate{void Update();}
}

Test2_绘制对象基类和枚举信息

DrawObject.cs
namespace CSharp俄罗斯方块
{/// <summary>/// 绘制类型/// </summary>enum E_DrawType{/// <summary>/// 墙壁/// </summary>Wall,/// <summary>/// 正方形方块/// </summary>Cube,/// <summary>/// 直线/// </summary>Line,/// <summary>/// 坦克/// </summary>Tank,/// <summary>/// 左梯子/// </summary>Left_Ladder,/// <summary>/// 右梯子/// </summary>Right_Ladder,/// <summary>/// 左长梯子/// </summary>Left_Long_ladder,/// <summary>/// 右长梯子/// </summary>Right_Long_ladder,}internal class DrawObject : IDraw{public Position pos;public E_DrawType type;public DrawObject(E_DrawType type){this.type = type;}public DrawObject(E_DrawType type, int x, int y) : this(type){pos = new Position(x, y);}public void Draw(){if (pos.y < 0)return;Console.SetCursorPosition(pos.x, pos.y);switch (type){case E_DrawType.Wall:Console.ForegroundColor = ConsoleColor.Red;break;case E_DrawType.Cube:Console.ForegroundColor = ConsoleColor.Blue;break;case E_DrawType.Line:Console.ForegroundColor = ConsoleColor.Green;break;case E_DrawType.Tank:Console.ForegroundColor = ConsoleColor.Cyan;break;case E_DrawType.Left_Ladder:case E_DrawType.Right_Ladder:Console.ForegroundColor = ConsoleColor.Magenta;break;case E_DrawType.Left_Long_ladder:case E_DrawType.Right_Long_ladder:Console.ForegroundColor = ConsoleColor.Yellow;break;}Console.Write("■");}//擦除public void ClearDraw(){if (pos.y < 0)return;Console.SetCursorPosition(pos.x, pos.y);Console.Write("  ");}/// <summary>/// 附着墙壁方法/// </summary>/// <param name="type"></param>public void ChangeType(E_DrawType type){this.type = type;}}
}
IDraw.cs
namespace CSharp俄罗斯方块
{internal interface IDraw{void Draw();}
}
Position.cs
namespace CSharp俄罗斯方块
{internal struct Position{public int x;public int y;public Position(int x, int y){this.x = x;this.y = y;}public static bool operator ==(Position left, Position right){if (left.x == right.x && left.y == right.y) { return true; }return false;}public static bool operator !=(Position left, Position right){if (left.x == right.x && left.y == right.y) { return false; }return true;}public static Position operator +(Position left, Position right){return new Position(left.x + right.x, left.y + right.y);}}}

Test3_地图相关

Map.cs
namespace CSharp俄罗斯方块
{internal class Map : IDraw{//固定墙壁private List<DrawObject> walls = new List<DrawObject>();//动态墙壁public List<DrawObject> dynamicWalls = new List<DrawObject>();private GameScene nowGameScene;//为了外部能快速得到地图边界//动态墙壁的宽容量,小方块横向个数public int w;public int h;//记录每一行有多少个小方块的容器,索引就是行号private int[] recordInfo;public Map(GameScene scene){nowGameScene = scene;h = Game.h - 6;recordInfo = new int[h];w = 0;//绘制横向墙壁for (int i = 0; i < Game.w; i += 2){walls.Add(new DrawObject(E_DrawType.Wall, i, h));w++;}w -= 2;for (int i = 0; i < h; i++){walls.Add(new DrawObject(E_DrawType.Wall, 0, i));walls.Add(new DrawObject(E_DrawType.Wall, Game.w - 2, i));}}public void Draw(){for (int i = 0; i < walls.Count; i++){walls[i].Draw();}for (int i = 0; i < dynamicWalls.Count; i++){dynamicWalls[i].Draw();}}public void ClearDraw(){for (int i = 0; i < dynamicWalls.Count; i++){dynamicWalls[i].ClearDraw();}}public void AddWalls(List<DrawObject> walls){for (int i = 0; i < walls.Count; i++){//掉下来的方块变成墙壁类型walls[i].ChangeType(E_DrawType.Wall);dynamicWalls.Add(walls[i]);if (walls[i].pos.y<=0){nowGameScene.StopThread();Game.ChangeScene(E_SceneType.End);return;}//进行添加动态墙壁行的计数recordInfo[h - walls[i].pos.y - 1]++;}ClearDraw();CheckClear();Draw();}/// <summary>/// 检测是否跨层/// </summary>public void CheckClear(){//遍历时安全移除,添加待移除数组List<DrawObject> delList = new List<DrawObject>();//要选择记录行中有多少个方块的容器//数组判断这一行是否满//遍历数组,检测数组里面存的数是不是w-2for (int i = 0; i < recordInfo.Length; i++){//如果这行满了需要移除if (recordInfo[i] == w){//1、这一行的所有方块移除for (int j = 0; j < dynamicWalls.Count; j++){//通过动态方块的y计算它在哪一行if (i == h - dynamicWalls[j].pos.y - 1){//待移除添加到记录列表delList.Add(dynamicWalls[j]);}//2、要这一行之上的所有方块下移else if (h - dynamicWalls[j].pos.y - 1 > i){dynamicWalls[j].pos.y++;}}//移除待删小方块for (int j = 0;j < delList.Count; j++){dynamicWalls.Remove(delList[j]);}//3、记录小方块数量的数组从上到下迁移for (int j = i; j < recordInfo.Length-1; j++){recordInfo[j] = recordInfo[j + 1];}//置空最顶层recordInfo[recordInfo.Length - 1] = 0;//利用递归,一层一层检测CheckClear();break;}}}}
}

Test4_坐标信息类

在这里插入图片描述
在这里插入图片描述

BlockInfo.cs
namespace CSharp俄罗斯方块
{internal class BlockInfo{private List<Position[]> list;public BlockInfo(E_DrawType type){list = new List<Position[]>();switch (type){case E_DrawType.Cube:list.Add(new Position[3] { new Position(2, 0), new Position(0, 1), new Position(2, 1) });break;case E_DrawType.Line:list.Add([new Position(0, -1), new Position(0, 1), new Position(0, 2)]);list.Add([new Position(-4, 0), new Position(-2, 0), new Position(2, 0)]);list.Add([new Position(0, -2), new Position(0, -1), new Position(0, 1)]);list.Add([new Position(-2, 0), new Position(2, 0), new Position(4, 0)]);break;case E_DrawType.Tank:list.Add([new Position(-2, 0), new Position(2, 0), new Position(0, 1)]);list.Add([new Position(0, -1), new Position(-2, 0), new Position(0, 1)]);list.Add([new Position(0, -1), new Position(-2, 0), new Position(2, 0)]);list.Add([new Position(0,-1), new Position(2, 0), new Position(0, 1)]);break;case E_DrawType.Left_Ladder:list.Add([new Position(0, -1), new Position(2, 0), new Position(2, 1)]);list.Add([new Position(2, 0), new Position(-2, 1), new Position(0, 1)]);list.Add([new Position(-2, -1), new Position(-2, 0), new Position(0, 1)]);list.Add([new Position(0, -1), new Position(2, -1), new Position(-2, 0)]);break;case E_DrawType.Right_Ladder:list.Add([new Position(0, -1), new Position(-2, 0), new Position(-2, 1)]);list.Add([new Position(-2, -1), new Position(0, -1), new Position(2, 0)]);list.Add([new Position(2, -1), new Position(2, 0), new Position(0, 1)]);list.Add([new Position(-2, 0), new Position(0, 1), new Position(2, 1)]);break;case E_DrawType.Left_Long_ladder:list.Add([new Position(-2, -1), new Position(0, -1), new Position(0, 1)]);list.Add([new Position(2, 1), new Position(-2, 0), new Position(2, 0)]);list.Add([new Position(0, -1), new Position(0, 1), new Position(2, 1)]);list.Add([new Position(-2, 0), new Position(2, 0), new Position(-2, 1)]);break;case E_DrawType.Right_Long_ladder:list.Add([new Position(0, -1), new Position(2, -1), new Position(0, 1)]);list.Add([new Position(-2, 0), new Position(2, 1), new Position(2, 0)]);list.Add([new Position(0, -1), new Position(0, 1), new Position(-2, 1)]);list.Add([new Position(-2, 0), new Position(2, 0), new Position(-2, -1)]);break;default:break;}}public Position[] this[int index]{get{if (index < 0)return list[0];else if (index >= list.Count)return list[list.Count - 1];elsereturn list[index];}}public int Count { get => list.Count; }}
}

Test5_板砖工人类

BlockWorker.cs
namespace CSharp俄罗斯方块
{enum E_Change_Type{Left,Right,}internal class BlockWorker : IDraw{//方块们private List<DrawObject> blocks;//用Dictionary方便查找private Dictionary<E_DrawType, BlockInfo> blockInfoDic;//随机创建的方块具体形态信息private BlockInfo nowBlockInfo;//当前形态的索引private int nowInfoIndex;public BlockWorker(){blockInfoDic = new Dictionary<E_DrawType, BlockInfo>(){{ E_DrawType.Cube,new BlockInfo(E_DrawType.Cube)},{ E_DrawType.Line,new BlockInfo(E_DrawType.Line)},{ E_DrawType.Tank,new BlockInfo(E_DrawType.Tank)},{ E_DrawType.Left_Ladder,new BlockInfo(E_DrawType.Left_Ladder)},{ E_DrawType.Right_Ladder,new BlockInfo(E_DrawType.Right_Ladder)},{ E_DrawType.Left_Long_ladder,new BlockInfo(E_DrawType.Left_Long_ladder)},{ E_DrawType.Right_Long_ladder,new BlockInfo(E_DrawType.Right_Long_ladder)},};RandomCreatBlock();}public void Draw(){for (int i = 0; i < blocks.Count; i++){blocks[i].Draw();}}/// <summary>/// 随机创建方块/// </summary>public void RandomCreatBlock(){Random r = new Random();E_DrawType type = (E_DrawType)r.Next(1, 8);blocks = new List<DrawObject>(){new DrawObject(type),new DrawObject(type),new DrawObject(type),new DrawObject(type),};//定义0,0相对坐标blocks[0].pos = new Position(24, -5);nowBlockInfo = blockInfoDic[type];//随机当前形态nowInfoIndex = r.Next(0, nowBlockInfo.Count);//取出原点坐标信息Position[] pos = nowBlockInfo[nowInfoIndex];for (int i = 0; i < pos.Length; i++){//通过原点坐标信息绘制四个方块blocks[i + 1].pos = pos[i] + blocks[0].pos;}}//擦除方法public void ClearDraw(){for (int i = 0; i < blocks.Count; i++){blocks[i].ClearDraw();}}/// <summary>/// 方块变形/// </summary>/// <param name="type">左,右</param>public void Change(E_Change_Type type){//擦除之前的方块ClearDraw();switch (type){case E_Change_Type.Left:nowInfoIndex--;if (nowInfoIndex < 0)nowInfoIndex = nowBlockInfo.Count - 1;break;case E_Change_Type.Right:nowInfoIndex++;if (nowInfoIndex >= nowBlockInfo.Count)nowInfoIndex = 0;break;}//得到索引,取出来Position[] pos = nowBlockInfo[nowInfoIndex];for (int i = 0; i < pos.Length; i++){blocks[i + 1].pos = pos[i] + blocks[0].pos;}//擦除之后绘制Draw();}/// <summary>/// 判断能否变形/// </summary>/// <param name="type">地图方向</param>/// <param name="map">地图墙壁</param>/// <returns></returns>public bool CanChange(E_Change_Type type, Map map){//临时变量用来模拟int nowIndex = nowInfoIndex;switch (type){case E_Change_Type.Left:nowIndex--;if (nowIndex < 0)nowIndex = nowBlockInfo.Count - 1;break;case E_Change_Type.Right:nowIndex++;if (nowIndex >= nowBlockInfo.Count)nowIndex = 0;break;}//临时索引信息判断是否和墙壁重合Position[] nowPos = nowBlockInfo[nowIndex];//判断是否超出地图边界Position tempPos;for (int i = 0; i < nowPos.Length; i++){tempPos = blocks[0].pos + nowPos[i];if (tempPos.x < 2 || tempPos.x >= Game.w - 2 || tempPos.y >= map.h){return false;}}//判断是否和其他方块重合for (int i = 0; i < nowPos.Length; i++){tempPos = blocks[0].pos + nowPos[i];for (int j = 0; j < map.dynamicWalls.Count; j++){if (tempPos == map.dynamicWalls[j].pos){return false;}}}return true;}/// <summary>/// 方块左右移动/// </summary>/// <param name="type">左,右</param>public void MoveR_L(E_Change_Type type){//移动之前擦除ClearDraw();//根据传入的类型,决定左右移动,得到偏移位置Position movePos = new Position(type == E_Change_Type.Left ? -2 : 2, 0);for (int i = 0; i < blocks.Count; i++){blocks[i].pos += movePos;}//移动之后绘制Draw();}/// <summary>/// 判断能否移动/// </summary>/// <param name="type">左,右移动</param>/// <returns></returns>public bool CanMoveR_L(E_Change_Type type, Map map){Position movePos = new Position(type == E_Change_Type.Left ? -2 : 2, 0);//左右边界重合,预判断posPosition pos;for (int i = 0; i < blocks.Count; i++){pos = blocks[i].pos + movePos;if (pos.x < 2 || pos.x >= Game.w - 2)return false;}//动态方块重合for (int i = 0; i < blocks.Count; i++){pos = blocks[i].pos + movePos;for (int j = 0; j < map.dynamicWalls.Count; j++){if (pos == map.dynamicWalls[j].pos)return false;}}return true;}//方块自动下落public void AutoMove(){ClearDraw();Position downMove = new Position(0, 1);for (int i = 0; i < blocks.Count; i++){blocks[i].pos += downMove;}Draw();}public bool CanDown(Map map){Position downPos = new Position(0, 1);//预下落位置Position pos;//边界for (int i = 0; i < blocks.Count; i++){pos = blocks[i].pos + downPos;if (pos.y >= map.h){//碰到地图,此时变成地图的一部分map.AddWalls(blocks);//创建新的随机方块RandomCreatBlock();return false;}}//动态方块for (int i = 0; i < blocks.Count; i++){pos = blocks[i].pos + downPos;for (int j = 0; j < map.dynamicWalls.Count; j++){if (pos == map.dynamicWalls[j].pos){//碰到方块,此时变成地图的一部分map.AddWalls(blocks);RandomCreatBlock();return false;}}}return true;}}
}

Test6_输入模块

InputThread.cs
namespace CSharp俄罗斯方块
{internal class InputThread{//线程成员变量Thread inputThread;//输入检测事件public event Action inputEvent;private static InputThread instance = new InputThread();public static InputThread Instance{get{return instance;}}private InputThread(){ inputThread = new Thread(InputCheck);inputThread.IsBackground = true;inputThread.Start();}private void InputCheck(){while (true){inputEvent?.Invoke();}}}
}

Program.cs

using CSharp俄罗斯方块;Game game = new Game();
game.start();

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

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

相关文章

数据库中字符串相加需要换行

数据库中字符串相加需要换行&#xff0c;这个需求在现在项目中很常见&#xff0c;特别是备注内容的追加&#xff0c;因此把Oracle/SQLServer/MySQL这几种数据库的使用进行简单的总结一下 1、本文内容 Oracle中实现字符串相加需要换行SQLServer中实现字符串相加需要换行MySQL中…

VMware的网络不通?这一篇给你一定的参考.虚拟机网络配置

如果你的虚拟机莫名其妙ping不通网络了&#xff0c;可以参考一下我的配置。这不是一篇教程&#xff0c;你可以核对一下自己的bug。 虚拟网络配置器中&#xff1a; 使用管理员权限更改设置&#xff0c;会跳出来vmnet0 桥接、仅主机和NAT都必须要有 vment0&#xff1a; vmnet1:…

【乐吾乐3D可视化组态编辑器】相机与视角

系统默认的相机为环绕旋转相机&#xff0c;它可以环绕一个中心点做上下左右的旋转&#xff0c;来从不同角度观察场景。当然&#xff0c;您也可以把一些特定角度的信息保存下来&#xff0c;在系统中我们把这个信息称作视角。通过交互中的切换视角动作&#xff0c;您就可以实现把…

英语新概念2-回译法-lesson1 和 lesson17

Lesson 1 私人谈话A private conversation 翻译&#xff1a; Last Sunday I went to the theater. My seat was good and the play was interesting, but I can not enjoy it. A young man and a young woman sat behind me and they were talking loudly. I felt angry becau…

2024年电子、电气与信息科学国际会议(EEIS 2024)

2024年电子、电气与信息科学国际会议&#xff08;EEIS 2024&#xff09; 2024 International Conference on Electronics, Electrical and Information Science 【重要信息】 大会地点&#xff1a;昆明 大会官网&#xff1a;http://www.iceeis.com 投稿邮箱&#xff1a;iceeis…

振弦式土压力计:功能优势与专业应用

振弦式土压力计&#xff0c;作为一种广泛应用于土木工程领域的测量仪器&#xff0c;具有多种功能优势&#xff0c;使得它成为了解被测结构物内部土压力变化的有效工具。下面我将详细介绍振弦式土压力计的功能优势及其在土木工程中的应用。 点击输入图片描述&#xff08;最多30字…

FTP协议——Pure-Ftpd安装(Linux)

1、简介 Pure-FTPd是一个高效、免费且开源的FTP服务器软件&#xff0c;广泛应用于各种Unix/Linux系统。它以其易用性、高安全性和功能丰富而闻名&#xff0c;适用于个人和企业的文件传输需求。 2、步骤 环境&#xff1a;Ubuntu 22.04.4 下载地址&#xff1a;Index of /pub/p…

3D Web轻量化平台HOOPS Web Platform在数字工厂中的应用实例

今天我们来聊聊HOOPS工具对大型数据的处理和可视化管理。这里是一个数字工厂的仪表盘展示&#xff0c;您可以在仪表盘上看到包括工厂的能源消耗、计划产量等数据信息&#xff0c;以及各种制造机器的生产量。 HOOPS中文网http://techsoft3d.evget.com/ 我们的HOOPS工具&#xf…

链表带环问题的思考

判断链表是否带环 思路&#xff1a;快慢指针 慢指针走一步&#xff0c;快指针走两步&#xff0c;当快指针追上慢指针时&#xff0c;代表该链表带环。代码如下: /*** Definition for singly-linked list.* struct ListNode {* int val;* struct ListNode *next;* };*/ …

百世慧入选第七届数字中国建设峰会“2024企业数字化转型典型应用案例”

5月24日-25日&#xff0c;第七届数字中国建设峰会在福州举行。本届峰会是国家数据工作体系优化调整后首次举办的数字中国建设峰会&#xff0c;主题为“释放数据要素价值&#xff0c;发展新质生产力”。 为了全方位展示各领域数字化最新成果&#xff0c;共创数字中国美好未来&a…

【启程Golang之旅】掌握Go语言数组基础概念与实际应用

欢迎来到Golang的世界&#xff01;在当今快节奏的软件开发领域&#xff0c;选择一种高效、简洁的编程语言至关重要。而在这方面&#xff0c;Golang&#xff08;又称Go&#xff09;无疑是一个备受瞩目的选择。在本文中&#xff0c;带领您探索Golang的世界&#xff0c;一步步地了…

java入门 springboot上传文件

一、 pom.xml knife4j和springboot之间存在版本不兼容的问题&#xff0c;需要选对合适的版本 <project xmlns"http://maven.apache.org/POM/4.0.0" xmlns:xsi"http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation"http://maven.apach…

c++——模板初始识

1.函数模板 我们经常用到Swap函数交换两个值。由于需要交换的数据的类型不同&#xff0c;我们就需要写不同参数类型的同名函数&#xff0c;也就是函数重载&#xff1a; 然而这三个函数的逻辑是一样的&#xff0c;写这么多有些多此一举&#xff0c;通过函数模版可以写一个通用…

GoldenEye-v1(vulnhub)靶机练习实践报告

GoldenEye-v1****靶机练习实践报告 一、安装靶机 靶机是.ova文件&#xff0c;需要用VirtualBox打开&#xff0c;但我习惯于使用VMWare,因此修改靶机文件&#xff0c;使其适用于VMWare打开。 解压ova文件&#xff0c;得到.ovf文件和.vmdk文件。 用记事本打开.ovf文件并修改“…

gmssl vs2010编译

1、虚拟机win10 x64&#xff0c;离线安装vs2010和2010sp1补丁&#xff1b; 2、安装ActivePerl_v5.28.1.0000和nasm-2.16.03-installer-x64均是默认完整安装&#xff1b; nasm官网下载&#xff1a; Index of /pub/nasm/releasebuilds/2.16.03/win64https://www.nasm.us/pub/nas…

Unity 之 Android 【获取设备的序列号 (Serial Number)/Android_ID】功能的简单封装

Unity 之 Android 【获取设备的序列号 (Serial Number)/Android_ID】功能的简单封装 目录 Unity 之 Android 【获取设备的序列号 (Serial Number)/Android_ID】功能的简单封装 一、简单介绍 二、获取设备的序列号 (Serial Number) 实现原理 1、Android 2、 Unity 三、注意…

gem5模拟器入门(一)——环境配置

什么是gem5&#xff1f; gem5是一个模块化的离散事件驱动的计算机系统模拟器平台。这意味着&#xff1a; GEM5 的组件可以轻松重新排列、参数化、扩展或更换&#xff0c;以满足您的需求。它将时间的流逝模拟为一系列离散事件。它的预期用途是以各种方式模拟一个或多个计算机系…

【职业教育培训机构小程序】教培机构“招生+教学”有效解决方案

教培机构“招生教学”有效解决方案在数字化转型的浪潮中&#xff0c;职业教育培训机构面临着提升教学效率、拓宽招生渠道、增强学员互动等多重挑战。小程序作为一种新兴的移动应用平台&#xff0c;为解决这些痛点提供了有效途径。 一、职业教育培训机构小程序的核心功能 &…

Laravel 图片添加水印

和这个配合使用 Laravel ThinkPhP 海报生成_laravel 制作海报-CSDN博客 代码 //水印 $x_length $imageInfo[0]; $y_length $imageInfo[1];$color imagecolorallocatealpha($posterImage, 255, 255, 255, 70); // 增加透明度参数alpha$font_size 40; //字体大小 $angle …

HTML静态网页成品作业(HTML+CSS)——家乡沅陵介绍网页(1个页面)

&#x1f389;不定期分享源码&#xff0c;关注不丢失哦 文章目录 一、作品介绍二、作品演示三、代码目录四、网站代码HTML部分代码 五、源码获取 一、作品介绍 &#x1f3f7;️本套采用HTMLCSS&#xff0c;未使用Javacsript代码&#xff0c;共有1个页面。 二、作品演示 三、代…