This series of articles by Net_assassin finishing, reproduced please indicate the source.
http://blog.csdn.net/net_assassin/article/category/1100363
Author: Net_assassin e-mail: net_assassin@hotmail.com look forward to interacting with like-minded friends
The background movement that we see in most action and arcade games uses scrolling based on the picture unit. Although this technology has been around for decades, it is still used to render backgrounds, and such 2D games are still active today. Back in the old days, when computer memory was extremely limited, the use of a picture-based unit of scrolling was because it was extremely efficient.
This chapter focuses on two different ways to create a scrolling background: bitmap-based and picture-based units.scrollingWhat is scrolling. In today's game world, 3D is everyone's concern, never heard of scrolling players and programmers. It's a pity, really. Even if it is not understood or appreciated, the long and fascinating history of modern games continues to be of value today.
Scrolling is a small part of a large virtual game world that displays in a screen window, and then moves through the view in the window to represent the changes in the location of the game world.
We can display a huge bitmap image in the virtual game world to represent the current level of the game, and then copy (bit transfer) the part of the virtual world to the screen. Just the simplest form of scrolling. Another way is to use the picture unit to create the world of the game, which will be explained in a quick way.create a background from a picture cellThe true power of the scrolling background comes from a technique called paving (tiling). Paving is a process in which there is no real background, but rather a picture cell array that forms the background to be displayed. In other words, this is a virtual virtual background that requires very little memory compared to a fully bitmap-based background.
scrolling items based on the picture unit
Here we recommend a special good (free) Picture Unit editing program Mappy. http://www.tilemap.co.uk/mappy.php
Bitmap-based scrollingUsing the Direct3D Surface object to complete the background scrolling there is also a way to scroll with a full bitmap. It requires some very complex programming to generate an algorithm that allows a single bitmap to be wound into a scrolling window without using a picture cell. This makes the code not only complicated, but also slower to render bitmap-based scrolling using picture wrapping.The theory of scrolling based on bitmapTo make bitmap-based scrolling as efficient as possible, it is recommended that you keep the source image as large as the screen. This may make it impossible for the scroll to be as versatile as a scroll that supports any resolution, but it is not difficult to go this way if you really need it (some performance needs to be scaled up because the scrolling buffer of the result needs to be zoomed to the screen). So, for starters, make sure the source bitmap is the same size as the screen. Then, what you have to do is create a larger scrolling buffer, which is 4 times times the size of the source image. This can be done by creating a large Direct3D surface in memory, and then pasting the source image into the four corners of the scrolling buffer. This consumes a lot of memory, but can be scrolled in any direction.
Performing this type of scrolling consists of these main steps: loading the scroll buffer all source bitmaps create source bitmaps 4 times times the size of the scroll buffers copy the source bitmap to the four corners of the scroll buffer in the render scroll buffer in relation to the scrolling position section