当前位置:网站首页>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;边栏推荐
- One-way hash function
- Several reasons and solutions of virtual machine Ping failure
- [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
- The ultimate buff of smart grid - guanghetong module runs through the whole process of "generation, transmission, transformation, distribution and utilization"
- json. Load (s) and json dump(s)
- "Bloom Cup" 5g Application Award grand slam! Several joint projects of guanghetong won the first, second and third prizes in the general product theme competition
- 凸函数的Hessian矩阵与高斯牛顿下降法增量矩阵半正定性的理解
- rk3399_9.0去掉设置的一级菜单network & internet
- 从“初代播种”到“落地生花”,广和通在5G商用三年间做了什么?
- Huawei cloud SRE deterministic O & M introduction
猜你喜欢

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

RSA a little bit of thought

AEC of the three swordsmen in audio and video processing: the cause of echo generation and the principle of echo cancellation

Vins theory and code explanation 0 -- theoretical basis in vernacular

How does CRM help enterprises and salespeople?

After class assignment for module 8 of phase 6 of the construction practice camp

Fast detection of short text repetition rate

探索数据可视化开发平台FlyFish开源背后的秘密!

姿态估计之2D人体姿态估计 - Associative Embedding: End-to-End Learning for Joint Detection and Grouping

How does the wireless communication module help the intelligent UAV build the "Internet of things in the air"?
随机推荐
uniapp中常用到的方法(部分) - 时间戳问题及富文本解析图片问题
Mitm (man in the middle attack)
rk3399_9.0去掉设置的一级菜单network & internet
json. Load (s) and json dump(s)
Net core Tianma XingKong series - Interface Implementation for dependency injection and mutual conversion of database tables and C entity classes
Applet warning: now you can provide attr `wx:key` for a `wx:for` to improve performance
农产品期货如何开户?有没有什么资金条件?
Self recommendation - in depth understanding of the rust Standard Library Kernel
探索数据可视化开发平台FlyFish开源背后的秘密!
Vins theory and code explanation 4 - initialization
Hessian matrix of convex function and Gauss Newton descent method
点击解锁广和通5G模组“关键词”
[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
Tensorflow actual combat Google deep learning framework version 2 learning summary tensorflow installation
cmake实战记录(一)
Opentelemetry metrics release candidate
自动化运维必备的工具-Shell脚本介绍
22. Generate Parentheses
Interview question details
TensorFlow实战Google深度学习框架第二版学习总结-TensorFlow入门