Android research-rolling of Game Development protagonists and maps, android game development

Source: Internet
Author: User
Tags android games

Android research-rolling of Game Development protagonists and maps, android game development

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

How can I make the screen display range move with the main character when developing android games and playing Horizontal Pass games?


Development of mobile games based on android

If you are interested in developing games for the Android platform, there are many things you need to know. If you have game development experience, moving to the mobile platform is not particularly difficult. You only need to learn about its architecture and APIs. If you are a beginner in game development, I have summarized a list of things that you must know to get started. This knowledge applies to many types of games, including strategy, strategy, simulation, and smart games. Android is a Java-based environment. This is good news for beginners, because compared with C ++, Java is widely regarded as a more easy-to-use language, and it is the specification of mobile development. Google has also done a great job in documenting the API and providing sample code for use. An example called API Demos shows the functions of almost all APIs. If you are familiar with Java and have used Eclipse, it is quite easy to run your first application. If you have never written code before, you still need to learn a lot on your way forward, but don't be discouraged.
The first step for beginners is to obtain the Android SDK (software development kit ). The SDK contains a core class library, a simulator, some tools and sample code. I strongly recommend using Eclipse and Android Eclipse plug-ins. If you are playing Android, Eclipse IDE is very useful for Java developers. If this is the first time you develop a Java project, you may need to download the full set of JDK, which includes some tools for signing and deploying your application.
Learning application architecture
Don't rush into the ocean of development. It is important to understand the Android application architecture. If you don't learn it, it will be difficult to debug the game you have designed online. You will need to understand Applications, Activities, Intents, and how they interact with each other. Google provides a lot of useful architecture information. What really matters is understanding why your game requires more than one Activity, and what is the design of a game with a good user experience. To understand this, you must first understand what is the Activity lifecycle.
Learning Activity Lifecycle
The Activity lifecycle is managed by the Android operating system. Your activity creation, recovery, suspension, and destruction are all controlled by the operating system. It is important to correctly handle these events so that the application can perform well and do what the user thinks is correct. It is good to know how all of this works before you design your game, because you can save debugging time and expensive redesign time for yourself in the future. For most applications, the default settings will work normally, but for games, you may need to consider opening the SingleInstance flag. When it is set to the default value, Android will create a new activity instance when it deems it appropriate. For a game, you may only need an instance of a game activity. This has some impact on how you manage the transaction status, but for me, this solves some resource management problems and should be considered.
Main cycle
Depending on the type of game you write, you may or may not need a primary loop. If your game does not rely on time or it only responds to what users do, and does not make any visual changes, it will always wait for user input, then you do not need the main loop. If you are writing a primary game or a game with an animation, timer, or any automatic operation, you should carefully consider using the main loop.
The main cycle of the game generally reminds the sub-system to run as many "tick" messages per second as possible in a specific order. Your main loop needs to run in its own thread because Android has a main user interface thread. If you do not run your own thread, the User Interface thread will be blocked by your game, which will cause the Android operating system to fail to update tasks normally. The execution sequence is usually as follows: Status, input, AI, physical, animation, sound, and video.
The Update Status indicates the Management Status transition, such as the end of the game, the choice of characters, or the next level. Most of the time you need to wait for a few seconds in a certain status, and the status management should be... the remaining full text>

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: 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.