Added some to the entity code and changed up the header for ResourceManager to include a virtual destructor

This commit is contained in:
Ben
2018-11-29 14:52:24 +00:00
parent 883d152893
commit 68802b5749
10 changed files with 36 additions and 3 deletions

Binary file not shown.

View File

@@ -1,5 +1,6 @@
#pragma once
#include "game.h"
#include "rect.h"
#undef main

View File

@@ -3,5 +3,8 @@
#include "entitybase.h"
class Entity : public EntityBase {
public:
Entity();
virtual ~Entity();
};

View File

@@ -1,5 +1,8 @@
#pragma once
class EntityBase {
public:
EntityBase();
virtual ~EntityBase();
};

View File

@@ -1,2 +1,9 @@
#include "entitymanager.h"
EntityManager::EntityManager() {
}
EntityManager::~EntityManager() {
}

View File

@@ -1,5 +1,17 @@
#pragma once
class EntityManager {
#include <string>
#include <iostream>
#include <map>
#include <vector>
#include "entity.h"
class EntityManager {
public:
EntityManager():
virtual ~EntityManager();
private:
std::map<std::string, Entity> m_activeEntities;
};

View File

@@ -3,7 +3,8 @@
Game::Game()
: input(&renderer)
, resourceManager(&renderer)
, textureManager(resourceManager.textureManager) {
, textureManager(resourceManager.textureManager)
, entityManager() {
}

View File

@@ -7,6 +7,7 @@
#include "renderengine/renderer.h"
#include "resourcemanager/resourcemanager.h"
#include "entitymanager/entitymanager.h"
#include "input/input.h"
class Game {
@@ -15,6 +16,7 @@ public:
ResourceManger resourceManager;
TextureManager textureManager;
EntityManager entityManager;
Renderer renderer;
Input input;

View File

@@ -7,4 +7,6 @@ public:
ResourceManger(Renderer* renderer) : textureManager(renderer) {};
TextureManager textureManager;
virtual ~ResourceManger();
};

View File

@@ -9,7 +9,9 @@ int main(int argc, char** argv) {
while (!game.renderer.isWindowClosed()) {
game.renderer.clear();
game.input.poll();
SDL_RenderCopy(game.renderer.SDLRenderer, game.textureManager.getTexture("mario"), NULL, NULL);
Rect rectfrom(0, 0, 1000, 1000);
Rect rectTo(-300, 0, 1000, 1000);
SDL_RenderCopy(game.renderer.SDLRenderer, game.textureManager.getTexture("mario"), rectfrom.ToSDLRect(), rectTo.ToSDLRect());
game.renderer.update();
}
}