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;
|
|
|
|
|
|
|
|
|
|
//int main()
|
|
|
|
|
//{
|
|
|
|
|
// cout << "Hello CMake." << endl;
|
|
|
|
|
// return 0;
|
|
|
|
|
//}
|
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);
|
|
|
|
|
graphics->PreferredBackBufferHeight(720);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Initialize() override {
|
|
|
|
|
graphics->Initialize();
|
2024-04-23 16:11:17 -03:00
|
|
|
|
const auto modes = _graphicsDevice->_adapter->SupportedDisplayModes();
|
2024-04-22 16:14:55 -03:00
|
|
|
|
Game::Initialize();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void LoadContent() override {
|
|
|
|
|
spriteBatch = New<SpriteBatch>(*_graphicsDevice);
|
|
|
|
|
|
|
|
|
|
XnaErrorCode err;
|
|
|
|
|
texture = Texture2D::FromStream(*_graphicsDevice, "D:\\sprite.jpg", &err);
|
|
|
|
|
|
|
|
|
|
auto audio = AudioEngine();
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
spriteBatch->Begin();
|
|
|
|
|
spriteBatch->Draw(*texture, position, Colors::White);
|
|
|
|
|
spriteBatch->End();
|
|
|
|
|
|
|
|
|
|
Game::Draw(gameTime);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
PGraphicsDeviceManager graphics = nullptr;
|
|
|
|
|
PSpriteBatch spriteBatch = nullptr;
|
|
|
|
|
PTexture2D texture = nullptr; //200x200
|
|
|
|
|
Vector2 position{};
|
|
|
|
|
std::vector<Vector2> points;
|
|
|
|
|
MouseState currentState{};
|
|
|
|
|
MouseState oldState{};
|
|
|
|
|
float vel = 1;
|
|
|
|
|
int var = 0;
|
|
|
|
|
};
|
|
|
|
|
}
|
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-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
|
|
|
|
}
|