Skip to content
Snippets Groups Projects

Implement Player Class

5 files
+ 27
38
Compare changes
  • Side-by-side
  • Inline

Files

+ 5
6
#include "Menu.hpp"
#include "Menu.hpp"
#include "../Building.hpp"
#include "../Building.hpp"
#include "../Level.hpp"
#include "../Config.hpp"
#include "../Config.hpp"
 
#include "../Level.hpp"
#include "../Spritesheet.hpp"
#include "../Spritesheet.hpp"
#include "../Tile.hpp"
#include "../Tile.hpp"
#include "../Unit.hpp"
#include "../Unit.hpp"
@@ -72,7 +72,7 @@ void Menu::render(Engine& engine)
@@ -72,7 +72,7 @@ void Menu::render(Engine& engine)
{
{
SDL_Texture* titleTexture = SDL_CreateTextureFromSurface(engine.renderer(), titleSurface);
SDL_Texture* titleTexture = SDL_CreateTextureFromSurface(engine.renderer(), titleSurface);
SDL_Rect titleRect = {
SDL_Rect titleRect = {
static_cast<int>((800 - titleSurface->w) / 2), 50, titleSurface->w, titleSurface->h};
static_cast<int>((800 - titleSurface->w) / 2), 50, titleSurface->w, titleSurface->h};
SDL_RenderCopy(engine.renderer(), titleTexture, nullptr, &titleRect);
SDL_RenderCopy(engine.renderer(), titleTexture, nullptr, &titleRect);
SDL_DestroyTexture(titleTexture);
SDL_DestroyTexture(titleTexture);
SDL_FreeSurface(titleSurface);
SDL_FreeSurface(titleSurface);
@@ -89,8 +89,8 @@ void Menu::render(Engine& engine)
@@ -89,8 +89,8 @@ void Menu::render(Engine& engine)
SDL_Texture* textTexture = SDL_CreateTextureFromSurface(engine.renderer(), textSurface);
SDL_Texture* textTexture = SDL_CreateTextureFromSurface(engine.renderer(), textSurface);
SDL_Rect textRect = {
SDL_Rect textRect = {
static_cast<int>((800 - textSurface->w) / 2), static_cast<int>(150 + i * 50),
static_cast<int>((800 - textSurface->w) / 2), static_cast<int>(150 + i * 50),
textSurface->w, textSurface->h};
textSurface->w, textSurface->h};
SDL_RenderCopy(engine.renderer(), textTexture, nullptr, &textRect);
SDL_RenderCopy(engine.renderer(), textTexture, nullptr, &textRect);
SDL_DestroyTexture(textTexture);
SDL_DestroyTexture(textTexture);
@@ -126,7 +126,6 @@ void Menu::handleEvent(Engine& engine, SDL_Event& event)
@@ -126,7 +126,6 @@ void Menu::handleEvent(Engine& engine, SDL_Event& event)
{
{
std::cout << "Starting game..." << std::endl;
std::cout << "Starting game..." << std::endl;
// Construct a level
// Construct a level
std::vector<Tile> tiles;
std::vector<Tile> tiles;
for (int y = 0; y < 20; y++)
for (int y = 0; y < 20; y++)
@@ -203,7 +202,7 @@ void Menu::handleEvent(Engine& engine, SDL_Event& event)
@@ -203,7 +202,7 @@ void Menu::handleEvent(Engine& engine, SDL_Event& event)
// std::make_shared<Level>("Osnabrück", 20, 20, tiles, buildings, units,
// std::make_shared<Level>("Osnabrück", 20, 20, tiles, buildings, units,
// effects, std::queue<Player>{});
// effects, std::queue<Player>{});
engine.pushScene(Level::loadLevel("../res/level.h5"));
engine.pushScene(Level::loadLevel("../res/level.h5", engine));
}
}
else if (m_options[m_selectedOption] == "Options")
else if (m_options[m_selectedOption] == "Options")
{
{
Loading