diff --git a/example/Makefile b/example/Makefile deleted file mode 100644 index b07e816..0000000 --- a/example/Makefile +++ /dev/null @@ -1,27 +0,0 @@ -# Executable Setup -TARGET := Game -SRC := $(wildcard src/*.cpp) -OBJ := $(SRC:.cpp=.o) -INCLUDE_DIRS := -Iinclude -I../bld/_deps/sdl-src/include -I../bld/_deps/sdl_ttf-src -I../bld/_deps/sdl_mixer-src/include -I../bld/_deps/sdl_image-src/include -I../bld/_deps/tmxlite-src/tmxlite/include -I../include -CXXFLAGS := -std=c++14 -Wall $(INCLUDE_DIRS) - -LINK_DIRS := -L../bld -L../bin -L../bld/_deps/sdl_image-build/ -L../bld/_deps/sdl_mixer-build/ -L../bld/_deps/sdl_ttf-build -L../bld/_deps/freetype-build -KRAKEN_LIB := -lKraken -SDL_LIB := -lSDL2 -lSDL2_image -lSDL2_ttf -lSDL2_mixer -TMXLITE_LIB := -ltmxlite -lfreetype -ifeq ($(OS), Windows_NT) - TMXLITE_LIB += -lz -lbz2 -lwinmm -lbrotlidec -endif -all: $(TARGET) - -# Compile Executable -$(TARGET): $(OBJ) - $(CXX) $(CXXFLAGS) -o $@ $^ $(LINK_DIRS) $(KRAKEN_LIB) $(SDL_LIB) $(TMXLITE_LIB) - -# Build Object Files -%.o: src/%.cpp - $(CXX) $(CXXFLAGS) -c $< -o $@ - -# Clean Object and Executable Files -clean: - del $(subst /,\,$(TARGET)) $(subst /,\,$(OBJ)) diff --git a/example/assets/KdamThmorPro-Regular.ttf b/example/assets/KdamThmorPro-Regular.ttf deleted file mode 100644 index e229861..0000000 Binary files a/example/assets/KdamThmorPro-Regular.ttf and /dev/null differ diff --git a/example/assets/background.png b/example/assets/background.png deleted file mode 100644 index b779693..0000000 Binary files a/example/assets/background.png and /dev/null differ diff --git a/example/assets/room.tmx b/example/assets/room.tmx deleted file mode 100644 index 32ee703..0000000 --- a/example/assets/room.tmx +++ /dev/null @@ -1,68 +0,0 @@ - - - - - -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0, -0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0, -0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0, -0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0, -0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0, -0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/example/assets/room.tsx b/example/assets/room.tsx deleted file mode 100644 index 8987217..0000000 --- a/example/assets/room.tsx +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/example/assets/tiles.aseprite b/example/assets/tiles.aseprite deleted file mode 100644 index 04a6b5b..0000000 Binary files a/example/assets/tiles.aseprite and /dev/null differ diff --git a/example/assets/tiles.png b/example/assets/tiles.png deleted file mode 100644 index 831fc77..0000000 Binary files a/example/assets/tiles.png and /dev/null differ diff --git a/example/include/Player.hpp b/example/include/Player.hpp deleted file mode 100644 index 5a2a49d..0000000 --- a/example/include/Player.hpp +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once - -#include -#include -#include - - -class Player : public kn::Sprite { -public: - Player(kn::RenderWindow& window, std::shared_ptr texture); - ~Player() = default; - - void update(double deltaTime, const std::vector>& tiles); - -private: - std::vector moveLeft = { KNK_a, KNK_left }; - std::vector moveRight = { KNK_d, KNK_right }; - - float speed = 120.0f; -}; diff --git a/example/src/main.cpp b/example/src/main.cpp deleted file mode 100644 index 114f785..0000000 --- a/example/src/main.cpp +++ /dev/null @@ -1,61 +0,0 @@ -#include "KrakenEngine.hpp" -#include -#include - -#include "../include/Player.hpp" - -const kn::math::Vec2 kn::SCREEN_SIZE = { 320, 180 }; -float kn::GRAVITY = 980.0f; - - -int main() { - kn::RenderWindow window("Game", 4); - kn::TextureCache textureCache(window); - kn::time::Clock clock; - - kn::TileMap tileMap(window, textureCache, "assets/room.tmx"); - std::vector> obstacles; - std::vector> intractables; - for (const auto& obj : tileMap.getObjects()) { - if (obj.type == "Obstacle") { - auto newSprite = std::make_shared(window, obj.texture); - newSprite->crop = obj.crop; - newSprite->rect = obj.rect; - obstacles.push_back(newSprite); - } else if (obj.type == "Intractable") { - auto newSprite = std::make_shared(window, obj.texture); - newSprite->crop = obj.crop; - newSprite->rect = obj.rect; - intractables.push_back(newSprite); - } - } - - textureCache.create("player", { 16, 16 }, { 255, 0, 0 }); - Player player(window, textureCache.getTexture("player")); - - bool done = false; - while (!done) { - double deltaTime = clock.tick(240); - - for (const auto &event : window.getEvents()) { - if (event.type == KN_QUIT) { - done = true; - } else if (event.type == KN_KEYDOWN) { - if (event.key.keysym.sym == KNK_ESCAPE) - done = true; - } - } - - window.cls(); - - tileMap.drawAll(); - for (const auto& i : intractables) - if (player.rect.collideRect(i->rect)) - kn::draw::rect(window, i->rect, { 255, 255, 0, 255 }, 1); - player.update(deltaTime, obstacles); - - window.flip(); - } - - return EXIT_SUCCESS; -} diff --git a/example/src/player.cpp b/example/src/player.cpp deleted file mode 100644 index 99d0615..0000000 --- a/example/src/player.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include "../include/Player.hpp" -#include - - -Player::Player(kn::RenderWindow& window, std::shared_ptr texture) -: kn::Sprite(window, texture) { - position = kn::SCREEN_SIZE / 4.0f; - rect.setCenter(position); -} - -void Player::update(double deltaTime, const std::vector>& tiles) { - if (onGround) { - if (kn::input::getKeysPressed()[KNK_space]) { - velocity.y = -150; - onGround = false; - } - } else { - velocity.y += kn::GRAVITY * deltaTime; - } - - direction = kn::input::getVector(moveLeft, moveRight); - velocity.x = direction.x * speed; - moveAndCollide(deltaTime, tiles); - - window.blit(texture, crop, rect); -}