From ca1d85eef20fa0e12e21aee48d10a5e2e48f837b Mon Sep 17 00:00:00 2001 From: lchsk Date: Mon, 13 Aug 2018 22:22:40 +0100 Subject: [PATCH] Update ASSET_DIR, README and installation procedure --- CMakeLists.txt | 19 +++++++++++++++ README.md | 23 +++++++++++++++--- .../CaviarDreams.ttf | Bin .../button_brown.png | Bin .../button_brown_pressed.png | Bin .../crosshair.png | Bin {assets => knight_general_assets}/cursor.png | Bin {assets => knight_general_assets}/earth_1.png | Bin {assets => knight_general_assets}/earth_2.png | Bin {assets => knight_general_assets}/gold.png | Bin {assets => knight_general_assets}/grass_1.png | Bin {assets => knight_general_assets}/grass_2.png | Bin .../knight_armored_right.png | Bin .../knight_special_right.png | Bin .../knight_warrior_right.png | Bin .../light_earth_1.png | Bin .../light_earth_2.png | Bin .../light_water_1.png | Bin .../light_water_2.png | Bin .../little_town_orchestral.ogg | Bin .../purple_1.png | Bin .../purple_2.png | Bin .../skeleton_armored_right.png | Bin .../skeleton_special_right.png | Bin .../skeleton_warrior_right.png | Bin {assets => knight_general_assets}/stone_1.png | Bin {assets => knight_general_assets}/stone_2.png | Bin {assets => knight_general_assets}/stone_3.png | Bin {assets => knight_general_assets}/stone_4.png | Bin {assets => knight_general_assets}/timber.png | Bin {assets => knight_general_assets}/tree_1.png | Bin {assets => knight_general_assets}/tree_2.png | Bin {assets => knight_general_assets}/water_1.png | Bin {assets => knight_general_assets}/water_2.png | Bin src/resources.cpp | 10 +++++--- 35 files changed, 45 insertions(+), 7 deletions(-) rename {assets => knight_general_assets}/CaviarDreams.ttf (100%) rename {assets => knight_general_assets}/button_brown.png (100%) rename {assets => knight_general_assets}/button_brown_pressed.png (100%) rename {assets => knight_general_assets}/crosshair.png (100%) rename {assets => knight_general_assets}/cursor.png (100%) rename {assets => knight_general_assets}/earth_1.png (100%) rename {assets => knight_general_assets}/earth_2.png (100%) rename {assets => knight_general_assets}/gold.png (100%) rename {assets => knight_general_assets}/grass_1.png (100%) rename {assets => knight_general_assets}/grass_2.png (100%) rename {assets => knight_general_assets}/knight_armored_right.png (100%) rename {assets => knight_general_assets}/knight_special_right.png (100%) rename {assets => knight_general_assets}/knight_warrior_right.png (100%) rename {assets => knight_general_assets}/light_earth_1.png (100%) rename {assets => knight_general_assets}/light_earth_2.png (100%) rename {assets => knight_general_assets}/light_water_1.png (100%) rename {assets => knight_general_assets}/light_water_2.png (100%) rename {assets => knight_general_assets}/little_town_orchestral.ogg (100%) rename {assets => knight_general_assets}/purple_1.png (100%) rename {assets => knight_general_assets}/purple_2.png (100%) rename {assets => knight_general_assets}/skeleton_armored_right.png (100%) rename {assets => knight_general_assets}/skeleton_special_right.png (100%) rename {assets => knight_general_assets}/skeleton_warrior_right.png (100%) rename {assets => knight_general_assets}/stone_1.png (100%) rename {assets => knight_general_assets}/stone_2.png (100%) rename {assets => knight_general_assets}/stone_3.png (100%) rename {assets => knight_general_assets}/stone_4.png (100%) rename {assets => knight_general_assets}/timber.png (100%) rename {assets => knight_general_assets}/tree_1.png (100%) rename {assets => knight_general_assets}/tree_2.png (100%) rename {assets => knight_general_assets}/water_1.png (100%) rename {assets => knight_general_assets}/water_2.png (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 53dcc2c..6837284 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,6 +18,22 @@ set(EXECUTABLE_NAME ${PROJECT_NAME}) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_FLAGS "-Wall -pedantic") +# cpack + +set(CPACK_PACKAGE_CONTACT "lchsk.com") +set(CPACK_GENERATOR "DEB;ZIP;") +set(CPACK_PACKAGE_DESCRIPTION, "Turn-based strategy game") +set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION}) + +# deb stuff +set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://lchsk.com") +set(CPACK_DEBIAN_PACKAGE_DEPENDS "libsfml-dev") +set(CPACK_DEBIAN_PACKAGE_MAINTAINER "lchsk.com") + +include(CPack) + +# end cpack + file(GLOB SOURCES "src/*.hpp" "src/*.cpp") add_executable(${PROJECT_NAME} ${SOURCES}) @@ -28,3 +44,6 @@ message(STATUS "SFML_VERSION: ${SFML_VERSION}") include_directories(${SFML_INCLUDE_DIR}) target_link_libraries(${EXECUTABLE_NAME} ${SFML_LIBRARIES}) + +install(TARGETS knight-general DESTINATION games) +install(DIRECTORY knight_general_assets DESTINATION games) diff --git a/README.md b/README.md index c6b7f7c..da1d24e 100644 --- a/README.md +++ b/README.md @@ -14,9 +14,26 @@ Knight General is inspired by classic turn-based strategy games. The aim of the - difficult AI opponent - several types of resources (gold, stone, timber, trees) which can be collected and sold to receive coins -## Dependencies +## Installation + +1. Make sure you have SFML library installed: on Ubuntu `sudo apt install libsfml-dev` + +2. Download DEB or ZIP package. + +3. Install DEB package: `sudo apt install ./knight-general-0.1.0-Linux.deb` + +4. Go to directory with `knight-general` executable (possibly `/usr/games`), and run `./knight-general` + +5. If you're using the ZIP archive, unzip it, then find `knight-general` executable and run it. + +## Requirements + +Tested on Ubuntu 17.10 but it should be easy to build on other free systems and probably on Mac/Windows as well. + +### Dependencies - SFML (tested with v2.4.2) +- modern C++ compiler, supporting at least C++14 ## Building from source @@ -26,7 +43,7 @@ Install dependencies on Ubuntu: ``` 1. Clone the repo -2. mkdir build && cp -r assets/ build/ && cd build +2. mkdir build && cp -r knight_general_assets/ build/ && cd build 3. cmake .. 4. make -j 5. ./knight-general @@ -46,7 +63,7 @@ Install dependencies on Ubuntu: ### Music -- https://opengameart.org/content/adventure-begins by bart (GPL 3.0** +- https://opengameart.org/content/adventure-begins by bart (GPL 3.0) ### Fonts diff --git a/assets/CaviarDreams.ttf b/knight_general_assets/CaviarDreams.ttf similarity index 100% rename from assets/CaviarDreams.ttf rename to knight_general_assets/CaviarDreams.ttf diff --git a/assets/button_brown.png b/knight_general_assets/button_brown.png similarity index 100% rename from assets/button_brown.png rename to knight_general_assets/button_brown.png diff --git a/assets/button_brown_pressed.png b/knight_general_assets/button_brown_pressed.png similarity index 100% rename from assets/button_brown_pressed.png rename to knight_general_assets/button_brown_pressed.png diff --git a/assets/crosshair.png b/knight_general_assets/crosshair.png similarity index 100% rename from assets/crosshair.png rename to knight_general_assets/crosshair.png diff --git a/assets/cursor.png b/knight_general_assets/cursor.png similarity index 100% rename from assets/cursor.png rename to knight_general_assets/cursor.png diff --git a/assets/earth_1.png b/knight_general_assets/earth_1.png similarity index 100% rename from assets/earth_1.png rename to knight_general_assets/earth_1.png diff --git a/assets/earth_2.png b/knight_general_assets/earth_2.png similarity index 100% rename from assets/earth_2.png rename to knight_general_assets/earth_2.png diff --git a/assets/gold.png b/knight_general_assets/gold.png similarity index 100% rename from assets/gold.png rename to knight_general_assets/gold.png diff --git a/assets/grass_1.png b/knight_general_assets/grass_1.png similarity index 100% rename from assets/grass_1.png rename to knight_general_assets/grass_1.png diff --git a/assets/grass_2.png b/knight_general_assets/grass_2.png similarity index 100% rename from assets/grass_2.png rename to knight_general_assets/grass_2.png diff --git a/assets/knight_armored_right.png b/knight_general_assets/knight_armored_right.png similarity index 100% rename from assets/knight_armored_right.png rename to knight_general_assets/knight_armored_right.png diff --git a/assets/knight_special_right.png b/knight_general_assets/knight_special_right.png similarity index 100% rename from assets/knight_special_right.png rename to knight_general_assets/knight_special_right.png diff --git a/assets/knight_warrior_right.png b/knight_general_assets/knight_warrior_right.png similarity index 100% rename from assets/knight_warrior_right.png rename to knight_general_assets/knight_warrior_right.png diff --git a/assets/light_earth_1.png b/knight_general_assets/light_earth_1.png similarity index 100% rename from assets/light_earth_1.png rename to knight_general_assets/light_earth_1.png diff --git a/assets/light_earth_2.png b/knight_general_assets/light_earth_2.png similarity index 100% rename from assets/light_earth_2.png rename to knight_general_assets/light_earth_2.png diff --git a/assets/light_water_1.png b/knight_general_assets/light_water_1.png similarity index 100% rename from assets/light_water_1.png rename to knight_general_assets/light_water_1.png diff --git a/assets/light_water_2.png b/knight_general_assets/light_water_2.png similarity index 100% rename from assets/light_water_2.png rename to knight_general_assets/light_water_2.png diff --git a/assets/little_town_orchestral.ogg b/knight_general_assets/little_town_orchestral.ogg similarity index 100% rename from assets/little_town_orchestral.ogg rename to knight_general_assets/little_town_orchestral.ogg diff --git a/assets/purple_1.png b/knight_general_assets/purple_1.png similarity index 100% rename from assets/purple_1.png rename to knight_general_assets/purple_1.png diff --git a/assets/purple_2.png b/knight_general_assets/purple_2.png similarity index 100% rename from assets/purple_2.png rename to knight_general_assets/purple_2.png diff --git a/assets/skeleton_armored_right.png b/knight_general_assets/skeleton_armored_right.png similarity index 100% rename from assets/skeleton_armored_right.png rename to knight_general_assets/skeleton_armored_right.png diff --git a/assets/skeleton_special_right.png b/knight_general_assets/skeleton_special_right.png similarity index 100% rename from assets/skeleton_special_right.png rename to knight_general_assets/skeleton_special_right.png diff --git a/assets/skeleton_warrior_right.png b/knight_general_assets/skeleton_warrior_right.png similarity index 100% rename from assets/skeleton_warrior_right.png rename to knight_general_assets/skeleton_warrior_right.png diff --git a/assets/stone_1.png b/knight_general_assets/stone_1.png similarity index 100% rename from assets/stone_1.png rename to knight_general_assets/stone_1.png diff --git a/assets/stone_2.png b/knight_general_assets/stone_2.png similarity index 100% rename from assets/stone_2.png rename to knight_general_assets/stone_2.png diff --git a/assets/stone_3.png b/knight_general_assets/stone_3.png similarity index 100% rename from assets/stone_3.png rename to knight_general_assets/stone_3.png diff --git a/assets/stone_4.png b/knight_general_assets/stone_4.png similarity index 100% rename from assets/stone_4.png rename to knight_general_assets/stone_4.png diff --git a/assets/timber.png b/knight_general_assets/timber.png similarity index 100% rename from assets/timber.png rename to knight_general_assets/timber.png diff --git a/assets/tree_1.png b/knight_general_assets/tree_1.png similarity index 100% rename from assets/tree_1.png rename to knight_general_assets/tree_1.png diff --git a/assets/tree_2.png b/knight_general_assets/tree_2.png similarity index 100% rename from assets/tree_2.png rename to knight_general_assets/tree_2.png diff --git a/assets/water_1.png b/knight_general_assets/water_1.png similarity index 100% rename from assets/water_1.png rename to knight_general_assets/water_1.png diff --git a/assets/water_2.png b/knight_general_assets/water_2.png similarity index 100% rename from assets/water_2.png rename to knight_general_assets/water_2.png diff --git a/src/resources.cpp b/src/resources.cpp index bba39be..7bbe535 100644 --- a/src/resources.cpp +++ b/src/resources.cpp @@ -4,13 +4,15 @@ namespace ld { + const std::string ASSETS_DIR = "knight_general_assets/"; + void Resources::load() { for (const ld::TileConfig &tc : TILES) { std::unique_ptr tex = std::make_unique(); const auto &filename = tc.get_filename(); - if (!tex->loadFromFile("assets/" + filename)) { + if (!tex->loadFromFile(ASSETS_DIR + filename)) { throw std::runtime_error("Unable to load " + filename); } @@ -20,18 +22,18 @@ void Resources::load() { for (const std::string &filename : files) { std::unique_ptr tex = std::make_unique(); - if (!tex->loadFromFile("assets/" + filename)) { + if (!tex->loadFromFile(ASSETS_DIR + filename)) { throw std::runtime_error("Unable to load " + filename); } textures[filename] = std::move(tex); } - if (!basic_font_.loadFromFile("assets/CaviarDreams.ttf")) { + if (!basic_font_.loadFromFile(ASSETS_DIR + "CaviarDreams.ttf")) { std::cout << "No font found\n"; } - if (music_.openFromFile("assets/little_town_orchestral.ogg")) { + if (music_.openFromFile(ASSETS_DIR + "little_town_orchestral.ogg")) { music_.setVolume(100); music_.setLoop(true); music_.play();