Android research-rolling of Game Development protagonists and maps

Source: Internet
Author: User

Android research-rolling of Game Development protagonists and maps
Zookeeper

Smooth scrolling of map Movement

Friends who have played rpg games should know that the maps of RPG games are generally relatively large. Today I will share with you how to deal with game maps larger than the screen size of mobile phones in RPG games.

Animation for program effects, The principle of map scrolling has been introduced in my previous blog post about how people move on the screen, because the previous game map is completely filled with the entire mobile phone screen, therefore, you do not need to process smooth scrolling of the map. In this article, I will introduce how to process map scrolling after a person moves. For example, if the map is attached to the left boundary of the screen, the map coordinates are first moved, when the number of characters on the screen exceeds 2/3, the map is moved to the opposite direction of the person's walk to the illusion that the person is still moving to the right, in fact, at this time, the coordinates of the animation that is played to the right remain unchanged in the screen, when a map moves to the opposite direction of a person, it indicates that the border on the right side of the map has been attached to the border on the right side of the mobile phone screen. In this case, the map cannot move the coordinates of the person on the screen until the person is moved. paste the border on the right of the screen, the other three directions have the same principle. In the previous chapter, I learned about the progress bar of Game Development in Android research. Code ImplementationLet's move the character to the right as an example, we need three coordinates: m_HeroPos to save the X coordinates of the characters in the map; mScreenPos to save the display coordinates of the characters on the screen; mMapPos to save the display coordinates of the map on the mobile phone screen, right-click the keyboard and add 8 pixels to the map coordinates (representing the walking step). When the coordinates of the characters exceed 2/3 of the screen, you need to check whether the map is already at the boundary, use the X coordinates of the map drawn on the screen plus the map width to determine whether it is equal to the screen width. If the equation is not true, the map can be moved to the left. Then, the coordinates of the character mScreenPos will remain unchanged. the map shows that the coordinates move a person's step to the left, if the preceding equation is true, the map cannot move to the left. At this time, the displayed coordinates of the mScreenPos character will move to the right of the character in a step until the displayed coordinates of the mMapPos map on the right side of the screen remain unchanged. The three-Direction Moving algorithms are exactly the same. Smooth scrolling of a map Extended learning-Amat map buffering AlgorithmThis game demo is not perfect yet. There is still a problem in the collision with the physical layer, but the most important thing is that the camark map buffer algorithm is not used. Next I will introduce in detail the principle of a camark map buffer algorithm. We need a map for the dashboard. In order to achieve smooth scrolling, the buffer size should be the cell phone screen width and height, so that the memory will resident in a cell phone screen size buffer. If a person walks down, the map is moved up. At this time, the screen is cut out in two parts, and the upper part is the buffer content after the buffer graph moves up, the lower part is the part of the map to be updated. The lower part of the updated map is combined with the upper part of the map buffer to complete a map update on the screen, this greatly improves the efficiency of game map creation. If this method is not used to update a map, it is inefficient to draw a tile every time the map is moved. After the map is moved up, the Green Map part is updated and the red part of the last buffer is combined to form a new game map. The principle of other directions is the same.

: If you can move the main character in the game in the lower right corner of the screen, the map centered in the lower right corner of the screen will be cut into four parts. The red area needs to update the remaining part of the three parts of the map. the portion that exceeds the upper left of the map, the update principle is the same as above. In this case, it seems that carmark is a genius in the game field, and Mark's map buffer algorithm is one of the best map algorithms. If you are interested, you can check out the information about carmatt, he is indeed a top game development engineer. You are welcome to download and read the source code.In the end, if you still think that I am not writing enough details, it doesn't matter if I post the source code. You are welcome to discuss it together. Hope you can make progress together.

Download source code: heromove

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.