[Gaming Basics] internal border scrolling Screen

Source: Internet
Author: User
What is a volume screen?

For most action games or adventure games, the game scenario is usually very large and cannot be fully displayed on the game stage. Therefore, if you only rely on game characters to move on the stage, the scope of its activities will be limited to a small stage.
So how can we solve this problem? Yes. Mobile game scenarios! As the saying goes, as the saying goes, the tree is quiet and the wind is endless, and the movement of the background will make the moving Effect of static game characters, while the movement of scenes is not
Restricted, we can only see the scene size from the perspective. As the scene moves freely, game characters can also be moved to any location of the scene. This is what we call a volume screen!
Let's take a look at how the volume screen in as3 is implemented!
In general, we define the speed VX and Vy for the game character char in the X axis and Y directions, and then move the character in the enter_frame event or timer event by increasing the speed value, the Code is as follows:

  1. Stage. addeventlistener (event. enter_frame, loop );
  2. Private function loop (E: Event): void
  3. {
  4. Char. x + = VX;
  5. Char. Y + = Vy;
  6. }


As mentioned above, the movement is relative. When I move forward and the tree on the side of the road goes backwards, the speed of the background is the opposite of that of the character when the screen is scaled. The Code is as follows:

  1. Private function loop (E: Event): void
  2. {
  3. Background. X-= VX;
  4. Background. Y-= Vy;
  5. }


Try to apply the above method and you will find that the effect is not as good as you think. When the background moves to the stage boundary, it will stop (the premise of course is that you have created a boundary detection for the game background, we will not discuss edge detection in the game here, but you can talk about it in Goole), so the game figures cannot really reach the boundary of the background.
To solve this problem, I use an inner boundary volume screen.
Inner border volume Screen

Before a game character arrives at the stage boundary, it directly moves the game character object. When the game character arrives at the stage boundary, it stops moving the game character and positions it at the boundary, then, the reverse mobile game scenario is also possible.
To produce the effect of moving game characters. But in this way, you will find new problems. We cannot predict scenarios that are not on the stage. As the scenario moves, an apple attack may occur.
As a result, it may also be an enemy, and a game character is positioned at the stage boundary. For an object that is about to appear, it can only come and be safe, this is a tough Design for other gamers.
Then there will be three enemies, and the game figures will surely die (for example ).

Download

(19.4 KB) 6 days ago


To avoid this situation, we can create an inner boundary. That is to say, when a game character arrives at the inner boundary but does not actually reach the stage boundary, the reverse mobile game scenario starts, in this way, you can find the enemy before colliding with game characters and then Dodge (for example ):


Theoretically speaking, let's implement this algorithm step by step.
First, the distance between the innertop, innerbtm, innerleft, and innerright between the inner boundary and the stage boundary are defined. Then, based on the location of game characters, We will classify and discuss:
1. A game character can move any side of the contact's inner boundary.

Download

(27.3 KB) 6 days ago


2. At this time, the game character moves to the left border and stops moving. The movement we see is the illusion of reverse movement of scenes.

3. when the game scenario moves to the visible region boundary (that is, the stage), the scene stops moving, and the left boundary of the inner boundary is extended to the left boundary position of the visible area, the game character can continue to move to the left.

4. When a game character moves to the right boundary of the inner boundary, the expanded left boundary in step 1 is restored to the initial state.

The Calculation Method of several other boundaries is same.
If you only define the left and right boundary, You can implement a horizontal screen. The classic example is super Mary. If the four inner boundaries are defined above and below, they are generally applied in the game with a look-down view, such as the Red realm!
Well, let's write it here. If you still feel vague about my explanation, you can refer to Chapter 6th in foundation game design with flash. I also revealed a small message that the book Turing has already translated almost. It is estimated that the book will be published in another two months!

Download

(27.26 KB) 6 days ago

Download

(24.68 KB) 6 days ago

Download

(26.29 KB) 6 days ago

Download

(22.69 KB) 6 days ago
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.