[1.1] 自分が今行いたい事は何か
DxLibライブラリを使って安定した60FPSを出したい
[1.2] どのように取り組んだか(プログラムコードがある場合記載)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DxLibDLL;
namespace DxLib_60FPS
{
class Program
{
static int m_StartTime;
static int m_Count;
static float m_Fps;
const int N = 60;
const int FPS = 60;
static int x = 0;
static int Handle;
static int Blue;
static void Init()
{
Handle = DX.LoadGraph("プレイヤー1.bmp");
}
static void Update()
{
x = x + 2;
if( m_Count == 0 )
{
m_StartTime = DX.GetNowCount();
}
if( m_Count == N )
{
int t = DX.GetNowCount();
m_Fps = (float)(1000.0) /( (t-m_StartTime) / (float)N);
m_Count = 0;
m_StartTime = t;
}
m_Count++;
}
static void Draw()
{
DX.DrawString(50, 20, "[ " + m_Fps + " FPS ]", DX.GetColor(255, 255, Blue ) );
DX.DrawGraph(x % 600, 100, Handle, DX.TRUE);
}
static void Wait()
{
int tookTime = DX.GetNowCount() - m_StartTime;
int waitTime = m_Count * 1000 / FPS - tookTime;
Blue = 255;
if (waitTime > 0)
{
Blue = 0;
DX.WaitTimer(waitTime);
}
}
static int Main(string[] args)
{
DX.SetGraphMode(640, 480, 16);
DX.SetTransColor(0, 255, 0);
DX.ChangeWindowMode(DX.TRUE);
DX.SetDrawScreen(DX.DX_SCREEN_BACK);
DX.DxLib_Init();
Init();
while (DX.ScreenFlip() == 0 && DX.ProcessMessage() == 0 && DX.ClearDrawScreen() == 0)
{
Update();
Draw();
Wait();
}
DX.DxLib_End();
return 0;
}
}
}
動かすと47FPSぐらいしかでなく、画像ひとつなのにこのパフォーマンスは
どこかわるいのではないかと
[1.4] 今何がわからないのか、知りたいのか
60FPSになるメインループのソースコードが知りたいです。
参考にしたのはhttp://csi.nisinippon.com/VS2015IDE/v02.html#topです。
前には、違うウェイトのソースコートがサイトにあったきがするのですが
みつけれませんでした。
[2] 環境
[2.1] OS : Windows, Linux等々
OS:Windows7 32bit Professional
[2.2] コンパイラ名 : VC++ 2008EE, Borand C++, gcc等々
VC# 2010 参考にしたホームページにある
コンソールからウィンドウズのexeにプロパティで変換している
[3] その他
・どの程度C言語を理解しているか
オブジェクト指向を理解、作成できる
・ライブラリを使っている場合は何を使っているか
DxLibライブラリ C# .Net(?)