mirror of
https://github.com/borgesdan/xn65
synced 2024-12-29 21:54:47 +01:00
Correções de nome de variáveis em Game
This commit is contained in:
parent
2135b5859b
commit
7b7fcddc4e
@ -8,21 +8,21 @@ namespace xna {
|
|||||||
contentManager = snew<ContentManager>(services, "");
|
contentManager = snew<ContentManager>(services, "");
|
||||||
contentManager->mainGameService = iservice;
|
contentManager->mainGameService = iservice;
|
||||||
|
|
||||||
_gameWindow = snew<GameWindow>();
|
gameWindow = snew<GameWindow>();
|
||||||
_gameWindow->impl->Color(146, 150, 154);
|
gameWindow->impl->Color(146, 150, 154);
|
||||||
_gameWindow->Title("XN65");
|
gameWindow->Title("XN65");
|
||||||
_gameWindow->impl->Size(
|
gameWindow->impl->Size(
|
||||||
GraphicsDeviceManager::DefaultBackBufferWidth,
|
GraphicsDeviceManager::DefaultBackBufferWidth,
|
||||||
GraphicsDeviceManager::DefaultBackBufferHeight, false);
|
GraphicsDeviceManager::DefaultBackBufferHeight, false);
|
||||||
|
|
||||||
_gameComponents = snew<GameComponentCollection>();
|
gameComponents = snew<GameComponentCollection>();
|
||||||
|
|
||||||
IsFixedTimeStep(isFixedTimeStep);
|
IsFixedTimeStep(isFixedTimeStep);
|
||||||
TargetElapsedTime(targetElapsedTime);
|
TargetElapsedTime(targetElapsedTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::Exit() {
|
void Game::Exit() {
|
||||||
_gameWindow->impl->Close();
|
gameWindow->impl->Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
int Game::StartGameLoop() {
|
int Game::StartGameLoop() {
|
||||||
@ -54,13 +54,13 @@ namespace xna {
|
|||||||
const auto total = impl->_stepTimer.GetTotalSeconds();
|
const auto total = impl->_stepTimer.GetTotalSeconds();
|
||||||
const auto elapsedTimeSpan = TimeSpan::FromSeconds(elapsed);
|
const auto elapsedTimeSpan = TimeSpan::FromSeconds(elapsed);
|
||||||
const auto totalTimeSpan = TimeSpan::FromSeconds(total);
|
const auto totalTimeSpan = TimeSpan::FromSeconds(total);
|
||||||
_currentGameTime.ElapsedGameTime = elapsedTimeSpan;
|
currentGameTime.ElapsedGameTime = elapsedTimeSpan;
|
||||||
_currentGameTime.TotalGameTime = totalTimeSpan;
|
currentGameTime.TotalGameTime = totalTimeSpan;
|
||||||
Update(_currentGameTime);
|
Update(currentGameTime);
|
||||||
});
|
});
|
||||||
|
|
||||||
BeginDraw();
|
BeginDraw();
|
||||||
Draw(_currentGameTime);
|
Draw(currentGameTime);
|
||||||
EndDraw();
|
EndDraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,7 +69,7 @@ namespace xna {
|
|||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!_gameWindow->impl->Create()) {
|
if (!gameWindow->impl->Create()) {
|
||||||
Exception::Throw(Exception::FAILED_TO_CREATE);
|
Exception::Throw(Exception::FAILED_TO_CREATE);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -93,7 +93,7 @@ namespace xna {
|
|||||||
|
|
||||||
void Game::Initialize() {
|
void Game::Initialize() {
|
||||||
Keyboard::Initialize();
|
Keyboard::Initialize();
|
||||||
Mouse::Initialize(_gameWindow->Handle());
|
Mouse::Initialize(gameWindow->Handle());
|
||||||
GamePad::Initialize();
|
GamePad::Initialize();
|
||||||
AudioEngine::Initialize();
|
AudioEngine::Initialize();
|
||||||
|
|
||||||
@ -101,16 +101,16 @@ namespace xna {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Game::Draw(GameTime const& gameTime) {
|
void Game::Draw(GameTime const& gameTime) {
|
||||||
if (_enabledGameComponents && !_drawableGameComponents.empty()) {
|
if (enabledGameComponents && !drawableGameComponents.empty()) {
|
||||||
const auto count = _drawableGameComponents.size();
|
const auto count = drawableGameComponents.size();
|
||||||
|
|
||||||
if (count != _drawableGameComponentsCount && _gameComponents->AutoSort) {
|
if (count != drawableGameComponentsCount && gameComponents->AutoSort) {
|
||||||
GameComponentCollection::DrawSort(_drawableGameComponents);
|
GameComponentCollection::DrawSort(drawableGameComponents);
|
||||||
_drawableGameComponentsCount = count;
|
drawableGameComponentsCount = count;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < count; ++i) {
|
for (size_t i = 0; i < count; ++i) {
|
||||||
auto& component = _drawableGameComponents[i];
|
auto& component = drawableGameComponents[i];
|
||||||
|
|
||||||
if (!component) continue;
|
if (!component) continue;
|
||||||
|
|
||||||
@ -120,24 +120,24 @@ namespace xna {
|
|||||||
drawable->Draw(gameTime);
|
drawable->Draw(gameTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
_drawableGameComponents.clear();
|
drawableGameComponents.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
graphicsDevice->Present();
|
graphicsDevice->Present();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::Update(GameTime const& gameTime) {
|
void Game::Update(GameTime const& gameTime) {
|
||||||
_audioEngine->Update();
|
audioEngine->Update();
|
||||||
|
|
||||||
if (_enabledGameComponents && _gameComponents->Count() > 0) {
|
if (enabledGameComponents && gameComponents->Count() > 0) {
|
||||||
const auto count = _gameComponents->Count();
|
const auto count = gameComponents->Count();
|
||||||
for (size_t i = 0; i < count; ++i) {
|
for (size_t i = 0; i < count; ++i) {
|
||||||
auto component = _gameComponents->At(i);
|
auto component = gameComponents->At(i);
|
||||||
|
|
||||||
if (!component) continue;
|
if (!component) continue;
|
||||||
|
|
||||||
if (component->Type() == GameComponentType::Drawable) {
|
if (component->Type() == GameComponentType::Drawable) {
|
||||||
_drawableGameComponents.push_back(component);
|
drawableGameComponents.push_back(component);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto updatable = reinterpret_pointer_cast<IUpdateable>(component);
|
auto updatable = reinterpret_pointer_cast<IUpdateable>(component);
|
||||||
@ -148,25 +148,25 @@ namespace xna {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sptr<GameWindow> Game::Window() { return _gameWindow; }
|
sptr<GameWindow> Game::Window() { return gameWindow; }
|
||||||
sptr<GraphicsDevice> Game::Device() const { return graphicsDevice; }
|
sptr<GraphicsDevice> Game::Device() const { return graphicsDevice; }
|
||||||
sptr<GameComponentCollection> Game::Components() const { return _gameComponents; }
|
sptr<GameComponentCollection> Game::Components() const { return gameComponents; }
|
||||||
sptr<GameServiceContainer> Game::Services() { return services; }
|
sptr<GameServiceContainer> Game::Services() { return services; }
|
||||||
sptr<ContentManager> Game::Content() const { return contentManager; }
|
sptr<ContentManager> Game::Content() const { return contentManager; }
|
||||||
void Game::EnableGameComponents(bool value) { _enabledGameComponents = value; }
|
void Game::EnableGameComponents(bool value) { enabledGameComponents = value; }
|
||||||
|
|
||||||
void Game::AttachGraphicsDevice(sptr<GraphicsDevice> const& device) {
|
void Game::AttachGraphicsDevice(sptr<GraphicsDevice> const& device) {
|
||||||
graphicsDevice = device;
|
graphicsDevice = device;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::ResizeWindow(int width, int heigth) {
|
void Game::ResizeWindow(int width, int heigth) {
|
||||||
const auto windowBounds = _gameWindow->ClientBounds();
|
const auto windowBounds = gameWindow->ClientBounds();
|
||||||
|
|
||||||
if (windowBounds.Width != width || windowBounds.Height != heigth) {
|
if (windowBounds.Width != width || windowBounds.Height != heigth) {
|
||||||
_gameWindow->impl->Size(
|
gameWindow->impl->Size(
|
||||||
width,
|
width,
|
||||||
heigth);
|
heigth);
|
||||||
_gameWindow->impl->Update();
|
gameWindow->impl->Update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,14 +76,14 @@ namespace xna {
|
|||||||
private:
|
private:
|
||||||
friend class GraphicsDeviceManager;
|
friend class GraphicsDeviceManager;
|
||||||
|
|
||||||
sptr<GameComponentCollection> _gameComponents = nullptr;
|
sptr<GameComponentCollection> gameComponents = nullptr;
|
||||||
sptr<GameWindow> _gameWindow{ nullptr };
|
sptr<GameWindow> gameWindow{ nullptr };
|
||||||
sptr<AudioEngine> _audioEngine = nullptr;
|
sptr<AudioEngine> audioEngine = nullptr;
|
||||||
sptr<ContentManager> contentManager;
|
sptr<ContentManager> contentManager;
|
||||||
std::vector<sptr<IGameComponent>> _drawableGameComponents;
|
std::vector<sptr<IGameComponent>> drawableGameComponents;
|
||||||
size_t _drawableGameComponentsCount{ 0 };
|
size_t drawableGameComponentsCount{ 0 };
|
||||||
bool _enabledGameComponents{ false };
|
bool enabledGameComponents{ false };
|
||||||
GameTime _currentGameTime{};
|
GameTime currentGameTime{};
|
||||||
bool isFixedTimeStep{ true };
|
bool isFixedTimeStep{ true };
|
||||||
TimeSpan targetElapsedTime{ TimeSpan::FromTicks(166667L) };
|
TimeSpan targetElapsedTime{ TimeSpan::FromTicks(166667L) };
|
||||||
bool isRunning{ false };
|
bool isRunning{ false };
|
||||||
|
@ -4,4 +4,4 @@
|
|||||||
|
|
||||||
# Add source to this project's executable.
|
# Add source to this project's executable.
|
||||||
add_subdirectory ("01_blank")
|
add_subdirectory ("01_blank")
|
||||||
add_subdirectory ("02_PlatfformerStarterKit")
|
#add_subdirectory ("02_PlatfformerStarterKit")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user