2022-07-26 12:40:54 +08:00
|
|
|
module;
|
|
|
|
#include <Windows.h>
|
|
|
|
#include <vector>
|
|
|
|
#include <wrl/client.h>
|
|
|
|
#include <chrono>
|
|
|
|
|
|
|
|
export module MegaEngine;
|
|
|
|
|
|
|
|
import Input;
|
|
|
|
import Graphics;
|
|
|
|
import GameObject;
|
|
|
|
import Steve;
|
2022-08-05 23:50:08 +08:00
|
|
|
import Obstacle;
|
|
|
|
import ScoreBoard;
|
|
|
|
import BackGround;
|
2022-07-26 12:40:54 +08:00
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
using namespace std::chrono;
|
|
|
|
|
|
|
|
export class Game
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static constexpr LPCWSTR wndClassName = L"1mGameWnd";
|
|
|
|
static constexpr LPCWSTR gameTitle = L"1mGame";
|
|
|
|
static constexpr int wndHeight = 450;
|
|
|
|
static constexpr int wndWidth = 1050;
|
|
|
|
|
|
|
|
void Run();
|
|
|
|
|
|
|
|
private:
|
2022-08-05 23:50:08 +08:00
|
|
|
Texture image;
|
2022-07-26 12:40:54 +08:00
|
|
|
Steve steve;
|
2022-08-05 23:50:08 +08:00
|
|
|
Obstacle obs;
|
|
|
|
ScoreBoard score;
|
|
|
|
BackGround background;
|
2022-07-26 12:40:54 +08:00
|
|
|
steady_clock::time_point last;
|
|
|
|
float delta;
|
|
|
|
|
2022-08-05 23:50:08 +08:00
|
|
|
enum Status { Begin, Running, End } status;
|
|
|
|
|
2022-07-26 12:40:54 +08:00
|
|
|
HWND hwnd = nullptr;
|
|
|
|
bool done = false;
|
|
|
|
|
|
|
|
void StartUp();
|
|
|
|
|
|
|
|
void Update();
|
|
|
|
void Render();
|
|
|
|
void LaterUpdate();
|
|
|
|
|
|
|
|
void CleanUp();
|
|
|
|
|
|
|
|
void CreateWnd();
|
|
|
|
bool PeekMsg();
|
|
|
|
bool Done();
|
|
|
|
|
2022-08-05 23:50:08 +08:00
|
|
|
void GameOver();
|
|
|
|
void ReStart();
|
|
|
|
|
2022-07-26 12:40:54 +08:00
|
|
|
static LRESULT CALLBACK WndProcSetUp(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
|
|
|
static LRESULT CALLBACK WndProcThunk(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
|
|
|
LRESULT WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
|
|
|
};
|