2024-03-18 15:41:46 -03:00
|
|
|
|
// xna.cpp : Defines the entry point for the application.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#include "xna.h"
|
|
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
using namespace xna;
|
|
|
|
|
|
2024-04-22 16:14:55 -03:00
|
|
|
|
namespace xna {
|
|
|
|
|
class Game1 : public Game {
|
|
|
|
|
public:
|
2024-05-06 10:32:17 -03:00
|
|
|
|
Game1() : Game() {
|
2024-04-22 16:14:55 -03:00
|
|
|
|
auto _game = reinterpret_cast<Game*>(this);
|
|
|
|
|
graphics = New<GraphicsDeviceManager>(_game);
|
2024-05-06 14:54:13 -03:00
|
|
|
|
|
|
|
|
|
Content()->RootDirectory("Content");
|
2024-04-22 16:14:55 -03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Initialize() override {
|
|
|
|
|
graphics->Initialize();
|
2024-05-06 11:35:27 -03:00
|
|
|
|
|
2024-05-06 14:54:13 -03:00
|
|
|
|
std::any device = graphicsDevice;
|
|
|
|
|
services->AddService(*typeof<GraphicsDevice>(), device);
|
2024-05-06 11:35:27 -03:00
|
|
|
|
|
2024-04-22 16:14:55 -03:00
|
|
|
|
Game::Initialize();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void LoadContent() override {
|
2024-05-06 14:54:13 -03:00
|
|
|
|
spriteBatch = New<SpriteBatch>(*graphicsDevice);
|
2024-04-22 16:14:55 -03:00
|
|
|
|
|
|
|
|
|
Game::LoadContent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Update(GameTime const& gameTime) override {
|
2024-04-24 10:11:53 -03:00
|
|
|
|
if (Keyboard::GetState().IsKeyDown(Keys::Escape) || GamePad.GetState(PlayerIndex::One).IsButtonDown(Buttons::Back))
|
2024-04-22 16:14:55 -03:00
|
|
|
|
Exit();
|
|
|
|
|
|
|
|
|
|
Game::Update(gameTime);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Draw(GameTime const& gameTime) override {
|
2024-05-06 14:54:13 -03:00
|
|
|
|
graphicsDevice->Clear(Colors::CornflowerBlue);
|
2024-04-22 16:14:55 -03:00
|
|
|
|
|
2024-05-06 14:54:13 -03:00
|
|
|
|
|
2024-04-22 16:14:55 -03:00
|
|
|
|
|
|
|
|
|
Game::Draw(gameTime);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
2024-04-26 11:35:59 -03:00
|
|
|
|
sptr<GraphicsDeviceManager> graphics = nullptr;
|
|
|
|
|
sptr<SpriteBatch> spriteBatch = nullptr;
|
2024-04-22 16:14:55 -03:00
|
|
|
|
};
|
|
|
|
|
}
|
2024-03-18 15:41:46 -03:00
|
|
|
|
|
2024-03-24 18:37:55 -03:00
|
|
|
|
|
2024-04-01 11:29:32 -03:00
|
|
|
|
int APIENTRY WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPSTR lpCmdLine, _In_ int nCmdShow) {
|
2024-05-06 09:58:40 -03:00
|
|
|
|
xna::InitPlatform::Init();
|
|
|
|
|
|
2024-04-22 16:14:55 -03:00
|
|
|
|
auto game = xna::Game1();
|
2024-04-16 19:27:05 -03:00
|
|
|
|
const auto result = game.Run();
|
|
|
|
|
return result;
|
2024-03-18 15:41:46 -03:00
|
|
|
|
}
|