WAP之家:为您提供最全最新的WAP技术,CP.SP.3G等行业资讯。 WAP之家交流论坛全新开放 点击进入>>
WAP资讯 | 3G动态 | SP动态 | 运营商动态 | 内容商动态 | 制造商动态 | 论坛讨论>> 每次自动访问
WAP技术 | WAP源码 | 手机编程 | 手机源码 | 无线技术 | J2ME技术 | 手机软件 添加到收藏夹
IVR技术 | SP资料 | SMS MMS技术 | 商业方案 | IVR下载 | 书籍教程 | 工具软件 语言:繁體中文

WAP之家技术文章手机编程Win Mobile程序开发.NET Compact Framework 游戏编程(英)

.NET Compact Framework 游戏编程(英)
作者:Geoff Schwab  来源:Microsoft  发布时间:2005-12-21 23:02:24
 

Applies t
   
Microsoft® .NET Compact Framework 1.0
   Microsoft Visual Studio® .NET 2003
   Microsoft eMbedded Visual C++® 3.0

Summary: This sample expands upon the GAPI series of articles by creating a playable game demo. (13 printed pages)

Download G-Man Game Sample
Evaluate or Purchase GapiDraw
Download GAPI
Download eMbedded Visual Tools 2002 Edition

Introduction

The 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.

GXInput

The 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

GXSound

GXSound 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.

GXGraphics

The 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 GAPINet

The 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:

[1] [2] [3] [4] [5] [6]  下一页

[] [返回上一页] [打 印]
文章评论

用户名: 查看更多评论

分 值:100分 85分 70分 55分 40分 25分 10分 0分

内 容:

         (注“”为必填内容。) 验证码: 验证码,看不清楚?请点击刷新验证码