Introduction of a space war game based on Monogame development

Source: Internet
Author: User
Tags git client visual studio 2010

Recently, the idea of downloading Microsoft Small Basic and writing a small program of two graphics transforms, hoping to make my son interested in technology (and, of course, being a yard farmer like me is not my intention). Pick up the first language I learned when I started programming GW Basic, after downloading Small Basic, the first graphics program is a colorful ball on the screen to jump the program, looks a bit like a DOS under the outbreak of a small ball virus phenomenon (sorry to expose their age), The second program in the window shows a mouse can control the airplane pattern, the son was very serious at that time. Thought, simply make a plane to play the game for his son, considering that small basic graphics processing is still relatively weak, so I have the previous research experience of Microsoft XNA, in the visual Studio In 2013, a simple space war game was achieved with Monogame.

MonoGame

Let's briefly introduce Monogame. It is an open source implementation for Microsoft XNA 4 that supports such things as Xbox360, Windows, Windows Phone, IOS, Android, Mac OS X, Linux, Windows 8 Metro, Windows 10 and many other platforms. Support for PlayStation Mobile, Raspberry Pi, and PlayStation 4 is currently being perfected. With regard to graphics systems, Monogame allows developers to choose between OpenGL-based or DirectX. You can find out more about Monogame's history at Monogame's website.

Two years ago I was going to simulate a game like the bucket, when I was using Microsoft XNA game Studio 4, and then I didn't go into the game because of a problem with the game map. So, in the following period of time, I have also thought of spare time to do some of the small games to entertain themselves, but was told that Microsoft XNA game Studio has been abandoned by Microsoft, the last version of the VS support it is visual Studio 2010, so after a search, I started my own monogame trip.

At first, Monogame made me mad because it lacked one of the most important features: Content Pipeline. If you want to use Monogame, you must continue to use Microsoft XNA Game Studio and use XNA's content pipeline to compile the materials, sounds, animations, fonts, and other footage you want into XNB files, and then call them in Monogame. This is very difficult to accept, so, at that time I also basically dismissed the idea of continuing to use Monogame.

However, with the efforts of the open source community, the new version of Monogame has fully supported the content pipeline, you can find the content file of the game from the solution manager created by Monogame and double-click it to open the Content editor:

It should be said that the use of the latest version of Monogame, has been able to meet the development of medium-sized game needs, although it still has some program defects (Bugs).

Starwar

Monogame's introduction to this end, confined to the space I will not be in-depth explanation. Please go to the following video to see if I do Starwar space war game is not smarty pants:

" Click here to watch the video "

What do you think? You alright? In any case, you can attract the children on the line. ^_^

Download and install the game

Please " click here " to download the game's installation package. Note that you will be prompted to install OpenAL (a set of open audio libraries) during the installation process, and click Confirm to install. After the installation is complete, you can start the game configuration program and Starwar Space war game from the Start menu.

When you start the game configuration system, a dialog box with User Access control appears, click Yes, and the configuration interface opens:

After the configuration is complete click the OK button, then go to the Start menu and select Starwar to open the game:

With the mouse to move the plane, left-click Fire Laser Attack enemy aircraft, the game at any time press Esc key exit.

The source of the game

The source code of the game is public, the address is: Https://github.com/daxnet/Starwar. You can use a GIT client to clone the source code locally, and note that to properly compile the source code, your computer needs to meet the following criteria:

    1. Installing Visual Studio 2013
    2. Installing Monogame 3.4
    3. . NET Framework: Version 4.0

Description: Game resources are from the network.

    • Background music: "Salamander Snake" game second off remix BGM (from http://v.youku.com/v_show/id_XNTcyNDUxODAw.html?from=s1.8-1-1.2)
    • Star background: From XNA Resource Network (http://xnaresources.com/)
    • Bullet launch, blasting sound effect: from XNA Resource Network (http://xnaresources.com/)
    • Other images (host, Enemy, bullet): Search results from Bing
The design of the game

The game is based on Visual C # with object-oriented design, in the game business, the object of participation in the game is collectively known as Sprites (Sprite), the following is the game of various types of Sprite class dependency graph:

    • Sprite: base class for all sprite types
    • Lasersprite: The genie that represents the laser bullet
    • Parallaxstarsprite: The genie of the Moving star, the star Elf will continue to fall in the course of the game, to present an effect that my machine is flying forward.
    • Backgroundsprite: Starry background elf, motionless throughout the game
    • Enemysprite: Enemy Plane Elf
    • Spaceshipsprite: My Machine elf
    • Animatedsprite: Animated Sprite that animates with a given sprite table (sprite Sheet) with a picture of each frame
    • Spritepool: Wizard Library for managing the specified type of sprite displayed on the screen. When the sprite appears on the screen, the Sprite's IsActive property is true, at which point the sprite can be added to the sprite library for overall management, and when the managed sprite disappears from the screen (coordinates outside the screen boundary), the sprite library frees the sprite's resources and removes it from the library. The ELF library ensures that the objects produced throughout the game are within a certain range
    • Spritegenerator: Wizard Dynamic Generator, for every certain time, anywhere on the screen to create a genie, and let it at any speed in a certain direction. For example, enemy aircraft and stars, are randomly generated by the wizard dynamic Generator, the resulting sprite will be added to the Spritepool, by Spritepool to host its life cycle

Implementation code is not posted here, you can directly to the above source code home page to view.

There's something else to do.

There are a few things you can do to improve the game, such as:

    • Introducing the LUA scripting engine to customize the flight path of enemy aircraft
    • Join the aircraft Bullet system
    • Join the Life system
    • Laser Bullet Power Enhancement
    • Level
    • (etc.....) )

Keep the interest in the future and then gradually improve it.

Introduction to a space war game based on Monogame development

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.