1
0
mirror of https://github.com/borgesdan/xn65 synced 2024-12-29 21:54:47 +01:00
2024-05-06 14:54:13 -03:00

63 lines
1.3 KiB
C++

// xna.cpp : Defines the entry point for the application.
//
#include "xna.h"
using namespace std;
using namespace xna;
namespace xna {
class Game1 : public Game {
public:
Game1() : Game() {
auto _game = reinterpret_cast<Game*>(this);
graphics = New<GraphicsDeviceManager>(_game);
Content()->RootDirectory("Content");
}
void Initialize() override {
graphics->Initialize();
std::any device = graphicsDevice;
services->AddService(*typeof<GraphicsDevice>(), device);
Game::Initialize();
}
void LoadContent() override {
spriteBatch = New<SpriteBatch>(*graphicsDevice);
Game::LoadContent();
}
void Update(GameTime const& gameTime) override {
if (Keyboard::GetState().IsKeyDown(Keys::Escape) || GamePad.GetState(PlayerIndex::One).IsButtonDown(Buttons::Back))
Exit();
Game::Update(gameTime);
}
void Draw(GameTime const& gameTime) override {
graphicsDevice->Clear(Colors::CornflowerBlue);
Game::Draw(gameTime);
}
private:
sptr<GraphicsDeviceManager> graphics = nullptr;
sptr<SpriteBatch> spriteBatch = nullptr;
};
}
int APIENTRY WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPSTR lpCmdLine, _In_ int nCmdShow) {
xna::InitPlatform::Init();
auto game = xna::Game1();
const auto result = game.Run();
return result;
}