Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using DxLibDLL;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading;
- using System.Threading.Tasks;
- using static DxLibDLL.DX;
- namespace ConsoleApplication3
- {
- class Program
- {
- public static bool CloseFlag = false;
- private static int mStartTime = 0;
- private static int mCount = 0;
- private static float mFps = 0;
- private static int N = 60;
- public static int FPS = 60;
- public static bool DrawFPS = true;
- private static int sleepCount = 0;
- private static long lastUpdateTick = 0;
- private static int screen1;
- private static int screen2;
- static void Main(string[] args)
- {
- DX.SetUseDirect3DVersion(DX.DX_DIRECT3D_9EX);
- DX.SetUseVramFlag(DX.TRUE);
- DX.ChangeWindowMode(DX.TRUE);
- DX.SetMultiThreadFlag(DX.TRUE);
- DX.SetDrawScreen(DX.DX_SCREEN_BACK);
- DX.SetChangeScreenModeGraphicsSystemResetFlag(DX.TRUE);
- DX.DxLib_Init();
- DX.MakeKeyInput(0, 0, 0, 0);
- screen1 = DX.MakeScreen(640, 480);
- screen2 = DX.MakeScreen(640, 480);
- sleepCount = 0;
- while (!CloseFlag && DX.ProcessMessage() == 0 && DX.CheckHitKey(DX.KEY_INPUT_ESCAPE) == 0)
- {
- Tick();
- Thread.Sleep(1);
- }
- CloseFlag = true;
- DX.DxLib_End();
- }
- static void Tick()
- {
- if (lastUpdateTick == 0) lastUpdateTick = DX.GetNowCount();
- if (DX.ClearDrawScreen() == 0 && sleepCount <= 0)
- {
- if (mStartTime == 0)
- mStartTime = DX.GetNowCount();
- if (mCount == N)
- {
- int t = DX.GetNowCount();
- mFps = 1000f / ((t - mStartTime) / (float)N);
- mCount = 0;
- mStartTime = t;
- }
- mCount++;
- Update(DX.GetNowCount() - lastUpdateTick);
- lastUpdateTick = DX.GetNowCount();
- Draw();
- int tookTime = DX.GetNowCount() - mStartTime;
- int waitTime = mCount * 1000 / FPS - tookTime;
- if (waitTime > 0)
- {
- sleepCount = 0;
- }
- }
- if (sleepCount > 0) sleepCount--;
- }
- static void Draw()
- {
- DX.SetDrawScreen(screen1);
- DX.FillGraph(screen1, 0, 0, 0, 0);
- DX.DrawCircleAA(200, 200, 60, 100, DX.GetColor(128, 100, 0), DX.TRUE);
- DX.SetDrawScreen(screen2);
- DX.FillGraph(screen2, 0, 0, 0, 0);
- DX.SetDrawScreen(DX.DX_SCREEN_BACK);
- DX.DrawGraph(0, 0, screen1, DX.TRUE);
- DX.DrawGraph(0, 0, screen2, DX.TRUE);
- DX.ScreenFlip();
- }
- static void Update(long tick)
- {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment