C # develop WPF/Silverlight animation and game series tutorials (game tutorial): (46) flight mode-free vs sky

Source: Internet
Author: User

Once upon a time, I began to fall in love with the boundless sky, imagining to fly with wings. The treasure chain, the miracle, and the dream fairy show the flying world to countless players. Wings are often a symbol of identity, but the charm of the game is naturally unstoppable if you can give it a meaning of freedom.

How to Make the role in the game fly freely? What are the special characteristics of role flight? This is the most important question for the game to consider when it comes to design. q in online games, wings are only a beautiful ornament, a symbol of the strong, and have no additional attributes for him. They also play games such as miracle and watch out for the gods, when a role is equipped with wings, the movement mode will change to the "ultra-low-altitude" flight mode, but it only shows a change in the appearance style when moving. When encountering any ground obstacle, it still cannot fly over; in 2D In the fantastic fairy tale, the flight mode is gorgeous and authentic. When the protagonist is in the sky, all objects on the ground are reduced to the original 60% ratio between left and right, in addition, the sky layer and the ground layer are covered with a transparent cloudification effect. If you are truly in the sky:


This 2.8d The visual effect Silverlight In two ways: HLSL Rendering and On-Demand scaling. If Silverlight The version can be fully activated. GPU The rendering function HLSL Directly to the genie tray ( Carrier ) And MAP tray for the corresponding proportion of reduced rendering, and then the protagonist and other empty objects to zoom in and restore secondary rendering, where in the sky layer and the ground layer to place a transparent cloud PNG Images, everything can be so simple; but currently Silverlight It cannot be called well yet GPU Under the premise that we can traverse all the objects displayed in the game window through a loop, if not in flight status, then the size is reduced to the original 60% The logic is simple, but you need to pay special attention to the processing of the map. For example, the map uses Tile Block or integral graph is not a problem. If the slice is loaded on demand, it is relatively troublesome and requires more writing.Algorithm. Additionally, the genie will ignore all obstacles during the flight, and the movement speed will be faster than on the ground. It also needs to consider whether the coordinates of the landing are obstacles, otherwise, logic such as landing is not allowed.

" Fantastic fairy "is currently the best 2D online games, in this tutorial, the game structure is not set up at the beginning. - air separation layer, therefore, this section focuses on the traditional low-altitude flight mode of the main character, that is, the appearance and the leap of obstacles.

the materials I have prepared here are from the Fengshen 2 , of course, you must add an isflying attribute to describe whether a task is in flight status, if yes, the collision detection is ignored, for example:

Private BoolWillcollide (QxspriteSprite,PointP ){

If(Sprite. isflying ){Return False;}

......

}

Then add the wings to the game. In this example game in this tutorial, for simplicity, I add wings to the clothing class and add a new weapon: bow. When flying in the sky, do you use the bow to be cool? The attributes of the bow weapons are recorded in Config. xml In the configuration file, two parameters are critical: Attackrange And Longdistanceattack Indicates the attack distance and whether the attack is a remote physical attack. In addition, because the protagonist's materials come from two different games, you are running the demo.ProgramPlease do not be surprised when you encounter a misposition. The principle is as follows:

After the bow:

Hey, the leading character with wings can now enter all areas marked as land obstacles. Because the bow has400The attack range, next we may wish to attract a group of strange people, and fly to the obstacle, an arrow shot at the strange people have no temper, Lu-The difference is that this is the flight privilege:

 

Cool, a little bitCodeThe modification has implemented such interesting functions. Of course, in actual production, you should set up a special wing equipment grid and handle the problem as needed.-The obstacle logic and combat logic between empty spaces, such as the air combat form of the permanent tower. If you want to create a project similar to "Dream fairy ",-The visual effects of the air separation layer should be well laid in the design architecture of the game at the beginning, otherwise the later modification will be much more complicated.

After the protagonist is equipped with a bow, he has long-distance attack capabilities. Careful friends may find out what is missing. Yes, it hurts after the shooting, but I have never seen any arrows fly out? Hey, this is what we will talk about in the next section about the effects of remote attacks and single magic attacks. Stay tuned.

For the source code of this Section, go to the directory to download the Online Demo address:Http://cangod.com

Author: dark blue right hand
Source: http://alamiye010.cnblogs.com/
Download the tutorial directory and source code: Click to enter (welcome to join the WPF/Silverlight team WPF/Silverlight blog Team)
The copyright of this article is shared by the author and the blog Park. You are welcome to reprint it. However, this statement must be retained without the author's consent and Article The original text link is displayed in a prominent position on the page. Otherwise, the legal liability is retained.
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.