Added some to the entity code and changed up the header for ResourceManager to include a virtual destructor
This commit is contained in:
Binary file not shown.
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "game.h"
|
||||
#include "rect.h"
|
||||
|
||||
#undef main
|
||||
|
||||
@@ -3,5 +3,8 @@
|
||||
#include "entitybase.h"
|
||||
|
||||
class Entity : public EntityBase {
|
||||
public:
|
||||
Entity();
|
||||
|
||||
virtual ~Entity();
|
||||
};
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
class EntityBase {
|
||||
public:
|
||||
EntityBase();
|
||||
|
||||
virtual ~EntityBase();
|
||||
};
|
||||
|
||||
@@ -1,2 +1,9 @@
|
||||
#include "entitymanager.h"
|
||||
|
||||
EntityManager::EntityManager() {
|
||||
|
||||
}
|
||||
|
||||
EntityManager::~EntityManager() {
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
Game::Game()
|
||||
: input(&renderer)
|
||||
, resourceManager(&renderer)
|
||||
, textureManager(resourceManager.textureManager) {
|
||||
, textureManager(resourceManager.textureManager)
|
||||
, entityManager() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -7,4 +7,6 @@ public:
|
||||
ResourceManger(Renderer* renderer) : textureManager(renderer) {};
|
||||
|
||||
TextureManager textureManager;
|
||||
|
||||
virtual ~ResourceManger();
|
||||
};
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user