XNA 3.0小例子

    MS昨天发布了XNA Game Studio 3.0游戏开发工具的首个社区技术预览版(CTP),以下是一些相关信息。
XNA Game Studio 3.0正式版预计到今年年底才会发布,目前的CTP预览版仅支持Zune游戏开发,尚不支持Xbox 360游戏。除了Zune游戏外,该开发工具还能够访问Zune播放器中存储的非DRM保护音乐,允许开发者自定义游戏背景音乐,或开发出实时音乐虚拟游戏等等。另外,使用它开发的游戏还能够支持ad-hoc点对点互联,支持多台Zune无线联机对战。

XNA Game Studio 3.0 CTP仅支持32位Windows系统,需要Visual Studio 2008 Standard Edition或以上开发环境的支持(必须安装C#,或至少安装Visual C# 2008 Express Edition)。现在网络上已经有首批Zune游戏放出,可以通过XNA Game Studio 3.0 CTP在Zune上安装试玩。

我也来看下热闹

 1    public class Game1 : Microsoft.Xna.Framework.Game
 2    {
 3        GraphicsDeviceManager graphics;
 4        SpriteBatch spriteBatch;
 5        SpriteFont fnt;
 6
 7        Vector2 Posi;                   //鼠标位置
 8        Color col;                      //鼠标颜色
 9        Color bgcol;                    //背景颜色
10        int LastScrollWheelValue=0;       //最后一次鼠标滚轮值
11
12        public Game1()
13        {
14            graphics = new GraphicsDeviceManager(this);
15            Content.RootDirectory = "Content";
16            Posi = Vector2.Zero;
17            col = Color.Red;
18            bgcol = Color.CornflowerBlue;
19        }

20
21        protected override void Initialize()
22        {
23
24            base.Initialize();
25        }

26
27
28        protected override void LoadContent()
29        {
30            spriteBatch = new SpriteBatch(GraphicsDevice);
31
32            fnt = Content.Load<SpriteFont>("font");
33        }

34
35
36        protected override void UnloadContent()
37        {
38        }

39
40
41        protected override void Update(GameTime gameTime)
42        {
43
44            MouseState ms = Mouse.GetState();
45            KeyboardState ke=Keyboard.GetState();
46            Random rnd = new Random();
47
48
49
50            if (ke.IsKeyDown(Keys.Escape))
51                this.Exit();
52
53            Posi.X = ms.X;
54            Posi.Y = ms.Y;
55            if (ms.RightButton==ButtonState.Pressed)
56                col = new Color((byte)rnd.Next(255), (byte)rnd.Next(255), (byte)rnd.Next(255));
57            if (ms.ScrollWheelValue != LastScrollWheelValue)
58                bgcol = new Color((byte)rnd.Next(255), (byte)rnd.Next(255), (byte)rnd.Next(255));
59            LastScrollWheelValue = ms.ScrollWheelValue;
60
61            base.Update(gameTime);
62        }

63
64        protected override void Draw(GameTime gameTime)
65        {
66            graphics.GraphicsDevice.Clear(bgcol);
67            spriteBatch.Begin();
68            spriteBatch.DrawString(fnt,"Hello,XNA 3.0",Posi,col);
69            spriteBatch.End();
70            base.Draw(gameTime);
71        }

72    }

73}
74
posted @ 2008-05-10 17:22  齐.net  阅读(1766)  评论(3编辑  收藏  举报