您的位置:首页 > 编程语言 > C#

Direct2D随笔3——构建游戏基础结构

2014-07-27 10:10 274 查看
using System;
using System.Windows.Forms;
using System.Collections.Generic;

namespace NewGame1 {
enum GameStatu {
gameRunning, //0
gamePause,   //1
gameMenu,    //2
gameLoading, //3
gameStart,   //4
gameTest,    //5
};
public partial class WinMain : Form {
TimeController timeController;
DirectRender2D directRender2D;
ulong gameFrame;
int counter_FPS;
public WinMain () {
InitializeComponent();
InitiallizeGameSystem();
}
protected void InitiallizeGameSystem () {
timeController = new TimeController(GameLoop);
directRender2D = new DirectRender2D(this);
}
void GameLoop (double ElapsedTime) {
//GameUpdate....
directRender2D.Begin();
directRender2D.renderClear(new Color4(0, 0, 0, 255));
directRender2D.End();
++gameFrame;
++counter_FPS;
}
private void countFPS (object sender, EventArgs e) {
if (counter_FPS > 65)
this.Text = "[High fps]";
else
this.Text = "[" + counter_FPS + "fps]";
counter_FPS = 0;
}
}
}

整理出来就是这样,第5篇我大概会说一说如何render出几何图形。

另外,游戏的输入还是一个很重要的内容,第4篇我会大概的说一说的。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  winform 2d 游戏 c#