当前位置:网站首页>C # game prototype character map dual movement
C # game prototype character map dual movement
2022-06-10 15:46:00 【Forgetful squirrel】
1. Design starting point
Prepare to make a short travel video , Want to achieve the effect of a villain or car moving on Baidu map according to the specified route , Take out the code you wrote before , Modified to complete .
Main modifications :
(1) Realized the double movement of character map . That is, if the character moves to the middle of the screen , Mobile character ; People move around the screen , If you can move the map, move the map , Otherwise move the character .
(2) The original one-way moving animation of the character is replaced by four-way moving animation
(3) Fixed the problem of character ghosting after pressing the key
(4) Several variables with ambiguous meanings have been modified
Unresolved bug: When you press the key to control the person to move, it will flash
2. Main update code
(1) Timer code
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;// Action of different characters x The coordinates are different
point.Y = -1 * direct * person1.Height;
using (Graphics g = Graphics.FromImage(person1))
{
g.DrawImage(person16, point);// Complete character switching and action superposition
}
using (Graphics g0 = Graphics.FromImage(pictureBox1.Image))
{
//g0.DrawImage()
g0.DrawImage(allBitmap, mapPoint);// Not good. , But I don't know how to solve it
g0.DrawImage(person1, personPt.X,personPt.Y);// Draw the overlay of people and background on the map
}
pictureBox1.Refresh();
t200.Start();
}(2) Character movement and map relative movement code
case 'D':
direct = 2;
if (personPt.X > (pictureBox1.Size.Width - person16.Width / 4)/2)// Across the middle of the screen
{// If the map can be moved , Then move the map
mapPoint.X -= 10;
if (mapPoint.X + allBitmap.Size.Width < currBitmap.Size.Width)// The map is on the edge
{
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;// It's not in the center of the screen yet , Mobile people
if (personPt.X > pictureBox1.Size.Width - person16.Width / 4)
personPt.X = pictureBox1.Size.Width - person16.Width / 4;
}
break;边栏推荐
- Unified certification center oauth2 certification pit
- MySQL8安装详细步骤
- 姿态估计之2D人体姿态估计 - Human Pose Regression with Residual Log-likelihood Estimation(RLE)[仅链接]
- Information theory and coding 2 final review BCH code
- ORB_SLAM2视觉惯性紧耦合定位技术路线与代码详解2——IMU初始化
- 姿态估计之2D人体姿态估计 - (OpenPose) Realtime Multi-Person 2D Pose Estimation using Part Affinity Fields
- 苹果式中文:似乎表达清楚意思了,懂了没完全懂的苹果式宣传文案
- 顺应医改,积极布局——集采背景下的高值医用耗材发展洞察2022
- 无线通信模组如何助力智能无人机打造“空中物联网”?
- ORB_ Slam2 visual inertial tight coupling positioning technology route and code explanation 0 - overall framework and theoretical basic knowledge
猜你喜欢

Using GDB to quickly read the kernel code of PostgreSQL

VINS理论与代码详解4——初始化
![Google X开源抓取机械臂,无需人工标注就能一眼找到目标零件[转]](/img/69/02a3e0eeaf3049f41b118cf0c58972.jpg)
Google X开源抓取机械臂,无需人工标注就能一眼找到目标零件[转]

opencv神经网络库之SVM和ANN_MLP的使用

ORB_ Slam2 visual inertial tight coupling positioning technology route and code explanation 3 - tight coupling optimization model

广和通携手中国移动、惠普、联发科、英特尔合作打造5G全互联PC泛终端系列产品

How does the wireless communication module help the intelligent UAV build the "Internet of things in the air"?

Unified certification center oauth2 certification pit

4. Meet panuon again UI. Title bar of silver form

ORB_SLAM2视觉惯性紧耦合定位技术路线与代码详解2——IMU初始化
随机推荐
探索数据可视化开发平台FlyFish开源背后的秘密!
排序与分页
QT 基于QScrollArea的界面嵌套移动
Wechat applet slides to the top
AEC of the three swordsmen in audio and video processing: the cause of echo generation and the principle of echo cancellation
RSA a little bit of thought
苹果式中文:似乎表达清楚意思了,懂了没完全懂的苹果式宣传文案
How to improve document management
竟然還有人說ArrayList是2倍擴容,今天帶你手撕ArrayList源碼
如何構建以客戶為中心的產品藍圖:來自首席技術官的建議
【无标题】
opencv神经网络库之SVM和ANN_MLP的使用
2290. Minimum Obstacle Removal to Reach Corner
Cmake actual combat record (I)
无线通信模组如何助力智能无人机打造“空中物联网”?
SQL语言
Self recommendation - in depth understanding of the rust Standard Library Kernel
姿态估计之2D人体姿态估计 - SimDR: Is 2D Heatmap Representation Even Necessary for Human Pose Estimation?
[high code file format API] Shanghai daoning provides you with the file format API set Aspose, which can create, convert and operate more than 100 file formats in just a few lines of code
姿态估计之2D人体姿态估计 - Simple Baseline(SBL)