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

76 lines
1.9 KiB
C++
Raw Normal View History

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:
Game1() {
auto _game = reinterpret_cast<Game*>(this);
graphics = New<GraphicsDeviceManager>(_game);
graphics->PreferredBackBufferWidth(1280);
2024-04-28 20:19:37 -03:00
graphics->PreferredBackBufferHeight(720);
2024-04-22 16:14:55 -03:00
}
void Initialize() override {
graphics->Initialize();
Game::Initialize();
}
void LoadContent() override {
spriteBatch = New<SpriteBatch>(*_graphicsDevice);
2024-05-04 21:07:39 -03:00
XnaErrorCode err{0};
//texture = Texture2D::FromStream(*_graphicsDevice, "D:\\sprite.jpg", &err);
texture = New<Texture2D>(_graphicsDevice.get(), 256, 256);
std::vector<Color> data(256 * 256, 4278190080U);
//std::vector<UINT> data(256 * 256, 0xffffffff);
//std::vector<Uint> data(256 * 256, 4278190080U);
texture->SetData(data, 0, data.size());
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 {
_graphicsDevice->Clear(Colors::CornflowerBlue);
spriteBatch->Begin();
spriteBatch->Draw(*texture, position, Colors::White);
spriteBatch->End();
Game::Draw(gameTime);
}
private:
2024-04-26 11:35:59 -03:00
sptr<GraphicsDeviceManager> graphics = nullptr;
sptr<SpriteBatch> spriteBatch = nullptr;
sptr<Texture2D> texture = nullptr; //200x200
2024-04-22 16:14:55 -03:00
Vector2 position{};
std::vector<Vector2> points;
MouseState currentState{};
MouseState oldState{};
float vel = 1;
int var = 0;
2024-04-28 20:19:37 -03:00
sptr<ContentManager> contentManager;
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-04-20 13:39:19 -03:00
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
}