From f59059860a17746d0746268f1fa5fc406bb5d067 Mon Sep 17 00:00:00 2001 From: Benedikt Galbavy Date: Mon, 8 Jan 2024 19:32:50 +0100 Subject: [PATCH] restructured project to compile with CMake --- .gitignore | 74 ++++++++++++++- .gitmodules | 8 ++ CMakeLists.txt | 19 ++++ README.md | 0 compile_commands.json | 38 ++++++++ lib/SDL | 1 + lib/SDL_image | 1 + src/ColliderComponent.h | 36 ++++++++ src/Components.h | 8 ++ src/Defines.h | 12 +++ src/ECS.h | 127 ++++++++++++++++++++++++++ src/Game.cpp | 127 ++++++++++++++++++++++++++ src/Game.h | 35 +++++++ src/GameObject.cpp | 35 +++++++ src/GameObject.h | 20 ++++ src/KeyboardController.h | 35 +++++++ src/Map.cpp | 31 +++++++ src/Map.h | 16 ++++ src/SpriteComponent.h | 55 +++++++++++ src/TextureDict.h | 12 +++ src/TextureManager.cpp | 12 +++ src/TextureManager.h | 10 ++ src/TileComponent.h | 41 +++++++++ src/TransformComponent.h | 55 +++++++++++ src/Vector2D.cpp | 52 +++++++++++ src/Vector2D.h | 19 ++++ src/assets/Map.aseprite | Bin 0 -> 3672 bytes src/assets/MapNew.aseprite | Bin 0 -> 5312 bytes src/assets/cat.png | Bin 0 -> 407 bytes src/assets/chicken_neutral.png | Bin 0 -> 751 bytes src/assets/chicken_neutral_knight.png | Bin 0 -> 949 bytes src/assets/cow.png | Bin 0 -> 5470 bytes src/assets/dirt.png | Bin 0 -> 456 bytes src/assets/grass.png | Bin 0 -> 673 bytes src/assets/stone.png | Bin 0 -> 279 bytes src/assets/water.png | Bin 0 -> 340 bytes src/assets/water1.ase | Bin 0 -> 909 bytes src/assets/water1.png | Bin 0 -> 1234 bytes src/main.cpp | 35 +++++++ 39 files changed, 913 insertions(+), 1 deletion(-) create mode 100644 .gitmodules create mode 100644 CMakeLists.txt create mode 100644 README.md create mode 100644 compile_commands.json create mode 160000 lib/SDL create mode 160000 lib/SDL_image create mode 100644 src/ColliderComponent.h create mode 100644 src/Components.h create mode 100644 src/Defines.h create mode 100644 src/ECS.h create mode 100644 src/Game.cpp create mode 100644 src/Game.h create mode 100644 src/GameObject.cpp create mode 100644 src/GameObject.h create mode 100644 src/KeyboardController.h create mode 100644 src/Map.cpp create mode 100644 src/Map.h create mode 100644 src/SpriteComponent.h create mode 100644 src/TextureDict.h create mode 100644 src/TextureManager.cpp create mode 100644 src/TextureManager.h create mode 100644 src/TileComponent.h create mode 100644 src/TransformComponent.h create mode 100644 src/Vector2D.cpp create mode 100644 src/Vector2D.h create mode 100644 src/assets/Map.aseprite create mode 100644 src/assets/MapNew.aseprite create mode 100644 src/assets/cat.png create mode 100644 src/assets/chicken_neutral.png create mode 100644 src/assets/chicken_neutral_knight.png create mode 100644 src/assets/cow.png create mode 100644 src/assets/dirt.png create mode 100644 src/assets/grass.png create mode 100644 src/assets/stone.png create mode 100644 src/assets/water.png create mode 100644 src/assets/water1.ase create mode 100644 src/assets/water1.png create mode 100644 src/main.cpp diff --git a/.gitignore b/.gitignore index 96c264b..f021c07 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,73 @@ -TestProject/.vs +# CMake +CMakeFiles/ +CMakeCache.txt +cmake_install.cmake +Makefile +install_manifest.txt +.cache/ +build/ + +# Compiled files +*.suo +*.user +*.userprefs +*.sln.docstates + +# Compiled dynamic libraries +*.so +*.dylib +*.dll + +# Compiled executables +*.exe +*.out +*.app + +# Generated by Visual Studio +.vscode/ +.vs/ +*.suo +*.user +*.sln.docstates +*_i.c +*_p.c +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Sublime Text +*.sublime-workspace +*.sublime-project + +# macOS +.DS_Store +.AppleDouble +.LSOverride +Icon +._* +.Spotlight-V100 +.Trashes +ehthumbs.db +Thumbs.db + +# Windows +Desktop.ini diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..fcf267e --- /dev/null +++ b/.gitmodules @@ -0,0 +1,8 @@ +[submodule "lib/SDL"] + path = lib/SDL + url = https://github.com/libsdl-org/SDL.git + branch = release-2.28.x +[submodule "lib/SDL_image"] + path = lib/SDL_image + url = https://github.com/libsdl-org/SDL_image.git + branch = release-2.8.x diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..82ef175 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 3.10) + +project(SDL_Minigame) + +set(CMAKE_CXX_STANDARD 20) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +add_subdirectory(lib/SDL) +add_subdirectory(lib/SDL_image) + +find_package(SDL2 REQUIRED CONFIG REQUIRED COMPONENTS SDL2) +find_package(SDL2 REQUIRED CONFIG COMPONENTS SDL2main) +find_package(SDL_image REQUIRED) + +file(GLOB_RECURSE SOURCES src/*.cpp) +add_executable(game ${SOURCES}) + +target_link_libraries(game PRIVATE SDL2::SDL2main) +target_link_libraries(game PRIVATE SDL2::SDL2 SDL2_image ${SDL2_LIBRARIES} ${SDL_IMAGE_LIBRARIES}) \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29 diff --git a/compile_commands.json b/compile_commands.json new file mode 100644 index 0000000..11ddc87 --- /dev/null +++ b/compile_commands.json @@ -0,0 +1,38 @@ +[ +{ + "directory": "/home/nano/Documents/inno/SDL_Minigame", + "command": "/usr/bin/c++ -I/usr/include/SDL -isystem /usr/include/SDL2 -std=gnu++20 -o CMakeFiles/game.dir/src/Game.cpp.o -c /home/nano/Documents/inno/SDL_Minigame/src/Game.cpp", + "file": "/home/nano/Documents/inno/SDL_Minigame/src/Game.cpp", + "output": "CMakeFiles/game.dir/src/Game.cpp.o" +}, +{ + "directory": "/home/nano/Documents/inno/SDL_Minigame", + "command": "/usr/bin/c++ -I/usr/include/SDL -isystem /usr/include/SDL2 -std=gnu++20 -o CMakeFiles/game.dir/src/GameObject.cpp.o -c /home/nano/Documents/inno/SDL_Minigame/src/GameObject.cpp", + "file": "/home/nano/Documents/inno/SDL_Minigame/src/GameObject.cpp", + "output": "CMakeFiles/game.dir/src/GameObject.cpp.o" +}, +{ + "directory": "/home/nano/Documents/inno/SDL_Minigame", + "command": "/usr/bin/c++ -I/usr/include/SDL -isystem /usr/include/SDL2 -std=gnu++20 -o CMakeFiles/game.dir/src/Map.cpp.o -c /home/nano/Documents/inno/SDL_Minigame/src/Map.cpp", + "file": "/home/nano/Documents/inno/SDL_Minigame/src/Map.cpp", + "output": "CMakeFiles/game.dir/src/Map.cpp.o" +}, +{ + "directory": "/home/nano/Documents/inno/SDL_Minigame", + "command": "/usr/bin/c++ -I/usr/include/SDL -isystem /usr/include/SDL2 -std=gnu++20 -o CMakeFiles/game.dir/src/TextureManager.cpp.o -c /home/nano/Documents/inno/SDL_Minigame/src/TextureManager.cpp", + "file": "/home/nano/Documents/inno/SDL_Minigame/src/TextureManager.cpp", + "output": "CMakeFiles/game.dir/src/TextureManager.cpp.o" +}, +{ + "directory": "/home/nano/Documents/inno/SDL_Minigame", + "command": "/usr/bin/c++ -I/usr/include/SDL -isystem /usr/include/SDL2 -std=gnu++20 -o CMakeFiles/game.dir/src/Vector2D.cpp.o -c /home/nano/Documents/inno/SDL_Minigame/src/Vector2D.cpp", + "file": "/home/nano/Documents/inno/SDL_Minigame/src/Vector2D.cpp", + "output": "CMakeFiles/game.dir/src/Vector2D.cpp.o" +}, +{ + "directory": "/home/nano/Documents/inno/SDL_Minigame", + "command": "/usr/bin/c++ -I/usr/include/SDL -isystem /usr/include/SDL2 -std=gnu++20 -o CMakeFiles/game.dir/src/main.cpp.o -c /home/nano/Documents/inno/SDL_Minigame/src/main.cpp", + "file": "/home/nano/Documents/inno/SDL_Minigame/src/main.cpp", + "output": "CMakeFiles/game.dir/src/main.cpp.o" +} +] \ No newline at end of file diff --git a/lib/SDL b/lib/SDL new file mode 160000 index 0000000..05eb080 --- /dev/null +++ b/lib/SDL @@ -0,0 +1 @@ +Subproject commit 05eb08053d48fea9052ad02b3d619244aeb868d3 diff --git a/lib/SDL_image b/lib/SDL_image new file mode 160000 index 0000000..abcf63a --- /dev/null +++ b/lib/SDL_image @@ -0,0 +1 @@ +Subproject commit abcf63aa71b4e3ac32120fa9870a6500ddcdcc89 diff --git a/src/ColliderComponent.h b/src/ColliderComponent.h new file mode 100644 index 0000000..2e24cf0 --- /dev/null +++ b/src/ColliderComponent.h @@ -0,0 +1,36 @@ +#pragma once +#include +#include "SDL.h" +#include "Components.h" + +class ColliderComponent : public Component +{ +public: + SDL_Rect collider; + const char* tag; + TransformComponent* transform; + + ColliderComponent(const char* tag) + { + this->tag = tag; + } + + void init() override + { + if (!entity->hasComponent()) + { + entity->addComponent(); + } + transform = &entity->getComponent(); + Game::colliders.push_back(this); + } + + void update() override + { + collider.x = transform->position.x; + collider.y = transform->position.y; + + collider.w = transform->width * transform->scale; + collider.h = transform->height * transform->scale; + } +}; \ No newline at end of file diff --git a/src/Components.h b/src/Components.h new file mode 100644 index 0000000..607d792 --- /dev/null +++ b/src/Components.h @@ -0,0 +1,8 @@ +#pragma once +#include "ECS.h" +#include "TransformComponent.h" +#include "SpriteComponent.h" +#include "KeyboardController.h" +#include "ColliderComponent.h" +#include "TileComponent.h" + diff --git a/src/Defines.h b/src/Defines.h new file mode 100644 index 0000000..da72770 --- /dev/null +++ b/src/Defines.h @@ -0,0 +1,12 @@ +#pragma once + +#define SCREEN_SIZE_HEIGHT 640 +#define SCREEN_SIZE_WIDTH 800 + +#define FPS 60 + +#define TILE_SIZE 32 + +#define MAP_SIZE_X 25 +#define MAP_SIZE_Y 20 + diff --git a/src/ECS.h b/src/ECS.h new file mode 100644 index 0000000..b9183ec --- /dev/null +++ b/src/ECS.h @@ -0,0 +1,127 @@ +#pragma once + +#include +#include +#include +#include +#include +#include + +class Component; +class Entity; + +using ComponentID = std::size_t; + +inline ComponentID getComponentTypeID() +{ + static ComponentID lastID = 0; + return lastID++; +} + +template inline ComponentID getComponentTypeID() noexcept +{ + static ComponentID typeID = getComponentTypeID(); + return typeID; +} + +constexpr std::size_t maxComponents = 32; +using ComponentBitSet = std::bitset; +using ComponentArray = std::array; + +class Component +{ + public: + Entity* entity; + + virtual void init() {} + virtual void update() {} + virtual void draw() {} + + virtual ~Component() {} +}; + +class Entity +{ + public: + void update() + { + for (auto& c : components) c->update(); + } + + void draw() + { + for (auto& c : components) c->draw(); + } + + bool isActive() const { return this->active; } + void destroy() { this->active = false; } + + template bool hasComponent() const + { + return componentBitSet[getComponentTypeID()]; + } + + template + T& addComponent(TArgs&&...mArgs) + { + T* c(new T(std::forward(mArgs)...)); + c->entity = this; + std::unique_ptr uPtr{ c }; + this->components.emplace_back(std::move(uPtr)); + + componentArray[getComponentTypeID()] = c; + componentBitSet[getComponentTypeID()] = true; + + c->init(); + return *c; + }; + + template T& getComponent() const + { + auto ptr(componentArray[getComponentTypeID()]); + return *static_cast(ptr); + } + + + private: + bool active = true; + std::vector> components; + + ComponentArray componentArray; + ComponentBitSet componentBitSet; +}; + +class Manager +{ + public: + void update() + { + for (auto& e : entities) e->update(); + } + + void draw() + { + for (auto& e : entities) e->draw(); + } + + void refresh() + { + entities.erase(std::remove_if(std::begin(entities), std::end(entities), + [](const std::unique_ptr& mEntity) + { + return !mEntity->isActive(); + }), + std::end(entities)); + } + + Entity& addEntity() + { + Entity* e = new Entity(); + std::unique_ptr uPtr{ e }; + entities.emplace_back(std::move(uPtr)); + return *e; + } + + private: + std::vector> entities; +}; diff --git a/src/Game.cpp b/src/Game.cpp new file mode 100644 index 0000000..ddab906 --- /dev/null +++ b/src/Game.cpp @@ -0,0 +1,127 @@ +#include "Game.h" +#include "TextureManager.h" +#include "Map.h" +#include "ECS.h" +#include "Components.h" +#include "Vector2D.h" + + +Map* map; +Manager manager; + +SDL_Renderer* Game::renderer = nullptr; + +SDL_Event Game::event; + +std::vector Game::colliders; + +auto& player(manager.addEntity()); +auto& wall(manager.addEntity()); + +Game::Game() +{ + +} + +Game::~Game() +{ + +} + +void Game::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 << "ERROR. Subsystem couldnt be initialized!" << std::endl; + return; + } + + window = SDL_CreateWindow(title, xpos, ypos, width, height, flags); + if (!window) { + std::cout << "ERROR: Window couldnt be created!" << std::endl; + return; + } + + renderer = SDL_CreateRenderer(window, -1, 0); + if (!renderer) { + std::cout << "ERROR: Renderer couldnt be created!" << std::endl; + return; + } + SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255); + this->isRunning = true; + + map = new Map(); + + //ecs implementation + + player.addComponent(2); + player.addComponent("assets/chicken_neutral_knight.png"); + player.addComponent(); + player.addComponent("player"); + + wall.addComponent(300.0f, 300.0f, 300, 20, 1); + wall.addComponent("assets/stone.png"); + wall.addComponent("wall"); + +} + +void Game::handleEvents() +{ + SDL_PollEvent(&event); + + switch (event.type) + { + case SDL_QUIT: this->isRunning = false; + break; + + default: + break; + } + +} + +void Game::update() +{ + Vector2D playerPos = player.getComponent().position; + + manager.refresh(); + manager.update(); + + for (auto cc : colliders) + { + if (SDL_HasIntersection(&player.getComponent().collider, &cc->collider) && strcmp(cc->tag, "player")) + { + player.getComponent().position = playerPos; + } + } +} + +void Game::render() +{ + SDL_RenderClear(renderer); + manager.draw(); + SDL_RenderPresent(renderer); +} + +void Game::clean() +{ + SDL_DestroyWindow(window); + SDL_DestroyRenderer(renderer); + SDL_Quit(); + std::cout << "Game Cleaned!" << std::endl; +} + +void Game::addTile(int id, int x, int y) +{ + auto& tile(manager.addEntity()); + tile.addComponent(x, y, 32, 32, id); +} + +bool Game::running() +{ + return isRunning; +} \ No newline at end of file diff --git a/src/Game.h b/src/Game.h new file mode 100644 index 0000000..838f66a --- /dev/null +++ b/src/Game.h @@ -0,0 +1,35 @@ +#pragma once +#include +#include +#include +#include +#include +#include + +class ColliderComponent; + +class Game +{ + public: + Game(); + ~Game(); + + void init(const char* title, int xpos, int ypos, int width, int height, bool fullscreen); + + void handleEvents(); + void update(); + void render(); + void clean(); + bool running(); + + static void addTile(int id, int x, int y); + static SDL_Renderer* renderer; + static SDL_Event event; + static std::vector colliders; + + private: + int counter = 0; + bool isRunning = false; + SDL_Window* window; +}; + diff --git a/src/GameObject.cpp b/src/GameObject.cpp new file mode 100644 index 0000000..84df9c1 --- /dev/null +++ b/src/GameObject.cpp @@ -0,0 +1,35 @@ +#include "GameObject.h" +#include "TextureManager.h" + +GameObject::GameObject(const char* texturesheet, int x, int y) +{ + this->objTexture = TextureManager::loadTexture(texturesheet); + this->xPos = x; + this->yPos = y; +} + +GameObject::~GameObject() +{ + +} + +void GameObject::update() +{ + xPos++; + yPos++; + + srcRect.h = 32; + srcRect.w = 32; + srcRect.x = 0; + srcRect.y = 0; + + destRect.h = srcRect.h *2; + destRect.w = srcRect.w *2; + destRect.x = xPos; + destRect.y = yPos; +} + +void GameObject::render() +{ + SDL_RenderCopy(Game::renderer, objTexture, &srcRect, &destRect); +} diff --git a/src/GameObject.h b/src/GameObject.h new file mode 100644 index 0000000..d8093d5 --- /dev/null +++ b/src/GameObject.h @@ -0,0 +1,20 @@ +#pragma once +#include "Game.h" + +class GameObject +{ + public: + GameObject(const char* texturesheet, int x, int y); + ~GameObject(); + + void update(); + void render(); + + private: + int xPos; + int yPos; + + SDL_Texture* objTexture; + SDL_Rect srcRect, destRect; +}; + diff --git a/src/KeyboardController.h b/src/KeyboardController.h new file mode 100644 index 0000000..77365c7 --- /dev/null +++ b/src/KeyboardController.h @@ -0,0 +1,35 @@ +#pragma once +#include "Game.h" +#include "ECS.h" +#include "Components.h" + +class KeyboardController : public Component +{ +public: + TransformComponent* transform; + const Uint8* keystates = SDL_GetKeyboardState(NULL); + + void init() override + { + transform = &entity->getComponent(); + } + + void update() override + { + transform->velocity.x = 0; + transform->velocity.y = 0; + + if (keystates[SDL_SCANCODE_UP] || keystates[SDL_SCANCODE_W]) { + transform->velocity.y = -1; + } + if (keystates[SDL_SCANCODE_LEFT] || keystates[SDL_SCANCODE_A]) { + transform->velocity.x = -1; + } + if (keystates[SDL_SCANCODE_DOWN] || keystates[SDL_SCANCODE_S]) { + transform->velocity.y = 1; + } + if (keystates[SDL_SCANCODE_RIGHT] || keystates[SDL_SCANCODE_D]) { + transform->velocity.x = 1; + } + } +}; diff --git a/src/Map.cpp b/src/Map.cpp new file mode 100644 index 0000000..5b728cd --- /dev/null +++ b/src/Map.cpp @@ -0,0 +1,31 @@ +#include "Map.h" +#include "Game.h" +#include + +Map::Map() +{ + +} + +Map::~Map() +{ +} + +void Map::loadMap(const char* path, int sizeX, int sizeY) +{ + char tile; + std::fstream mapFile; + mapFile.open(path); + + for (int y = 0; y < sizeY; y++) + { + for (int x = 0; x < sizeX; x++) + { + mapFile.get(tile); + Game::addTile(atoi(&tile), x * TILE_SIZE, y * TILE_SIZE); + mapFile.ignore(); + } + } + + mapFile.close(); +} diff --git a/src/Map.h b/src/Map.h new file mode 100644 index 0000000..74c04a1 --- /dev/null +++ b/src/Map.h @@ -0,0 +1,16 @@ +#pragma once +#include "Defines.h" + +class Map +{ + public: + Map(); + ~Map(); + + static void loadMap(const char* path, int sizeX, int sizeY); + + private: + + +}; + diff --git a/src/SpriteComponent.h b/src/SpriteComponent.h new file mode 100644 index 0000000..cd8a877 --- /dev/null +++ b/src/SpriteComponent.h @@ -0,0 +1,55 @@ +#pragma once +#include "Components.h" +#include "SDL.h" +#include "TextureManager.h" + +class SpriteComponent : public Component +{ + public: + SpriteComponent() = default; + SpriteComponent(const char* path) + { + setTexture(path); + } + + ~SpriteComponent() + { + SDL_DestroyTexture(this->texture); + } + + void setTexture(const char* path) + { + //SDL_DestroyTexture(this->texture); + this->texture = TextureManager::loadTexture(path); + } + + void init() override + { + this->transform = &entity->getComponent(); + + this->srcRect.x = this->srcRect.y = 0; + this->srcRect.w = transform->width; + this->srcRect.h = transform->height; +; + + } + + void update() override + { + this->destRect.x = this->transform->position.x; + this->destRect.y = this->transform->position.y; + this->destRect.w = transform->width * transform->scale; + this->destRect.h = transform->height * transform->scale; + } + + void draw() override + { + TextureManager::draw(this->texture, this->srcRect, this->destRect); + } + + private: + TransformComponent* transform; + SDL_Texture* texture; + SDL_Rect srcRect, destRect; + +}; diff --git a/src/TextureDict.h b/src/TextureDict.h new file mode 100644 index 0000000..cd03fed --- /dev/null +++ b/src/TextureDict.h @@ -0,0 +1,12 @@ +#pragma once +#include +#include + +std::map textureDict = +{ + {0, "assets/water.png"}, + {1, "assets/dirt.png"}, + {2, "assets/grass.png"} +}; + + diff --git a/src/TextureManager.cpp b/src/TextureManager.cpp new file mode 100644 index 0000000..d79f976 --- /dev/null +++ b/src/TextureManager.cpp @@ -0,0 +1,12 @@ +#include "TextureManager.h" + +SDL_Texture* TextureManager::loadTexture(const char* fileName) +{ + return IMG_LoadTexture(Game::renderer, fileName); + +} + +void TextureManager::draw(SDL_Texture* texture, SDL_Rect src, SDL_Rect dest) +{ + SDL_RenderCopy(Game::renderer, texture, &src, &dest); +} \ No newline at end of file diff --git a/src/TextureManager.h b/src/TextureManager.h new file mode 100644 index 0000000..83fbd63 --- /dev/null +++ b/src/TextureManager.h @@ -0,0 +1,10 @@ +#pragma once + +#include "Game.h" + +class TextureManager +{ + public: + static SDL_Texture* loadTexture(const char* fileName); + static void draw(SDL_Texture* texture, SDL_Rect src, SDL_Rect dest); +}; \ No newline at end of file diff --git a/src/TileComponent.h b/src/TileComponent.h new file mode 100644 index 0000000..c11afeb --- /dev/null +++ b/src/TileComponent.h @@ -0,0 +1,41 @@ +#pragma once +#include "ECS.h" +#include "TransformComponent.h" +#include "SDL.h" +#include "TextureDict.h" + +class TileComponent : public Component +{ +public: + TransformComponent* transform; + SpriteComponent* sprite; + + SDL_Rect tileRect; + int tileID; + const char* path; + + TileComponent() = default; + + TileComponent(int x, int y, int w, int h, int id) + { + this->tileRect.x = x; + this->tileRect.y = y; + this->tileRect.w = w; + this->tileRect.h = h; + tileID = id; + + auto it = textureDict.find(tileID)->second; + this->path = it; + } + + ~TileComponent() = default; + + void init() override + { + this->entity->addComponent(this->tileRect.x, this->tileRect.y, this->tileRect.w, this->tileRect.h, 1); + this->transform = &entity->getComponent(); + + this->entity->addComponent(this->path); + this->sprite = &entity->getComponent(); + } +}; \ No newline at end of file diff --git a/src/TransformComponent.h b/src/TransformComponent.h new file mode 100644 index 0000000..509e525 --- /dev/null +++ b/src/TransformComponent.h @@ -0,0 +1,55 @@ +#pragma once +#include "Components.h" +#include "Vector2D.h" + +class TransformComponent : public Component +{ +public: + + Vector2D position; + Vector2D velocity; + + int height = 32; + int width = 32; + int scale = 1; + + int speed = 3; + + + TransformComponent() + { + position.zero(); + } + + TransformComponent(int scale) + { + position.zero(); + this->scale = scale; + } + + TransformComponent(float x, float y) + { + this->position.x = x; + this->position.y = y; + } + + TransformComponent(float x, float y, int w, int h, int scale) + { + this->position.x = x; + this->position.y = y; + this->width = w; + this->height = h; + this->scale = scale; + } + + void init() override + { + velocity.zero(); + } + + void update() override + { + position.x += velocity.x * speed; + position.y += velocity.y * speed; + } +}; diff --git a/src/Vector2D.cpp b/src/Vector2D.cpp new file mode 100644 index 0000000..7fae1a5 --- /dev/null +++ b/src/Vector2D.cpp @@ -0,0 +1,52 @@ +#include "Vector2D.h" + +Vector2D::Vector2D() +{ + this->x = 0.0f; + this->y = 0.0f; +} + +Vector2D::Vector2D(float x, float y) +{ + this->x = x; + this->y = y; +} + +Vector2D& operator+(Vector2D& vector1, const Vector2D& vector2) +{ + vector1.x += vector2.x; + vector1.y += vector2.y; + return vector1; +} +Vector2D& operator-(Vector2D& vector1, const Vector2D& vector2) +{ + vector1.x -= vector2.x; + vector1.y -= vector2.y; + return vector1; +} +Vector2D& operator*(Vector2D& vector1, const Vector2D& vector2) +{ + vector1.x *= vector2.x; + vector1.y *= vector2.y; + return vector1; +} +Vector2D& operator/(Vector2D& vector1, const Vector2D& vector2) +{ + vector1.x /= vector2.x; + vector1.y /= vector2.y; + return vector1; +} +Vector2D& Vector2D::operator*(const int& i) +{ + this->x *= i; + this->y *= i; + + return *this; +} +Vector2D& Vector2D::zero() +{ + this->x = 0.0f; + this->y = 0.0f; + + return *this; +} diff --git a/src/Vector2D.h b/src/Vector2D.h new file mode 100644 index 0000000..8da3016 --- /dev/null +++ b/src/Vector2D.h @@ -0,0 +1,19 @@ +#pragma once + +class Vector2D +{ + public: + float x; + float y; + + Vector2D(); + Vector2D(float x, float y); + + friend Vector2D& operator+(Vector2D& vector1, const Vector2D& vector2); + friend Vector2D& operator-(Vector2D& vector1, const Vector2D& vector2); + friend Vector2D& operator*(Vector2D& vector1, const Vector2D& vector2); + friend Vector2D& operator/(Vector2D& vector1, const Vector2D& vector2); + + Vector2D& operator*(const int& i); + Vector2D& zero(); +}; \ No newline at end of file diff --git a/src/assets/Map.aseprite b/src/assets/Map.aseprite new file mode 100644 index 0000000000000000000000000000000000000000..7cb0febd00731df74f9a129949004ef298e96641 GIT binary patch literal 3672 zcmeH~X;4#F7={lbqzf`IY%*eU1*@&fW@HHaY2aDlA2&JXjBjo5K~zdYKo-} zL>2=$Qnf@RWe|i)h%9O=5ELs`phZ!V(U1V4f`;YxyHu@hXZo)*{lRzVJacl+&7Ajr z@0`1AGezj(IRk_lCeOl<0YWGY+Mnfw42VHw2FHIPjI!n;v>z{zx9ZH~c9x+m@ z)&n!QuL0IX1p-e7djXFH5PnmGe1YHYrUOqg3GY7&Bk>#vWj1jwiNGKjNChH+JRl56 z0%Cv+AOLU=*1KIwaOGy@kQ6EeluHm}MU~cFha6 z2sHD+vX6(D(bM0xT%CD>mE2G>JIGagyLmpnW6PW?G_qn+B(*3_ZBZwFCRNnRW7x%o zm#R8H-TPPIwc5ezBY-WpyG~l z>%nDLc3VeMMHfuwO=>yZ@|<>Inj}&*SXQoyX*OtYdsf}Wl= zbMyJp!!~X9=jMziHdMG3%gCWgITY4nB`M~ixJ!^OdAdHv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oJ`;^E`bryuuOY05R{> zm43v)fakNDqvk5~t^*4Vnt zX67s+{`I(qZ^bMg;u4T04Ri#F)9MN_+bt;(BLxd%x4En(M4NHm%NHRu6m~puUI@3F zKf;wV_REx&ScJG z?zNhoTy54GeTc6VwT>S%c|}0+J*}-2#+i3m7^^?f)QI2R?6;)C$nP-J-Vr;8wET}nk^#xrLXU1ss=cq+jpq8Tv>4PAN~J!Nmx#CYMZ z$Il)z-!70ArLKEkw|pk8YcSH1=D$5c!!?&y-5qj6(}38s3V~mgOAJ0KCXVK zBV|$FdmWR`@K>Nva+u%NkUw4{eFlMA>(>uY90?etjJ((4-z&1;-t~!}416;1$-pNA zpA395@c(OoAGqr&O6CXnfN~falqVd>A4S7wP%mJl|DZ{$g?Q)|&@s?|Z;`nqUr$fZ i72Z}_in2C)vvcIfUdCt3DGbW8_GWJ!Ls@@~^8Y&qI`g0a literal 0 HcmV?d00001 diff --git a/src/assets/cat.png b/src/assets/cat.png new file mode 100644 index 0000000000000000000000000000000000000000..4b52f0fcfbf1988c32395e02d385c7e205575059 GIT binary patch literal 407 zcmV;I0cie-P)I zD3?U604f0z2V`sj5I1@L69C1f+WoVbd;gWaKB7MYe!k9pD-ONJ2MYk|lcm@VI|2Y< z>p+OsB%G87qO&(AV^RZ$*|&B*Q$L|XT(HZ_oD>q;6eeA z6G4j~#(mcr&9v)l2ax?(kmAN`Kn8)`BPEFd$g1Dw?P%nHYWL)X--Sd0Zs*HKLE4BL zr$FTZ#Qlkg9e{QWVg4D%5ax1XR0EW02;z3czf&a14U;PzPmvJ-Z$J?6HzabyR@|xv zF!;Vcc@6*|->P^U;k`lE^Px%sYygZR9J=WmcMHgVHn3hUV4`pFF%SoYJy5_r4*q`LHrX$?Ap;mp^HOT!KFw9 zDUO8>6$gh5wwpr{Iu*B0MJiZ@#(_{kjxdzX z`pR<}{;nXA;CQD15C}OypP$9Qc6Lc76Bzm-`fh<+OYi@R9DH1Xw!Um>&*sqeDga9M zDFBH~hKi~(bp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ph<6oUXC7^LypNT_-*;4Al};OT@qatZ8=f z>~C0qWsuH{V-$46)DV`QL0g!00?{OPX#+uuQpqlRd_7%odGbcj*8FX@7w3qC1i=sRk5wIOA<}iZ9&n!#qElXUE09V@(sT2Hly#gS(^ub z(aB2ojkR0noV8o$nhI%UYXx7Q{ literal 0 HcmV?d00001 diff --git a/src/assets/cow.png b/src/assets/cow.png new file mode 100644 index 0000000000000000000000000000000000000000..956895f7b7a48ccb06a5297b7e16967dd7146839 GIT binary patch literal 5470 zcmV-k6`|^hP)DPKtMp)*r30^zqq)7n3!UZaA@$bsJy(qy1KgG-`~T-!{XxN@9*!^)6>bx z$>`|l`T6A@u7Z!tqT}C-EVm~^0 zd0c90O}V+AN=i8O-?vv+L#L;8a%^hI$iPHIKFG+Bzp;_k&7+unZ>yJpOG`_rsEm`7 zk~cRjxVW&8eR*43KdqpDYimf0i)mL$LaeNSiFsSZypx)mc;U*U^whM-yqK+od~#Du zeP~jssHd;5cY|MEdT?%qg@v!Lod5sroScwpX;fP@GeJQtrjUC801bhGY^9BeU0hK1 z>$`S#NeLbk7Z)8`+Wy!8029(lL_t(|ob8?aW7D=4$CI+U^xAO}JCD*dY1%C}BTZXc z2J}Lpz@Y8AvJG|_3y|G0*d6rl|Nr?~(mApsS$^cvHZEWIL3Ml_eInU9K6+)|K0PuF zCrjj-hGCd4O*>xFuxPSG50`1WOw)CmCdoLKMVihDmR{=U&i#7bGcM4>d3v}gSX#1W zfu?P8icOP4mL|8%3YK}<((n@hd7c?q@p3*AvyyYp>_O*q?)c2P#LQVY^PN3KW_>va zme$!YXESdN)3hMxmg%J-=QIu9Pm;h)(|16vmIkpj z;#%fu8kp&q0(0GU3vQ7pS8%;_j;39jrpYo*=4m=l(`A~b$&oDGFw3%U=>}T5u5j^C zOXcG1aHhfwgjZjwC<7{iIb4)rnKL7cQn4&5mWHMh_?B74QYcEH67Y&ISpxIOw`|rX zLgqlrIz5G1hTgK_H+%3c8~bK2aZ6)7=1Q;ku~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`Sen378i>WIxiv$ zfDYa_AH_zWjJlm9WEF6u79AD@?UV}L!%`HMVFtjSh?J>wO9j{1@f`rv0#7_JmxU7v zhwyu4$ta)%0hE>D>OfRdEdZGvZIN4aUXqYP)XLth8d{FC`AR{Ln%RUSO+B^|h$=+U z0_Bd4N~5)p^GZRKp&EATH^#hL&+0w{Sty7?Yk5bOQ=DwXxQC}3DsbpKtd<%9FZ^D) zsi6meW43MEmfi$FgQ)-0kq1bDYmY!HX4h2;Lm`3zc#i}LATmk_(soLlKduxr+gr&- z5GpK|nygiq9I)+Jn^BZ-nUh{oqMri5svss+uX{J`U8ncXQ7?!ZO-pQAEjzn&j&k5X z*YBQtVpE8$;CP{o?)X{MNUcporMww|sIFO_JyG*2fp#MRo&aTv=v`i;MC9!l^Ax2~ z8FGP6dJeQgRIDp~oT1)Z^KUf_FgdJGv2R?R(s-yea@qswfin z2c-&;{+v?VFRso1FT literal 0 HcmV?d00001 diff --git a/src/assets/stone.png b/src/assets/stone.png new file mode 100644 index 0000000000000000000000000000000000000000..4798d7b9a90fce6e2fb7dc8d24f5e0972ac63ef5 GIT binary patch literal 279 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^R}7d>4ZLn2z= zPD|uEtiaQH`{7KL^3P2Ny>s^~>D6Y2v}~HlzBJ_W^z~9}(>0&g+N`)f`6ROf15*Om z0wejUmDUcIJatl)I3{*}W9ZnZ^6Ko@&ple7r!V)|Bb0Te^T+|_4@m*@Em@UM2E5_O zSRd9hb46@Y%GDNAR}R1JukChlnRJL=zF)fgc{O)Iy4fa?z>ASt3@=(|&T^1yEcnit z?fT^-2VXDKuLZ?lT}-0iPMaj(v~^ZY|0$z})EA!3@!K9n=KdCcGvmDI-*c5fM=3D; b6MMj{?opTK{w{Jc|Fp{Y50D?AB zNdeWOfL!+syaQZ2_k*(`u2hQdGxQWrtUg>J#F(>uAJ%dJU&9DDl`iD~T^)e0@qsNdQY8fN`H)ZvN)-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C96odJDFGvsbI$Ge`nWZnQmT`i?uQ>Nx|SK}Z3SEtRw9;|sT8PwfyT(>oTHoT zq+OkalSFhhMLhwpvOp)+O{e?ck5nqd^Zg?tXG^{}6DG}3?;3HL5ZikNz|E8zKRLkG z!*u}Sor!>$shK4Jm$WKEz6KiTCl*1nQjcouFCZRd#|9zEx!m|i1=E{HMm7gcd<;wf|_!~{_X345cQfpR7*176>*Y5fOG)FcV&Z5@>=-Ruik}$1){g*lK5aJ6{?a zwUI0AfN}TRp9A-b=g&~Pv(NMWBabyYnxbmVpa01n^YrI6LJr4~e;kZmJ*}!2BscRO zfA;l-A39Sz8P#&ZP0Qu&ydnky-BD!$pvd(T(P_>JVW(y(VE&W0xLOXtHTJsgNkN%x w!id98%R2P_pPo)(#Z0V0Z`{b}4z7Ft1G`FeA^{UR1ONa407*qoM6N<$g1lr);Q#;t literal 0 HcmV?d00001 diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..05c2f04 --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,35 @@ +#include "Game.h" +#include "Defines.h" + +Game* game = nullptr; + +int main(int argc, char* argv[]) +{ + const int frameDelay = 1000 / FPS; + + Uint32 frameStart; + int frameTime; + + game = new Game(); + + game->init("RPG_Game", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, SCREEN_SIZE_WIDTH, SCREEN_SIZE_HEIGHT, false); + while (game->running()) + { + frameStart = SDL_GetTicks(); + + game->handleEvents(); + game->update(); + game->render(); + + frameTime = SDL_GetTicks() - frameStart; + + if (frameDelay > frameTime) + { + SDL_Delay(frameDelay - frameTime); + } + } + + game->clean(); + + return 0; +} \ No newline at end of file