Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
#include "GameManager.h"
#include <iostream>
#include "TextureManager.h"
#include "Components.h"
#include "Vector2D.h"
SDL_Renderer* GameManager::render = nullptr;
Manager manager;
auto& newCharacter(manager.addEntity());
GameManager::GameManager()
{}
GameManager::~GameManager()
{}
void GameManager::init(const char *title, int xpos, int ypos, int width, int height, bool fullscreen)
{
int flags = 0;
if (fullscreen) {
flags = SDL_WINDOW_FULLSCREEN;
}
if (SDL_Init(SDL_INIT_EVERYTHING) == 0) {
std::cout << "Subsystems Initialized!" << std::endl;
window = SDL_CreateWindow(title, xpos, ypos, width, height, flags);
if (window) {
std::cout << "Window created!" << std::endl;
}
render = SDL_CreateRenderer(window, -1, 0);
if (render) {
SDL_SetRenderDrawColor(render, 255, 255, 255, 255);
std::cout << "Render created!" << std::endl;
}
isRunning = true;
}
newCharacter.addComp<TransformComp>();
newCharacter.addComp<SpriteComp>("assets/player3.png");
}
void GameManager::handleEvents()
{
SDL_Event event;
SDL_PollEvent(&event);
switch (event.type) {
case SDL_QUIT:
isRunning = false;
break;
default:
break;
}
}
void GameManager::update()
{
manager.refresh();
manager.update();
}
void GameManager::renderer()
{
SDL_RenderClear(render);
manager.draw();
SDL_RenderPresent(render);
}
void GameManager::clean()
{
SDL_DestroyWindow(window);
SDL_DestroyRenderer(render);
SDL_Quit();
std::cout << "Game cleaned!" << std::endl;
}