mirror of
https://github.com/borgesdan/xn65
synced 2024-12-29 21:54:47 +01:00
Implementações em Platform
This commit is contained in:
parent
77e1b316e2
commit
3e93d0ffbe
@ -88,15 +88,15 @@ namespace xna {
|
|||||||
void SoundEffect::Play() {
|
void SoundEffect::Play() {
|
||||||
if (!impl->_dxSoundEffect)
|
if (!impl->_dxSoundEffect)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
impl->_dxSoundEffect->Play();
|
impl->_dxSoundEffect->Play();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoundEffect::Play(float volume, float pitch, float pan) {
|
void SoundEffect::Play(float volume, float pitch, float pan) {
|
||||||
if (!impl->_dxSoundEffect)
|
if (!impl->_dxSoundEffect)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
impl->_dxSoundEffect->Play(volume, pitch, pan);
|
impl->_dxSoundEffect->Play(volume, pitch, pan);
|
||||||
}
|
}
|
||||||
|
|
||||||
uptr<SoundEffectInstance> SoundEffect::CreateInstance() {
|
uptr<SoundEffectInstance> SoundEffect::CreateInstance() {
|
||||||
|
@ -19,7 +19,7 @@ namespace xna {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
static constexpr int DefaultBackBufferWidth = 800;
|
static constexpr int DefaultBackBufferWidth = 800;
|
||||||
static constexpr int DefaultBackBufferHeight = 600;
|
static constexpr int DefaultBackBufferHeight = 480;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool CreateDevice();
|
bool CreateDevice();
|
||||||
|
@ -406,7 +406,7 @@ namespace xna {
|
|||||||
HINSTANCE _hInstance{ nullptr };
|
HINSTANCE _hInstance{ nullptr };
|
||||||
HWND _windowHandle{ nullptr };
|
HWND _windowHandle{ nullptr };
|
||||||
int _windowWidth{ 800 };
|
int _windowWidth{ 800 };
|
||||||
int _windowHeight{ 600 };
|
int _windowHeight{ 480 };
|
||||||
HICON _windowIcon{ nullptr };
|
HICON _windowIcon{ nullptr };
|
||||||
HCURSOR _windowCursor{ nullptr };
|
HCURSOR _windowCursor{ nullptr };
|
||||||
COLORREF _windowColor{ RGB(0,0,0) };
|
COLORREF _windowColor{ RGB(0,0,0) };
|
||||||
|
@ -20,9 +20,7 @@ namespace PlatformerStarterKit {
|
|||||||
|
|
||||||
void Initialize() override {
|
void Initialize() override {
|
||||||
auto game = reinterpret_cast<Game*>(this);
|
auto game = reinterpret_cast<Game*>(this);
|
||||||
graphics = New<GraphicsDeviceManager>(game->shared_from_this());
|
graphics = New<GraphicsDeviceManager>(game->shared_from_this());
|
||||||
graphics->PreferredBackBufferWidth(BackBufferWidth);
|
|
||||||
graphics->PreferredBackBufferHeight(BackBufferHeight);
|
|
||||||
graphics->Initialize();
|
graphics->Initialize();
|
||||||
|
|
||||||
std::any device = graphicsDevice;
|
std::any device = graphicsDevice;
|
||||||
@ -130,11 +128,9 @@ namespace PlatformerStarterKit {
|
|||||||
sptr<Texture2D> diedOverlay = nullptr;
|
sptr<Texture2D> diedOverlay = nullptr;
|
||||||
int levelIndex = -1;
|
int levelIndex = -1;
|
||||||
sptr<Level> level = nullptr;
|
sptr<Level> level = nullptr;
|
||||||
bool wasContinuePressed;
|
bool wasContinuePressed = false;
|
||||||
TimeSpan WarningTime = TimeSpan::FromSeconds(30);
|
TimeSpan WarningTime = TimeSpan::FromSeconds(30);
|
||||||
static constexpr int TargetFrameRate = 60;
|
static constexpr int TargetFrameRate = 60;
|
||||||
static constexpr int BackBufferWidth = 1280;
|
|
||||||
static constexpr int BackBufferHeight = 720;
|
|
||||||
static constexpr Buttons ContinueButton = Buttons::A;
|
static constexpr Buttons ContinueButton = Buttons::A;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ namespace PlatformerStarterKit {
|
|||||||
|
|
||||||
void Gem::OnCollected(xna::sptr<Player>& collectedBy)
|
void Gem::OnCollected(xna::sptr<Player>& collectedBy)
|
||||||
{
|
{
|
||||||
collectedSound->Play();
|
collectedSound->Play();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Gem::Draw(xna::GameTime const& gameTime, xna::SpriteBatch& spriteBatch)
|
void Gem::Draw(xna::GameTime const& gameTime, xna::SpriteBatch& spriteBatch)
|
||||||
|
@ -186,10 +186,9 @@ namespace PlatformerStarterKit {
|
|||||||
for (size_t y = 0; y < Height(); ++y) {
|
for (size_t y = 0; y < Height(); ++y) {
|
||||||
for (size_t x = 0; x < Width(); ++x) {
|
for (size_t x = 0; x < Width(); ++x) {
|
||||||
auto& texture = tiles[x][y].Texture;
|
auto& texture = tiles[x][y].Texture;
|
||||||
if (texture) {
|
if (texture) {
|
||||||
const auto p = xna::Vector2(x, y);
|
|
||||||
const auto s = xna::Vector2(x, y);
|
const auto s = xna::Vector2(x, y);
|
||||||
const auto position = p * s;
|
const auto position = s * Tile::Size();
|
||||||
spriteBatch.Draw(texture, position, xna::Colors::White);
|
spriteBatch.Draw(texture, position, xna::Colors::White);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,8 +12,8 @@ namespace PlatformerStarterKit {
|
|||||||
struct Tile {
|
struct Tile {
|
||||||
xna::PTexture2D Texture = nullptr;
|
xna::PTexture2D Texture = nullptr;
|
||||||
TileCollision Collision{};
|
TileCollision Collision{};
|
||||||
constexpr static int Width = 64;
|
constexpr static int Width = 40;
|
||||||
constexpr static int Height = 48;
|
constexpr static int Height = 32;
|
||||||
|
|
||||||
constexpr static xna::Vector2 Size() {
|
constexpr static xna::Vector2 Size() {
|
||||||
return{ Width, Height };
|
return{ Width, Height };
|
||||||
|
Loading…
x
Reference in New Issue
Block a user