Hi,
i have a little problem with speed of my game (I'm trying to make something like CD-Man/PacMan). I've read all tutorials and followed them, but the game still demands tooo much memory and isn't fast enough...
Her it goes:
I use these standard methods to run my app.
This one is the main cycle-
public static void Run()
{
targetForm = new Form1();
targetForm.Show();
Init(targetForm);//Init method prepares graphic device
InitializeItems();//Loads pictures etc.. (not imortant)
while (running)
{
m_StopWatch.Reset();
m_StopWatch.Start();
Application.DoEvents();
Update();//Goes through Update() method of every drawable object in the game.
Render();//Renders every drawable object
m_StopWatch.Stop();
m_CurrentFrameTime = (double)m_StopWatch.ElapsedTicks;
double delta = m_FrameTime - m_CurrentFrameTime;
if (delta > 0)
{
m_StopWatch.Reset();
m_StopWatch.Start();
while ((double)m_StopWatch.ElapsedTicks < delta) ;
m_StopWatch.Stop();
m_CurrentFrameTime += m_StopWatch.ElapsedTicks;
}
InfoTxt.Text = "FPS: " + CurrentFrameRate.ToString();
}
Application.Exit();
}
Here is Init() method-
private static void Init(Form targetForm)
{
FrameRate = 60;
PresentParameters presentParams = new PresentParameters();
presentParams.Windowed = true;
presentParams.SwapEffect = SwapEffect.Discard;
presentParams.PresentationInterval = PresentInterval.Immediate;
dGDevice = new DGDevice(0, Microsoft.DirectX.Direct3D.DeviceType.Hardware, targetForm, CreateFlags.SoftwareVertexProcessing, presentParams);
dGDevice.RenderState.ReferenceAlpha = 0;
dGDevice.RenderState.AlphaFunction = Compare.NotEqual;
dXSprite = new D3DSprite(dGDevice);
}
Pictures in my game are represented as Microsoft.DirectX.Direct3D.Texture and are drawn with Sprite.Draw2D() method
Now:
+ My (and the tutorial's game)FPS is hardly 60.
+ Application needs approximately 25MB of memory (which is terrible, because the window of the game is exactly same big as window of microsoft's Pinball3D game (the one you get automatically with WinXP), but Pinball3D is happy with 3MB)
Do you have some tips, please?? I want to make my first game that is not just a pathetic parody of a game :-) and i have these obstacles.
Thx very much for any suggestions.
G'Axer