added resources and changed textures

This commit is contained in:
Ben
2019-01-06 15:31:39 +00:00
parent dae9169704
commit 1ba7a0609a
7 changed files with 16 additions and 12 deletions

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

@@ -1,8 +1,7 @@
#include "entitybase.h"
EntityBase::EntityBase()
: textureDimensions(0, 0) {
EntityBase::EntityBase() {
}
EntityBase::~EntityBase() {

View File

@@ -14,9 +14,6 @@ public:
virtual ~EntityBase();
private:
std::string textureRef;
std::string textureSource;
Vec2<int> textureDimensions;
};
#endif

View File

@@ -1,5 +1,7 @@
#include "texturemanager.h"
#include <SDL2/SDL_image.h>
TextureManager::TextureManager(Renderer* renderer) {
m_renderer = renderer;
}

View File

@@ -2,11 +2,12 @@
#define _RESOURCEMANAGER_TEXTUREMANAGER_H_
#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
#include <logger.h>
#include <vector>
#include <string>
#include <map>
#include <logger.h>
#include <math.h>
#include "../renderengine/renderer.h"
struct Texture {
@@ -17,6 +18,11 @@ struct Texture {
std::string name;
std::string source;
SDL_Texture* texture;
// Vec2<int>* textureDimensions;
};
struct TextureMap {
std::vector<Texture*> textures;
};
class TextureManager {

View File

@@ -7,14 +7,14 @@ int main(int argc, char** argv) {
Game game;
game.renderer.createWindow("Crumpet Engine", 600, 400, SCREEN_MODE_VSYNC);
game.textureManager.registerTexture("./resources/mario.png", "mario");
game.textureManager.registerTexture("./resources/eldritch-ts.png", "Eldritch");
while (!game.renderer.isWindowClosed()) {
game.renderer.clear();
game.input.poll();
Rect rectfrom(0, 0, 1000, 1000);
Rect rectTo(-300, 0, 1000, 1000);
SDL_RenderCopy(game.renderer.SDLRenderer, game.textureManager.getSDLTexture("mario"), rectfrom.ToSDLRect(), rectTo.ToSDLRect());
Rect rectfrom(0, 0, 100, 100);
Rect rectTo(0, 0, 400, 400);
SDL_RenderCopy(game.renderer.SDLRenderer, game.textureManager.getSDLTexture("Eldritch"), rectfrom.ToSDLRect(), rectTo.ToSDLRect());
game.renderer.update();
}
}