Commit 44f4ecb7 authored by Georg Schaefer's avatar Georg Schaefer
Browse files

Merge branch 'develop' into feature/starfield

parents 948eed48 aec24118
Pipeline #1 passed with stages
......@@ -6,7 +6,7 @@ linux:
stage: build
script:
- ./build_deps.sh linux
- premake5 --cc=clang gmake
- premake5 --cc=gcc gmake
- make clean
- make -j 7
tags:
......@@ -19,7 +19,7 @@ release:
stage: deploy
script:
- ./build_deps.sh linux
- premake5 --cc=clang gmake
- premake5 --cc=gcc gmake
- make clean
- make -j 7
- tar -caf linux.tar.xz assets build
......@@ -57,4 +57,4 @@ release_windows:
tags:
- Windows
only:
- develop
\ No newline at end of file
- develop
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 2.8)
project(gdw_ss15_cpp)
#use clang instead of g++
#set(CMAKE_CXX_COMPILER "/usr/bin/clang++")
#set compiler options
if (${CMAKE_CXX_COMPILER} MATCHES "clang")
set(CMAKE_CXX_FLAGS "${CMAKE_FXX_FLAGS} -stdlib=libc++")
endif ()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1y")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -g -Wall -Wextra")
################################################################################
# Libraries
################################################################################
find_package(OpenGL)
#define symbols for debug build
if (CMAKE_BUILD_TYPE STREQUAL Debug)
add_definitions(-DDEBUG)
if (NOT WIN32)
add_definitions(-DSTACKTRACE)
endif ()
endif ()
if(UNIX)
include(FindPkgConfig)
PKG_SEARCH_MODULE(SDL2 REQUIRED sdl2)
PKG_SEARCH_MODULE(SDL2MIXER REQUIRED SDL2_mixer)
include_directories(
${SDL2_INCLUDE_DIRS}
${SDL2_mixer_INCLUDE_DIRS}
)
elseif(WIN32)
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/lib/sdl2/include
${CMAKE_CURRENT_SOURCE_DIR}/lib/sdl2_mixer/x86_64-w64-mingw32/include/SDL2
)
link_directories(
${CMAKE_CURRENT_SOURCE_DIR}/lib/sdl2/x86_64-w64-mingw32/lib
${CMAKE_CURRENT_SOURCE_DIR}/lib/sdl2_mixer/x86_64-w64-mingw32/lib
)
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/lib/sdl2/x86_64-w64-mingw32/bin/SDL2.dll DESTINATION .)
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/lib/sdl2_mixer/x86_64-w64-mingw32/bin/ DESTINATION . FILES_MATCHING PATTERN *.dll)
endif()
#gli library
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/lib/gli
)
add_subdirectory(lib/gli)
#define symbols for project
add_definitions(-DGLM_SWIZZLE)
add_definitions(-DGLEW_STATIC)
find_package(OpenGL)
#glm library
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/lib/glew/include
${CMAKE_CURRENT_SOURCE_DIR}/lib/gli
${CMAKE_CURRENT_SOURCE_DIR}/lib/recastnavigation/Recast/Include
${CMAKE_CURRENT_SOURCE_DIR}/lib/recastnavigation/DetourCrowd/Include
${CMAKE_CURRENT_SOURCE_DIR}/lib/recastnavigation/Detour/Include
${CMAKE_CURRENT_SOURCE_DIR}/lib/recastnavigation/DebugUtils/Include
${CMAKE_CURRENT_SOURCE_DIR}/lib/recastnavigation/DetourTileCache/Include
${CMAKE_CURRENT_SOURCE_DIR}/lib/glm
${CMAKE_CURRENT_SOURCE_DIR}/lib/sdl2/include
${CMAKE_CURRENT_SOURCE_DIR}/lib/sdl2_mixer/x86_64-w64-mingw32/include/SDL2
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/lib/nanovg/src
)
FILE(GLOB_RECURSE clion_all_headers
${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/include/*.h
${CMAKE_CURRENT_SOURCE_DIR}/include/*.hpp
${CMAKE_CURRENT_SOURCE_DIR}/*.inl
${CMAKE_CURRENT_SOURCE_DIR}/lib/glm
)
add_definitions(-DGLM_SWIZZLE)
add_subdirectory(lib/glm)
#glew library
add_library(glew_static STATIC IMPORTED)
set_target_properties(glew_static PROPERTIES
IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/lib/glew/build/libGLEW.a
if (WIN32)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
endif ()
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/lib/glew/include
)
FILE(GLOB_RECURSE Recast_cpp
${CMAKE_CURRENT_SOURCE_DIR}/lib/recastnavigation/Recast/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/lib/recastnavigation/Recast/*.h
set(glew_SRC
${CMAKE_CURRENT_SOURCE_DIR}/lib/glew/src/glew.c
${CMAKE_CURRENT_SOURCE_DIR}/lib/glew/src/glewinfo.c
${CMAKE_CURRENT_SOURCE_DIR}/lib/glew/src/visualinfo.c
)
add_definitions(-DGLEW_STATIC)
add_library(glew_static ${glew_SRC})
add_library(Recast STATIC ${Recast_cpp})
FILE(GLOB_RECURSE Detour_cpp
${CMAKE_CURRENT_SOURCE_DIR}/lib/recastnavigation/Detour/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/lib/recastnavigation/Detour/*.h
#recastNavigation library
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/lib/recastnavigation/Recast/Include
${CMAKE_CURRENT_SOURCE_DIR}/lib/recastnavigation/Detour/Include
${CMAKE_CURRENT_SOURCE_DIR}/lib/recastnavigation/DetourCrowd/Include
${CMAKE_CURRENT_SOURCE_DIR}/lib/recastnavigation/DetourTileCache/Include
${CMAKE_CURRENT_SOURCE_DIR}/lib/recastnavigation/DebugUtils/Include
)
set(recast_SRC
${CMAKE_CURRENT_SOURCE_DIR}/lib/recastnavigation/Recast/Source/Recast.cpp
${CMAKE_CURRENT_SOURCE_DIR}/lib/recastnavigation/Recast/Source/RecastArea.cpp
${CMAKE_CURRENT_SOURCE_DIR}/lib/recastnavigation/Recast/Source/RecastAlloc.cpp
${CMAKE_CURRENT_SOURCE_DIR}/lib/recastnavigation/Recast/Source/RecastContour.cpp
${CMAKE_CURRENT_SOURCE_DIR}/lib/recastnavigation/Recast/Source/RecastFilter.cpp
${CMAKE_CURRENT_SOURCE_DIR}/lib/recastnavigation/Recast/Source/RecastLayers.cpp
${CMAKE_CURRENT_SOURCE_DIR}/lib/recastnavigation/Recast/Source/RecastMesh.cpp
${CMAKE_CURRENT_SOURCE_DIR}/lib/recastnavigation/Recast/Source/RecastMeshDetail.cpp
${CMAKE_CURRENT_SOURCE_DIR}/lib/recastnavigation/Recast/Source/RecastRasterization.cpp
${CMAKE_CURRENT_SOURCE_DIR}/lib/recastnavigation/Recast/Source/RecastRegion.cpp
)
add_library(Recast ${recast_SRC})
set(detour_SRC
${CMAKE_CURRENT_SOURCE_DIR}/lib/recastnavigation/Detour/Source/DetourAlloc.cpp
${CMAKE_CURRENT_SOURCE_DIR}/lib/recastnavigation/Detour/Source/DetourCommon.cpp
${CMAKE_CURRENT_SOURCE_DIR}/lib/recastnavigation/Detour/Source/DetourNavMesh.cpp
${CMAKE_CURRENT_SOURCE_DIR}/lib/recastnavigation/Detour/Source/DetourNavMeshBuilder.cpp
${CMAKE_CURRENT_SOURCE_DIR}/lib/recastnavigation/Detour/Source/DetourNavMeshQuery.cpp
${CMAKE_CURRENT_SOURCE_DIR}/lib/recastnavigation/Detour/Source/DetourNode.cpp
)
add_library(Detour ${detour_SRC})
set(detourcrowd_SRC
${CMAKE_CURRENT_SOURCE_DIR}/lib/recastnavigation/DetourCrowd/Source/DetourPathCorridor.cpp
${CMAKE_CURRENT_SOURCE_DIR}/lib/recastnavigation/DetourCrowd/Source/DetourLocalBoundary.cpp
${CMAKE_CURRENT_SOURCE_DIR}/lib/recastnavigation/DetourCrowd/Source/DetourObstacleAvoidance.cpp
${CMAKE_CURRENT_SOURCE_DIR}/lib/recastnavigation/DetourCrowd/Source/DetourPathQueue.cpp
${CMAKE_CURRENT_SOURCE_DIR}/lib/recastnavigation/DetourCrowd/Source/DetourCrowd.cpp
${CMAKE_CURRENT_SOURCE_DIR}/lib/recastnavigation/DetourCrowd/Source/DetourProximityGrid.cpp
)
add_library(DetourCrowd ${detourcrowd_SRC})
add_library(Detour STATIC ${Detour_cpp})
FILE(GLOB_RECURSE DetourCrowd_cpp
${CMAKE_CURRENT_SOURCE_DIR}/lib/recastnavigation/DetourCrowd/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/lib/recastnavigation/DetourCrowd/*.h
set(debugutils_SRC
${CMAKE_CURRENT_SOURCE_DIR}/lib/recastnavigation/DebugUtils/Source/DebugDraw.cpp
${CMAKE_CURRENT_SOURCE_DIR}/lib/recastnavigation/DebugUtils/Source/DetourDebugDraw.cpp
${CMAKE_CURRENT_SOURCE_DIR}/lib/recastnavigation/DebugUtils/Source/RecastDebugDraw.cpp
${CMAKE_CURRENT_SOURCE_DIR}/lib/recastnavigation/DebugUtils/Source/RecastDump.cpp
)
add_library(DebugUtils ${debugutils_SRC})
add_library(DetourCrowd STATIC ${DetourCrowd_cpp})
FILE(GLOB_RECURSE DebugUtils
${CMAKE_CURRENT_SOURCE_DIR}/lib/recastnavigation/DebugUtils/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/lib/recastnavigation/DebugUtils/*.h
#nanovg library
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/lib/nanovg/src)
set(nanovg_SRC
${CMAKE_CURRENT_SOURCE_DIR}/lib/nanovg/src/nanovg.c
)
add_library(nanovg ${nanovg_SRC})
add_library(DebugUtils STATIC ${DebugUtils})
################################################################################
# Project settings
################################################################################
FILE(GLOB_RECURSE nanovg_src
${CMAKE_CURRENT_SOURCE_DIR}/lib/nanovg/src/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/lib/nanovg/src/*.c
${CMAKE_CURRENT_SOURCE_DIR}/lib/nanovg/src/*.h
#set compiler options
if (${CMAKE_CXX_COMPILER} MATCHES "clang")
set(CMAKE_CXX_FLAGS "${CMAKE_FXX_FLAGS} -stdlib=libc++")
endif ()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1y")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -g -Wall -Wextra")
#define symbols for debug build
if (CMAKE_BUILD_TYPE STREQUAL Debug)
add_definitions(-DDEBUG)
if (NOT MSVC)
add_definitions(-DSTACKTRACE)
endif ()
endif ()
#include directory of project
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/include
)
add_library(nanovg STATIC ${nanovg_src})
#project files to compile
file(GLOB_RECURSE project_SRC
${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp
)
file(GLOB_RECURSE project_HDR
${CMAKE_CURRENT_SOURCE_DIR}/include/*.h
${CMAKE_CURRENT_SOURCE_DIR}/include/*.hpp
)
file(GLOB_RECURSE project_INL
${CMAKE_CURRENT_SOURCE_DIR}/*.inl
)
#libraries to link
set(LINKED_LIBRARIES
nanovg
DebugUtils
DetourCrowd
Detour
Recast
SDL2
SDL2main
SDL2_mixer
GL
c++
c++abi
glew_static
nanovg
DebugUtils
DetourCrowd
Detour
Recast
SDL2main
SDL2
SDL2_mixer
)
add_executable(Game ${clion_all_headers})
target_link_libraries(Game ${LINKED_LIBRARIES} glew_static)
if(UNIX)
set( LINKED_LIBRARIES
${LINKED_LIBRARIES}
GL
c++
c++abi)
elseif(WIN32)
set( LINKED_LIBRARIES
imagehlp
mingw32
${LINKED_LIBRARIES}
opengl32
-static-libgcc
-static-libstdc++)
endif()
#build executable and then link to the libraries
add_executable(Game ${project_SRC} ${project_HDR} ${project_INL})
target_link_libraries(Game ${LINKED_LIBRARIES})
#copy assets to the executable destination
file(COPY assets DESTINATION .)
......@@ -17,22 +17,25 @@ victim_mass : 1
map_load_timer : 0
test_ui : false
mapGenDebug : false
player_move_left_key : A
player_move_left_key2 : Left
player_move_left_cbutton : LEFT
player_move_left_caxis : RIGHTX
player_move_right_key : D
player_move_right_key2 : Right
player_move_right_cbutton : RIGHT
player_move_right_caxis : RIGHTX
beam_normal_key : Q
beam_normal_mbutton : Left
beam_normal_caxis : LEFTTRIGGER
beam_inverse_key : E
beam_inverse_mbutton : Right
beam_inverse_caxis : RIGHTTRIGGER
place_item_key : Space
place_item_mbutton : Middle
place_item_cbutton : A
state_switch_key : Escape
state_switch_cbutton : START
move_left_key1 : a
move_left_key2 : left
move_left_controller_axis : leftx
move_right_key1 : d
move_right_key2 : right
move_right_controller_axis : leftx_negative
beam_normal_mouse_button : left
beam_normal_controller_axis : lefttrigger
beam_inverse_mouse_button : right
beam_inverse_controller_axis : righttrigger
place_item_key1 : Space
place_item_mouse_button : Middle
place_item_controller_button : a
test_key1 : t
test_key2 : p
test_mouse_button : middle
test_controller_button : back
test_controller_axis : righty
state_switch_key1 : Escape
state_switch_controller_button : START
button_click_mouse_button : left
button_click_controller_button : a
Simple DirectMedia Layer
Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
Simple DirectMedia Layer
Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
This diff is collapsed.
......@@ -22,7 +22,7 @@ namespace gdw {
virtual std::shared_ptr<const asset> load_asset(const std::string& name) const = 0;
virtual std::string native_name(const std::string& name) const {
virtual std::string native_name(const std::string&) const {
return std::string();
}
};
......
......@@ -7,7 +7,7 @@
#include <audio/music.hpp>
#include <audio/music_manager.hpp>
#include <audio/sound.hpp>
#include <audio/sound_file.hpp>
#include <audio/sound_manager.hpp>
namespace gdw {
......
......@@ -4,13 +4,13 @@
#include <SDL_mixer.h>
namespace gdw {
class sound {
class sound_file {
private:
Mix_Chunk* impl_;
public:
sound(const char* mem, int size);
~sound();
sound_file(const char* mem, int size);
~sound_file();
Mix_Chunk* get() const;
};
......
#ifndef __GDW_SOUND_MANAGER_HPP__
#define __GDW_SOUND_MANAGER_HPP__
#include <audio/sound.hpp>
#include <audio/sound_file.hpp>
#include <util/cached_resource_manager.hpp>
namespace gdw{
......@@ -9,13 +9,13 @@ namespace gdw{
}
namespace gdw {
using sound_ptr = std::shared_ptr<const sound>;
using sound_ptr = std::shared_ptr<const sound_file>;
class sound_manager: public cached_resource_manager<const sound, sound_manager> {
class sound_manager: public cached_resource_manager<const sound_file, sound_manager> {
private:
engine& engine_;
friend class cached_resource_manager<const sound, sound_manager>;
friend class cached_resource_manager<const sound_file, sound_manager>;
public:
sound_manager(engine& engine);
......
//****************************************
// by Benjamin 'Albsi' Albsmeier
// input/input.cpp for GDW SS15
//****************************************
#ifndef __CONTROLLER_HPP__
#define __CONTROLLER_HPP__
#include <unordered_map>
#include <SDL.h>
#include <input/input.hpp>
#include <input/input_mapping.hpp>
namespace gdw{
struct axis_struct{
bool changed = false;
int down = 0;
bool released = false;
};
class controller{
private:
input *input_;
static float constexpr axis_max_ = 32767.f;
static float constexpr axis_dead_zone_ = .3f;
SDL_GameController *sdl_controller_;
std::unordered_map<int, bool> button_map_;
std::unordered_map<int, bool> button_released_map_;
std::shared_ptr<std::unordered_map<int, axis_struct>> axis_map_;
public:
controller(input *input, SDL_GameController* sdl_controller);
~controller();
void reset();
void update(float delta);
SDL_GameController* sdl_controller();
std::shared_ptr<std::unordered_map<int, axis_struct>> axis_map();
bool down(SDL_GameControllerButton button_id);
bool pressed(SDL_GameControllerButton button_id);
bool released(SDL_GameControllerButton button_id);
bool pressed_axis(SDL_GameControllerAxis axis_id);
bool down_axis(SDL_GameControllerAxis axis_id);
bool released_axis(SDL_GameControllerAxis axis_id);
float axis(SDL_GameControllerAxis axis);
void up_event(const SDL_ControllerButtonEvent &e);
void down_event(const SDL_ControllerButtonEvent &e);
void axis_event(const SDL_ControllerAxisEvent &e) noexcept {/*handelt on another way, see: float controllerAxis(SDL_GameControllerAxis axis, int nr)*/};
};
}
#endif
//****************************************
// by Benjamin 'Albsi' Albsmeier
// input/input.cpp for GDW SS15
//****************************************
#ifndef __CONTROLLER_MANAGER_HPP__
#define __CONTROLLER_MANAGER_HPP__
#include <unordered_map>
#include <SDL.h>
#include <input/input.hpp>
#include <input/controller.hpp>
namespace gdw{
/*enum class controllerCursor {
none,
left,
right
};*/
class controller_manager{
private:
engine &engine_;
input *input_;
static float constexpr speed_ = 800.f;
std::string controller_database_path_ = "input/gamecontrollerdb.txt";
std::shared_ptr<const asset> controller_database_;
std::unordered_map<int, std::shared_ptr<gdw::controller>> controllers_;
//std::unordered_map<int, bool> used_controllers_;
//int controllerNr = -1;
//bool controllerUse = false;
//controllerCursor ccursor = controllerCursor::none;
//controllerCursor getCCursorFromName(std::string name);
int first_controller();
public:
controller_manager(input *input, engine& engine);
~controller_manager();
void update(float delta);
void reset();
//RETURN
bool pressed(SDL_GameControllerButton button_id, int controller_id);
bool down(SDL_GameControllerButton button_id, int controller_id);
bool released(SDL_GameControllerButton button_id, int controller_id);
bool pressed_axis(SDL_GameControllerAxis axis_id, int controller_id);
bool down_axis(SDL_GameControllerAxis axis_id, int controller_id);
bool released_axis(SDL_GameControllerAxis axis_id, int controller_id);
float axis(SDL_GameControllerAxis axis, int controller_id);
int controller_count();
bool is_controller(int controller_id);
std::shared_ptr<gdw::controller> controller(int controller_id);
//EVENT
void up_event(const SDL_ControllerButtonEvent &e);
void down_event(const SDL_ControllerButtonEvent &e);
void added(const SDL_ControllerDeviceEvent &e);
void removed(const SDL_ControllerDeviceEvent &e);
//FOLLOWED METHODES ARE UNUSED
void axis_event(const SDL_ControllerAxisEvent &e) noexcept {/*handelt on another way, see: float controllerAxis(SDL_GameControllerAxis axis, int nr)*/};
void remapped(const SDL_ControllerDeviceEvent &e) noexcept {log << "input: controllerRemapped was triggerd but is not handelt" << std::endl;};
void joy_added(const SDL_JoyDeviceEvent &e) noexcept {/*controllerAdded*/};
void joy_removed(const SDL_JoyDeviceEvent &e) noexcept {/*controllerRemoved*/};
void joy_hat(const SDL_JoyHatEvent &e) noexcept {/*controllerDown / controllerUp*/};
void joy_down(const SDL_JoyButtonEvent &e) noexcept {/*controllerDown*/};
void joy_up(const SDL_JoyButtonEvent &e) noexcept {/*controllerUp*/};
void joy_ball(const SDL_JoyBallEvent &e) noexcept {log << "input: joyBall was triggerd but is not handelt" << std::endl;};
void joy_axis(const SDL_JoyAxisEvent &e) noexcept {/*controllerAxis*/};
};
}
#endif
//****************************************
// by Benjamin 'Albsi' Albsmeier
// input/input.hpp for GDW SS15
// mouse, keyboard input
//****************************************
#ifndef __INPUT_HPP__
#define __INPUT_HPP__
#include <memory>
#include <map>
#include <unordered_map>
#include <vector>
#include <SDL.h>
#include <glm/glm.hpp>
#include <asset/asset.hpp>
#include <core/engine.hpp>
#include <util/logger.hpp>
#ifndef __INPUT_HPP__
#define __INPUT_HPP__
namespace gdw{
struct controller {
SDL_GameController *sdlController;
int controllerNr = -1;
std::unordered_map<int, bool> controllerMap;
std::unordered_map<int, bool> controllerReleasedMap;
bool active = false;
};
//if you add here, add also a mapping in makeMapping() in input.cpp
enum class inputMapping {
state_switch,
player_move_left,
player_move_right,
beam_normal,
beam_inverse,
place_item,
button_click
};
struct inputMappingStruct {
unsigned int type = 0;
bool negativAxis = false;
SDL_Keycode keyCode1 = 0;
SDL_Keycode keyCode2 = 0;
int mbuttonCode = -1;
SDL_GameControllerButton cbuttonCode