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

61 lines
1.4 KiB
C++
Raw Normal View History

2024-03-18 15:41:46 -03:00
// xna.cpp : Defines the entry point for the application.
//
2024-06-03 21:55:09 -03:00
#include "xna/xna.hpp"
2024-07-13 22:55:36 -03:00
#include "xna/xna-dx.hpp"
2024-03-18 15:41:46 -03:00
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-05-06 14:54:13 -03:00
Content()->RootDirectory("Content");
2024-04-22 16:14:55 -03:00
}
void Initialize() override {
2024-05-24 14:42:12 -03:00
auto game = reinterpret_cast<Game*>(this);
graphics = snew<GraphicsDeviceManager>(game->shared_from_this());
//graphics->Initialize();
graphics->ApplyChanges();
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 {
spriteBatch = snew<SpriteBatch>(graphicsDevice);
2024-04-22 16:14:55 -03:00
Game::LoadContent();
}
void Update(GameTime const& gameTime) override {
2024-05-21 09:40:59 -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-25 16:55:10 -03:00
graphicsDevice->Clear(Colors::CornflowerBlue);
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;
sptr<Texture2D> texture = nullptr;
2024-04-22 16:14:55 -03:00
};
}
2024-03-18 15:41:46 -03:00
int APIENTRY WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPSTR lpCmdLine, _In_ int nCmdShow) {
2024-05-23 16:50:41 -03:00
xna::Platform::Init();
2024-05-24 14:42:12 -03:00
auto game = snew<Game1>();
const auto result = game->Run();
2024-04-16 19:27:05 -03:00
return result;
2024-03-18 15:41:46 -03:00
}