Super Mario 3, Super Mario 3

Source: Internet
Author: User

Super Mario 3, Super Mario 3
Zookeeper

Stage 3:

Objective: To achieve a collision between the horizontal direction and the vertical direction, which is more realistic.

1: To solve the horizontal collision, we must first identify a problem that what on the map cannot pass through, that is to say, we must first define some object brick types on the graph for collision detection.

Preparations for the start of the horizontal detection function:

In order to simplify the horizontal detection, because mario's anchor is in the center position, both sides of the detection are replaced by the center position on the left and right. The two conditions shown in the figure are used to check whether Mario is late for the big mushroom and the award mushroom.

The last and third sentence in the map is to convert the GL coordinate and the brick coordinate. This is very important because the game uses the GL coordinate system, but the TMX map uses the brick coordinate, you need to convert the coordinates of Mario in the game to the coordinate of bricks, then use the last sentence in the sentence to find the types of bricks under the coordinate of the current bricks, and make the judgment of the switch statement:

We can see which bricks are subject to horizontal Collision Detection and which are not needed. When encountering an obstacle, although Mario has a walking animation, his position cannot be moved and he stays in front of the obstacle.

All of the above shows the detection process on the right side of Mario. The same is true on the left side and on the right side.

2: collision detection in the vertical direction, as well as the left and right translations and jumps standing on the map ladder do not follow the implementation:

Start of the detection function in the vertical direction:

In the first condition, Mario fell into the trap and died. The following detection is not required. The second condition is that the control of Mario's head does not go out of the map area.

In the game, Mario needs to be able to step on the edge of bricks in the vertical direction,

This effect cannot use the midpoint of Mario's foot as the detection point. We should put the detection code in a loop, from the lower left to the lower right corner of Mario. If we find that we can stand, then you can stand and exit the loop. The remaining parts are always in the horizontal direction.

 

Vertical Detection involves the detection of Mario landing and falling down from the top of the head to the bricks. The difference between the latter and the current JumpOfffset is positive and negative. When JumpOffset is positive, it indicates that Mario is in the take-off phase, and vice versa.

Mario's whereabouts detection is no different from the above.

Finally, Mario stood on the ladder to detect and follow the ladder. Because the ladder is implemented by placing objects on a map, there is an array of ladders in CCGameLayer, which stores all the ladders. The ladders have the moving component values that move up or down or left or right, there is also the length of the ladder, because the ladder is placed in the vacant place, so Mario can not head to the ladder, so the Ladder detection only Mario whereabouts. Code snippet of the update function for detecting a ladder:

 


At the beginning of world 4-3 in "Super Mary", a piece of "mushroom" was too high?

Super Mary has a acceleration run
It means holding down the key of the fireball while holding down the direction key.

Note that a short distance is required for the acceleration to reach the maximum speed.

Can I send the changed super Mary 3 to my mailbox? QQ: 1056520305

Baidu tieba · super Mary 3 · find a [Super Mary's official online disk] in the lower right, and click "Super Mary" 3-generation revision-unlimited item version, then, download the package step by step and use the simulator to open it.
On the game map, open the item bar (Press z) and press shift to select unlimited items!

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.