当前位置:网站首页>C# 游戏雏形 人物地图双重移动
C# 游戏雏形 人物地图双重移动
2022-06-10 14:56:00 【健忘的松鼠】
1. 设计出发点
准备做一个旅游短视频,想实现一个小人或汽车在百度地图上按指定路线移动的效果,把之前自己写的代码拿出来,修改完成。
主要修改内容:
(1)实现了人物地图双移动。即如果人物向屏幕中间移动,移动人物;人物向屏幕四周移动,如果可移动地图则移动地图,否则移动人物。
(2)将原先的人物单方向移动动画换成了四方向
(3)改正了按键后人物重影的问题
(4)修改了几个原先含义不明确的变量
未解决bug:按键控制人物移动时会闪烁
2. 主要更新代码
(1)定时器代码
private void T200_Tick(object sender, EventArgs e)
{
t200.Stop();
Bitmap person1 = new Bitmap(person16.Width/4, person16.Height/4);
winPoint point = new winPoint(0, 0);
cnt++;
if (cnt > 3) cnt = 0;
point.X = -1*cnt * person1.Width;//不同人物动作x坐标不同
point.Y = -1 * direct * person1.Height;
using (Graphics g = Graphics.FromImage(person1))
{
g.DrawImage(person16, point);//完成人物切换和动作叠加
}
using (Graphics g0 = Graphics.FromImage(pictureBox1.Image))
{
//g0.DrawImage()
g0.DrawImage(allBitmap, mapPoint);//不好,但不知道如何在上面解决
g0.DrawImage(person1, personPt.X,personPt.Y);//将人物和背景叠加图绘制到地图上
}
pictureBox1.Refresh();
t200.Start();
}(2)人物移动和地图相对移动代码
case 'D':
direct = 2;
if (personPt.X > (pictureBox1.Size.Width - person16.Width / 4)/2)//越过屏幕中间
{//如果地图可移动,则移动地图
mapPoint.X -= 10;
if (mapPoint.X + allBitmap.Size.Width < currBitmap.Size.Width)//地图到边了
{
mapPoint.X += 10;
personPt.X += 10;
if (personPt.X > pictureBox1.Size.Width - person16.Width / 4)
personPt.X = pictureBox1.Size.Width - person16.Width / 4;
}
}
else
{
personPt.X += 10;//还没有到屏幕中心,移动人
if (personPt.X > pictureBox1.Size.Width - person16.Width / 4)
personPt.X = pictureBox1.Size.Width - person16.Width / 4;
}
break;边栏推荐
- CVPR 2022 Oral | SCI:实现快速、灵活与稳健的低光照图像增强
- One-way hash function
- 2022第十五届南京国际数字化工业博览会
- Wechat applet date comparison, calculation days
- Golang uses reflection to directly copy data from one structure to another (through the same fields)
- Applet network request promise
- Even some people say that ArrayList is twice as large. Today, I will take you to tear up the ArrayList source code
- 微信小程序 日期比较,计算天数
- 【LogoDetection 数据集处理】(3)将训练集按照类别划分为多个文件夹
- 2022 the 14th Nanjing International artificial intelligence product exhibition
猜你喜欢
![[logodetection data set processing] (3) divide the training set into multiple folders by category](/img/eb/49c65f9af4c899b8cffaeec630be79.png)
[logodetection data set processing] (3) divide the training set into multiple folders by category
![[logodetection dataset processing] (4) extract the logo area of each picture](/img/cf/a8d5f840f52a56d498fa36b2343c07.png)
[logodetection dataset processing] (4) extract the logo area of each picture

svn外网打不开url地址怎么解决

How the autorunner automated test tool creates a project -alltesting | Zezhong cloud test

Meta公司新探索 | 利用Alluxio数据缓存降低Presto延迟

如何实现erp外网连接?

3. Encounter the form of handycontrol again

2022南京国际智慧工地装备展览会

Applet network request promise

2022 the 15th Nanjing International Industrial Automation Exhibition
随机推荐
Jaeger引入了对OpenTelemetry的原生支持
三子棋(c语言实现)
Day10/11 recursion / backtracking
CRM对企业以及销售员有哪些帮助?
Sanzi chess (implemented in C language)
Information theory and coding 2 final review BCH code
How can JMeter parameterization be implemented?
Consumption mode of Message Oriented Middleware
New exploration of meta company | reduce Presto latency by using alluxio data cache
4、再遇Panuon.UI.Silver之窗体标题栏
超强实操!手把手教学Kinect深度图与RGB摄像头的标定与配准
小程序实现全局数据共享
Data Lake (VI): Hudi and Flink integration
cmake实战记录(一)
LeetCode_20(括号匹配)
Get to know RPC
golang使用反射将一个结构体的数据直接复制到另一个结构体中(通过相同字段)
How the WordPress administrator user name was leaked
2022第十五届南京国际数字化工业博览会
佳博GP2120TU标签打印机 安装和使用教程(PC)