Delete YuppleMayham/src/gameplay/'
This commit is contained in:
parent
93b0c0ea0d
commit
cb79147e50
1 changed files with 0 additions and 134 deletions
|
|
@ -1,134 +0,0 @@
|
|||
#include "gameplay/game.h"
|
||||
#include "gameplay/input.h"
|
||||
#include "gameplay/scene.h"
|
||||
/*due for possible removal!*/
|
||||
#include "gameplay/gameactor.h"
|
||||
#include "gameplay/weapons/weapon.h"
|
||||
/*-------------------------*/
|
||||
|
||||
#include "utility/command.h"
|
||||
#include "utility/resourcemanager.h"
|
||||
#include "utility/ftfont.h"
|
||||
#include "utility/logger.h"
|
||||
|
||||
#include "graphics/glwindow.h"
|
||||
|
||||
#include "sound/engine.h"
|
||||
|
||||
#include <glm/gtc/matrix_transform.hpp>
|
||||
#include <memory>
|
||||
#include <utility/events.h>
|
||||
|
||||
bool Game::init()
|
||||
{
|
||||
window = std::make_shared<GLWindow>("Yupple Mayham", 800, 600);
|
||||
|
||||
if (!window->Init())
|
||||
ERROR_LOG("Failed to init GLWindow: {}", SDL_GetError());
|
||||
|
||||
if (!gladLoadGLLoader((GLADloadproc)SDL_GL_GetProcAddress))
|
||||
ERROR_LOG("Failed to load GLLoader", NULL);
|
||||
|
||||
#if _DEBUG
|
||||
LOG_LEVEL(DEBUG);
|
||||
#else
|
||||
LOG_LEVEL(INFO);
|
||||
#endif
|
||||
|
||||
SDL_GL_SetSwapInterval(1);
|
||||
glViewport(0, 0, window->width(), window->height());
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
// For now we'll init default bindings, but as we move forward controls will be set by the player and saved in controls.xml
|
||||
inputHandler = std::make_shared<InputHandler>();
|
||||
inputHandler->bindKeyCommand(SDLK_w, 0, new MoveUpCommand());
|
||||
inputHandler->bindKeyCommand(SDLK_a, 0, new MoveLeftCommand());
|
||||
inputHandler->bindKeyCommand(SDLK_s, 0, new MoveDownCommand());
|
||||
inputHandler->bindKeyCommand(SDLK_d, 0, new MoveRightCommand());
|
||||
|
||||
inputHandler->bindMouseCommand(MOUSE_BUTTON_LEFT, 100, new ShootCommand());
|
||||
inputHandler->bindMouseMotion(new FollowMouseCommand());
|
||||
inputHandler->bindMouseScroll(new CycleCommand());
|
||||
|
||||
game_state |= GAME_RUNNING;
|
||||
globalEventManager = std::make_shared<EventManager>();
|
||||
resourceManager = std::make_shared<ResourceManager>();
|
||||
renderer = std::make_shared<Renderer>(resourceManager);
|
||||
audioEngine = std::make_shared<AudioEngine>(resourceManager);
|
||||
audioEngine->hookEventManager(globalEventManager);
|
||||
/* Testing */
|
||||
audioEngine->pushMusic("music/short_song.ogg");
|
||||
audioEngine->pushMusic("music/bright.ogg");
|
||||
audioEngine->pushMusic("music/main_song.ogg");
|
||||
audioEngine->playMusic();
|
||||
/* */
|
||||
renderer->hookEventManager(globalEventManager);
|
||||
textHandler = std::make_shared<Text>();
|
||||
if (!textHandler->loadFonts("fonts"))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
const unsigned Game::getWindowWidth() const { return window->width(); }
|
||||
const unsigned Game::getWindowHeight() const { return window->height(); }
|
||||
|
||||
bool Game::loadDebugScene()
|
||||
{
|
||||
currentScene = std::make_shared<Scene>(SCENE_SHOOTER, resourceManager, globalEventManager);
|
||||
currentScene->init();
|
||||
audioEngine->hookSceneManager(currentScene->getEventManager());
|
||||
if (currentScene->getPlayer() == nullptr)
|
||||
return false;
|
||||
inputHandler->setActor(currentScene->getPlayer().get());
|
||||
return true;
|
||||
}
|
||||
|
||||
void Game::captureInput(SDL_Event& e)
|
||||
{
|
||||
inputHandler->captureInput(e);
|
||||
}
|
||||
|
||||
void Game::executeInputs()
|
||||
{
|
||||
inputHandler->handleInput();
|
||||
inputHandler->executeCommands();
|
||||
}
|
||||
|
||||
void Game::update(double deltaTime)
|
||||
{
|
||||
if (currentScene)
|
||||
currentScene->update(deltaTime);
|
||||
audioEngine->poll();
|
||||
}
|
||||
|
||||
void Game::render()
|
||||
{
|
||||
glClearColor(0.05f, 0.25f, 0.05f, 1.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
if (currentScene)
|
||||
{
|
||||
currentScene->render(renderer);
|
||||
/*Debug ammo indicator*/
|
||||
textHandler->DrawText("comic.ttf", std::to_string(currentScene->getPlayer()->getHeldWeapon()->getMagazine()), glm::vec2(10, 10), 0.5f);
|
||||
textHandler->DrawText("comic.ttf", "/", glm::vec2(50, 10), 0.5f);
|
||||
textHandler->DrawText("comic.ttf", std::to_string(currentScene->getPlayer()->getHeldWeapon()->getAmmo()), glm::vec2(90, 10), 0.5f);
|
||||
}
|
||||
|
||||
window->swap();
|
||||
}
|
||||
|
||||
void Game::quit()
|
||||
{
|
||||
game_state = GAME_QUITTING;
|
||||
}
|
||||
|
||||
Game::~Game()
|
||||
{
|
||||
if (audioEngine) {
|
||||
audioEngine->killMusic();
|
||||
}
|
||||
resourceManager->clearResources();
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue