当前位置:网站首页>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;边栏推荐
- How does the wireless communication module help the intelligent UAV build the "Internet of things in the air"?
- Net core Tianma XingKong series - Interface Implementation for dependency injection and mutual conversion of database tables and C entity classes
- Several reasons and solutions of virtual machine Ping failure
- 影刀RPA学习和遇见excel部分问题解决方式
- "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
- 姿态估计之2D人体姿态估计 - (OpenPose) Realtime Multi-Person 2D Pose Estimation using Part Affinity Fields
- Common QR decomposition, SVD decomposition and other matrix decomposition methods of visual slam to solve full rank and deficient rank least squares problems (analysis and summary of the most complete
- Odoo authority management (access authority and record rules) is applied to upgrade role management
- Tensorflow actual combat Google deep learning framework version 2 learning summary tensorflow installation
- In what scenario can we not use the arrow function?
猜你喜欢

Comply with medical reform and actively layout -- insight into the development of high-value medical consumables under the background of centralized purchase 2022

You will never want to miss these vertical niche navigation websites

"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

Click to unlock "keyword" of guanghetong 5g module

SVM and ANN of OpenCV neural network library_ Use of MLP

What has guanghetong done in the three years of 5g business from "seeding in the first generation" to "flower on the ground"?

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

VINS理論與代碼詳解4——初始化

Several reasons and solutions of virtual machine Ping failure

反“内卷”,消息称 360 企业安全云将上线“一键强制下班”功能,电脑自动关闭办公软件
随机推荐
uniapp中常用到的方法(部分) - 时间戳问题及富文本解析图片问题
Kubernetes 1.24: preventing unauthorized volume mode switching
[rust daily] first release of mnemos on April 20, 2022
Tensorflow actual combat Google deep learning framework version 2 learning summary tensorflow installation
After class assignment for module 8 of phase 6 of the construction practice camp
Quelqu'un a même dit que ArrayList était deux fois plus grand. Aujourd'hui, je vais vous montrer le code source ArrayList.
如何写一个全局的 Notice 组件?
自动化运维必备的工具-Shell脚本介绍
Cube 技术解读 | Cube 渲染设计的前世今生
Cmake actual combat record (I)
Docket command
Software intelligence: formal rules of AAAS system metrics and grammars
姿态估计之2D人体姿态估计 - Numerical Coordinate Regression with Convolutional Neural Networks(DSNT)
AEC of the three swordsmen in audio and video processing: the cause of echo generation and the principle of echo cancellation
HKU and NVIDIA | factuality enhanced language models for open ended text generation
One-way hash function
RSA a little bit of thought
Vins Theory and Code detail 4 - Initialization
竟然還有人說ArrayList是2倍擴容,今天帶你手撕ArrayList源碼
ORB_SLAM2视觉惯性紧耦合定位技术路线与代码详解1——IMU流型预积分