Silverlight Game Design: (iii) All originated in this real world

Source: Internet
Author: User
Tags silverlight

All along, I've been thinking about how to make Silverlight more simple in game making. The Bible says that God created the world, and that "game", no matter how old it was, was seen as a specific activity to simulate the real world to some extent. Based on Einstein's space-time theory, the fundamental structure of all things that exist in the world is 3-D space + 1-D time, and a great game is emerging in my mind. Base class: Gamebase.

"Object", used to describe all objects in the world, as an objective reality, we cannot instantiate it: Public abstract class gamebase. All "Objects" have 3-dimensional space characteristics, simply say X, Y, Z:

/// <summary>
         /// 获取或设置X、Y坐标
         /// </summary>
         public virtual Point Coordinate {
             get { return new Point(Canvas.GetLeft(this), Canvas.GetTop (this)); }
             set { Canvas.SetLeft(this, value.X); Canvas.SetTop(this,  value.Y); }
         }
         /// <summary>
         /// 获取或设置Z层次深度
         /// </summary>
         public int Z {
             get { return Canvas.GetZIndex(this); }
             set { Canvas.SetZIndex(this, value); }
    }

The coordinate is defined as a point type to facilitate the compatibility of the storyboard animation, and as a virtual virtual property, subclasses can choose whether to override according to their specific requirements.

In addition, we must give the "object" an external "body" to hold the other parts so that we can visually see it:

Gamebase:canvas

Canvas is a very good choice. Compared to image, it has the same excellent background attribute for the rendering of "body" images, while the contrast grid, also as a container control inherited from the panel, can easily lay out all the objects contained in the body. Overall evaluation: ultra-thin, lightweight, simple and not simple.

Finally, we have to give the "object" a way to obtain external images for "skin" packaging channels, see also GetImage method:

/// <summary>
         /// 获取指定路径的图片
         /// </summary>
         protected virtual BitmapImage GetImage(string uri) {
             return new BitmapImage((new Uri(string.Format(@"../Images/ {0}", uri), UriKind.Relative))){
                  CreateOptions = BitmapCreateOptions.None
             };
         }

This method specifies how the picture will be rendered as it is downloaded. Of course, as a virtual virtual method, any subclass of "object" can also be rewritten according to its own needs. To give a simple example, I hope that the wizard will only use a legend to render the picture before downloading all 56 frames, so I can use WebClient or some other way to implement the related logical behavior by rewriting the GetImage method in the wizard control. As long as the grasp of the picture resources from the download to the presentation of the entire process, to achieve it is relatively simple.

Next, I'll introduce the most important "one-dimensional time" to the game.

In our real world, "objects" can be divided broadly into "dynamic objects" and "static objects". Only "dynamic Object" will be active and time interaction, and "static object" without any external intervention on the premise of eternal unchanged. Back to the game world, the most representative "dynamic object" in the game is a household name (Sprite), which has a wide variety of forms in all games:

(Source of material: Caga elf)

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.