Skip to content

Commit

Permalink
Update ASSET_DIR, README and installation procedure
Browse files Browse the repository at this point in the history
  • Loading branch information
lchsk committed Aug 13, 2018
1 parent b7a7d2d commit ca1d85e
Show file tree
Hide file tree
Showing 35 changed files with 45 additions and 7 deletions.
19 changes: 19 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})

Expand All @@ -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)
23 changes: 20 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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

Expand Down
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
10 changes: 6 additions & 4 deletions src/resources.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<sf::Texture> tex = std::make_unique<sf::Texture>();

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);
}

Expand All @@ -20,18 +22,18 @@ void Resources::load() {
for (const std::string &filename : files) {
std::unique_ptr<sf::Texture> tex = std::make_unique<sf::Texture>();

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();
Expand Down

0 comments on commit ca1d85e

Please sign in to comment.