.NET Compact Framework 游戏编程(英) |
| 作者:Geoff Schwab 来源:Microsoft 发布时间:2005-12-21 23:02:24 |
|
Applies t Summary: This sample expands upon the GAPI series of articles by creating a playable game demo. (13 printed pages) Download G-Man Game Sample IntroductionThe Ultimage GMan game demo is the culmination of my series of GAPI wrapper articles. I first started this series as a challenge to myself to develop a graphics library that ran under managed code and both outperformed GDI and implemented specific functionality (alpha blending, destination key transparency, etc.) not available through GDI. Having achieved this goal, I decided to take it even further by developing a level of a playable game demo. To do this, I elicited the help of two extremely talented artists: Douglas Albright III, who provided the art, and Jason Ilano, who provided the animation. Figure 1 shows an introduction screen to the game.
Figure 1. Introduction screenshot from Ultimate GMan. Due to the size and complexity of the project, I have chosen to keep the article clean of sample code and discuss the components and technical details instead. For a more detailed technical description of gaming in the .NET Compact Framework, see the MSDN article titled "Gaming with the .NET Compact Framework: A Simple Example". Ultimate GMan consists of a layered, parallax scrolling background with AI controlled objects (planes and evil mechanical rabbits) that attack the player. The player has the ability to duck and crawl to avoid the attacks of these enemies and when the best defense is a good offense, the player can launch fireballs. The trajectory of these fireballs is controlled by the length of time that the player holds down the fire button. Figure 2 shows the game in action.
Figure 2. Screenshot of Ultimate GMan gameplay. GXInputThe GXInput library provides the application with the ability to track button presses. The functionality of GXInput is described in detail in the following article: Dancing Particles: Adding Points, Lines, Fonts, and Input to the Managed Graphics Library GXSoundGXSound is a new library in this series of articles. This sound library provides .wav playback capability to the game and is based on the sample found in the P/Invoke library. That library is described in detail at the following link: Recording and Playing Sound with the Waveform Audio Interface The GXSound library provides a wrapper around the WaveOut functionality provided in the above sample and improves upon it by providing a means for preloading wave files and re-using the buffers of pre-loaded sounds rather than releasing the buffers when playback is completed. The GXSound library maintains a list of sounds and provides the application with ID's for each sound that is loaded. The application, in turn, uses these ID's to perform actions on each sound. These actions consist of functions such as Play, Pause, Stop, etc. GXGraphicsThe GXGraphics library is a shell that exposes high level graphics functionality at an API level. In this demo, the GXGraphics API provides a wrapper around two other graphics API's and an implementation of a third managed code graphics library. The two wrappers consist of the .NET Compact Framework's GDI API defined in the System.Drawing namespace, and the native commercial product GapiDraw. The managed library utilizes the Pocket PC Game API (GAPI) which provides information about the device's display properties and access to the display memory. Figure 3 represents this relationship with arrows representing the direction of function calls.
Figure 3. GXGraphics API relationship. Regardless of which graphics engine is used to build an application, the interface to GXGraphics remains the same, thus providing great flexibility during the development process. The various implementations are controlled by compiler switches used to include and exclude the separate implementations via the preprocessor directives: USE_GXLIBS, USE_GDI, and USE_GAPIDRAW. These directives define the use of the GAPI implementation, the GDI wrapper, and the GapiDraw wrapper respectively. For the purpose of this demo, only the minimum necessary amount of functionality is implemented, thus various features that are supported by the various underlying API's are not necessarily available in GXGraphics. GX Libraries and GAPINetThe GXGraphics library's managed code graphics implementation is based on GAPI. This implementation is a subset of the functionality provided by the previous graphics articles leading up to this demo. For more information on the GAPI graphics library, refer to the following articles: |
| [] [返回上一页] [打 印] |
|
文章评论 |



