-
Notifications
You must be signed in to change notification settings - Fork 5
Installation
Madour edited this page Oct 9, 2020
·
9 revisions
There are 2 ways to use NasNas in your project.
- Copy the source files into your project folder
- Link the static or dynamic libraries
The game framework is still in development, that's why I don't recommend using the static or dynamic libraries
(tested on Window and Linux)
- Make sure you have SFML2 installed
- Clone the NasNas repository somewhere on your computer
- Create somewhere else a new folder with the following folders:
NewProject
├─ include # contains header files
└─ src # contains source files
- Copy
NasNas/cmake
toNewProject
. - Copy
NasNas/include/NasNas
toNewProject/include
. - Copy
NasNas/src/NasNas
toNewProject/src
. - Copy the
NasNas.h
file to theNewProject
folder. - Create the following
CMakeLists.txt
file in theNewProject
folder :
cmake_minimum_required(VERSION 3.10)
project(NewProject)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY bin)
if (WIN32)
set(SFML_ROOT C:/SFML) # specify here the install location of SFML
set(SFML_STATIC_LIBRARIES TRUE)
find_package(SFML COMPONENTS graphics audio PATHS ${SFML_ROOT}/lib/cmake/ )
else()
find_package(SFML COMPONENTS graphics audio )
endif()
# the following variables can be set to FALSE to exclude the associated module
set(NASNAS_BUILD_RESLIB TRUE)
set(NASNAS_BUILD_ECS TRUE)
set(NASNAS_BUILD_TILEMAPPING TRUE)
set(NASNAS_BUILD_UI TRUE)
include(cmake/NasNas.cmake)
add_executable(NewProject
NasNas.h ${NasNas_Src} ${NasNas_Inc}
main.cpp
)
target_include_directories(NewProject PRIVATE include)
target_link_libraries(NewProject sfml-graphics sfml-audio)
- Create the following
main.cpp
in theNewProject
folder :
// Minimal working example
#include "NasNas.h"
class Game : public ns::App {
public:
Game() : ns::App("NewProject", 720, 480) {}
void update() override {}
};
int main() {
Game g;
g.run();
return 0;
}
- Make sure CMake is installed, configured and added to your PATH
- Make sure your compiler is added to your PATH
- Open a command prompt and run the following commands :
mkdir build && cd build
cmake ..
cmake --build . -j4
If the build is successful, you should find the executable file under build/bin
.