-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
87 lines (67 loc) · 2.3 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#include <vector>
#include <math.h>
#include "DxLib.h"
#include "sceneMGR.h"
#define INIT_SCREEN_W (640)
#define INIT_SCREEN_H (480)
//■■■■■■■■■■■■FPS計測■■■■■■■■■■■■
static int mStartTime;
static int mCount;
static float mFps;
static const int N = 60;
static const int FPS = 60;
bool Flame_Count() {
if (mCount == 0) {
mStartTime = GetNowCount();
}
if (mCount == N) {
int t = GetNowCount();
mFps = 1000.f / ((t - mStartTime) / (float)N);
mCount = 0;
mStartTime = t;
}
mCount++;
return true;
}
void Wait() {
int tookTime = GetNowCount() - mStartTime;
int waitTime = mCount * 1000 / FPS - tookTime;
if (waitTime > 0) {
Sleep(waitTime);
}
}
//■■■■■■■■■■■■■■■■■■ウィンドウの調整■■■■■■■■■■■■■■■■■■■■
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
int DesktopW, DesktopH;
double WindowExH;
SetMainWindowText("Busters' Mission"); //ウィンドウのタイトルを設定する
SetWindowSizeChangeEnableFlag(TRUE, TRUE); //サイズ変更を可能にする
ChangeWindowMode(FALSE); //ウィンドウモードを有効にする
//SetWindowStyleMode(0); //最大化ボタンが存在し、さらに枠が細くなるウィンドウモードに変更
//GetDefaultState(&DesktopW, &DesktopH, NULL); //画面サイズをデスクトップのサイズと同じにする
SetGraphMode(800, 600, 16);
//SetWindowPosition((DesktopW - INIT_SCREEN_W) / 2, (DesktopH - INIT_SCREEN_H) / 2);//ウィンドウの位置を画面の中心にする
if (DxLib_Init() == -1) // DXライブラリ初期化処理
{
return -1;
} // エラーが起きたら直ちに終了
//WindowExH = ((double)DesktopH - 100.0) / 480.0;
//SetWindowMaxSize(DesktopW, DesktopH);
//SetWindowMinSize(DesktopW / 3, DesktopH / 3);
SetDrawScreen(DX_SCREEN_BACK); //ウィンドウの裏画面設定
SCENE_MGR scene_mgr;
scene_mgr.Initialize(); //初期化
//■■■■■■■■■■■■■■■■■■■■■■メインループ■■■■■■■■■■■■■■■■■■■■■■
while (ScreenFlip() == 0 && ProcessMessage() == 0 && ClearDrawScreen() == 0) {
Flame_Count();
scene_mgr.Update(); //更新
scene_mgr.Draw(); //描画
Wait();
}
//■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
scene_mgr.Finalize(); //終了処理
DxLib_End(); // DXライブラリ使用の終了処理
return 0; // ソフトの終了
}