Skip to content

Commit

Permalink
Merge pull request #53 from YGNI-RType/feat/libdev-3d
Browse files Browse the repository at this point in the history
Multiple players moving in the appartment with third person camera
  • Loading branch information
Arcod7 authored Oct 30, 2024
2 parents 5f8646d + a8a7b29 commit 7c73329
Show file tree
Hide file tree
Showing 77 changed files with 1,751 additions and 39 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ r-type_server

## tester
Rtype
POC_3D

# Created by https://www.toptal.com/developers/gitignore/api/cmake,macos,c++,conan,visualstudiocode
# Edit at https://www.toptal.com/developers/gitignore?templates=cmake,macos,c++,conan,visualstudiocode
Expand Down
3 changes: 3 additions & 0 deletions examples/POC_3D/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/build/*
!/build/.gitkeep

65 changes: 65 additions & 0 deletions examples/POC_3D/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
cmake_minimum_required(VERSION 3.10)

project(R-Type)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED YES)
set(CMAKE_CXX_EXTENSIONS NO)
set(CMAKE_DEBUG_POSTFIX d)


# set(VCPKG_SHOULD_NOT_UPDATE 1)
include(../../cmake/automate-vcpkg.cmake)
vcpkg_bootstrap()
vcpkg_install_packages(raylib stduuid nlohmann-json)

if(CMAKE_BUILD_TYPE STREQUAL "Debug")
if (MSVC)
add_compile_options(/D_ITERATOR_DEBUG_LEVEL=0)
endif()
# The static permits to enter the functions, avoid settings the path to a .dll etc...
find_library(GEngine_LIB NAMES GEngine-sd PATHS ../../build/Debug ../../build)
# find_library(GEngine_LIB NAMES GEngined PATHS ../../build/Debug ../../build)
else()
find_library(GEngine_LIB NAMES GEngine-sd PATHS ../../build/Release ../../build)
endif()

file(GLOB_RECURSE SOURCES source/*.cpp)
file(GLOB_RECURSE HEADERS include/*.h)

find_package(raylib CONFIG REQUIRED)
find_package(glfw3 CONFIG REQUIRED)

include_directories(include)
include_directories(../../include)

add_executable(r-type_client ${SOURCES} ${HEADERS})
add_executable(r-type_server ${SOURCES} ${HEADERS})

if(WIN32)
target_link_libraries(r-type_client PRIVATE ${GEngine_LIB} raylib wsock32 ws2_32)
target_link_libraries(r-type_server PRIVATE ${GEngine_LIB} raylib wsock32 ws2_32)
else()
target_link_libraries(r-type_client PRIVATE ${GEngine_LIB} raylib glfw)
target_link_libraries(r-type_server PRIVATE ${GEngine_LIB} raylib glfw)
endif()

set_target_properties(r-type_client PROPERTIES
CXX_STANDARD 20
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO
DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX}
)
set_target_properties(r-type_server PROPERTIES
CXX_STANDARD 20
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO
DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX}
)

install(TARGETS r-type_client r-type_server
RUNTIME DESTINATION bin
)

target_compile_definitions(r-type_server PRIVATE GEngine_Server)
target_compile_definitions(r-type_client PRIVATE GEngine_Client)
1 change: 1 addition & 0 deletions examples/POC_3D/assets/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.trash
6 changes: 6 additions & 0 deletions examples/POC_3D/assets/animations/r-typesheet1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"playerdeath": { "frames": [0, 1, 2, 3, 4, 5], "looping": false },
"shoot": { "frames": [0, 1], "looping": false },
"charging": { "frames": [0, 1, 2, 3, 4, 5, 6, 7], "looping": true },
"beam": { "frames": [0, 1], "looping": true }
}
3 changes: 3 additions & 0 deletions examples/POC_3D/assets/animations/r-typesheet3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"enemy": { "frames": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] }
}
3 changes: 3 additions & 0 deletions examples/POC_3D/assets/animations/r-typesheet42.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"spaceship": { "frames": [0, 1, 2, 3, 4], "idleFrameIdx": 2, "looping": false }
}
3 changes: 3 additions & 0 deletions examples/POC_3D/assets/animations/r-typesheet44.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"small": { "frames": [0, 1, 2, 3, 4, 5], "looping": false }
}
3 changes: 3 additions & 0 deletions examples/POC_3D/assets/animations/r-typesheet5.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"red_enemy": { "frames": [0, 1, 2, 3, 4, 5, 6, 7] }
}
Binary file added examples/POC_3D/assets/fonts/arcade.ttf
Binary file not shown.
Binary file added examples/POC_3D/assets/models/coraline.glb
Binary file not shown.
Binary file added examples/POC_3D/assets/models/coraline_old.glb
Binary file not shown.
Binary file added examples/POC_3D/assets/models/door.glb
Binary file not shown.
Binary file added examples/POC_3D/assets/models/gmApart.glb
Binary file not shown.
Binary file added examples/POC_3D/assets/sounds/shoot.mp3
Binary file not shown.
Binary file added examples/POC_3D/assets/sprites/background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file added examples/POC_3D/build/.gitkeep
Empty file.
96 changes: 96 additions & 0 deletions examples/POC_3D/cmake/automate-vcpkg.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
cmake_minimum_required (VERSION 3.12)

if(WIN32)
set(VCPKG_FALLBACK_ROOT ${CMAKE_CURRENT_BINARY_DIR}/vcpkg CACHE STRING "vcpkg configuration directory to use if vcpkg was not installed on the system before")
else()
set(VCPKG_FALLBACK_ROOT ${CMAKE_CURRENT_BINARY_DIR}/.vcpkg CACHE STRING "vcpkg configuration directory to use if vcpkg was not installed on the system before")
endif()

# On Windows, Vcpkg defaults to x86, even on x64 systems. If we're
# doing a 64-bit build, we need to fix that.
if (WIN32)
# Since the compiler checks haven't run yet, we need to figure
# out the value of CMAKE_SIZEOF_VOID_P ourselfs

include(CheckTypeSize)
enable_language(C)
check_type_size("void*" SIZEOF_VOID_P BUILTIN_TYPES_ONLY)

if (SIZEOF_VOID_P EQUAL 8)
message(STATUS "Using Vcpkg triplet 'x64-windows'")
set(VCPKG_TRIPLET x64-windows)
endif()
endif()

if(NOT DEFINED VCPKG_ROOT)
if(NOT DEFINED ENV{VCPKG_ROOT})
set(VCPKG_ROOT ${VCPKG_FALLBACK_ROOT})
else()
set(VCPKG_ROOT $ENV{VCPKG_ROOT})
endif()
endif()

# Installs a new copy of Vcpkg or updates an existing one
macro(vcpkg_bootstrap)
if(NOT VCPKG_SHOULD_NOT_UPDATE)
_install_or_update_vcpkg()
endif()

# We know this wasn't set before so we need point the toolchain file to the newly found VCPKG_ROOT
set(CMAKE_TOOLCHAIN_FILE ${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake CACHE STRING "")

# Just setting vcpkg.cmake as toolchain file does not seem to actually pull in the code
include(${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake)

set(AUTOMATE_VCPKG_USE_SYSTEM_VCPKG OFF)

message(STATUS "Automate VCPKG status:")
message(STATUS " VCPKG_ROOT.....: ${VCPKG_ROOT}")
message(STATUS " VCPKG_EXEC.....: ${VCPKG_EXEC}")
message(STATUS " VCPKG_BOOTSTRAP: ${VCPKG_BOOTSTRAP}")
endmacro()

macro(_install_or_update_vcpkg)
if(NOT EXISTS ${VCPKG_ROOT})
message(STATUS "Cloning vcpkg in ${VCPKG_ROOT}")
execute_process(COMMAND git clone https://github.com/Microsoft/vcpkg.git ${VCPKG_ROOT})
else()
message(STATUS "Auto-updating vcpkg in ${VCPKG_ROOT}")
execute_process(COMMAND git pull WORKING_DIRECTORY ${VCPKG_ROOT})
endif()

if(NOT EXISTS ${VCPKG_ROOT}/README.md)
message(FATAL_ERROR "***** FATAL ERROR: Could not clone vcpkg *****")
endif()

if(WIN32)
set(VCPKG_EXEC ${VCPKG_ROOT}/vcpkg.exe)
set(VCPKG_BOOTSTRAP ${VCPKG_ROOT}/bootstrap-vcpkg.bat)
else()
set(VCPKG_EXEC ${VCPKG_ROOT}/vcpkg)
set(VCPKG_BOOTSTRAP ${VCPKG_ROOT}/bootstrap-vcpkg.sh)
endif()

if(NOT EXISTS ${VCPKG_EXEC})
message("Bootstrapping vcpkg in ${VCPKG_ROOT}")
execute_process(COMMAND ${VCPKG_BOOTSTRAP} WORKING_DIRECTORY ${VCPKG_ROOT})
endif()

if(NOT EXISTS ${VCPKG_EXEC})
message(FATAL_ERROR "***** FATAL ERROR: Could not bootstrap vcpkg *****")
endif()
endmacro()

# Installs the list of packages given as parameters using Vcpkg
macro(vcpkg_install_packages)
message(STATUS "Installing/Updating the following vcpkg-packages: ${PACKAGES_LIST_STR}")

if (VCPKG_TRIPLET)
set(ENV{VCPKG_DEFAULT_TRIPLET} "${VCPKG_TRIPLET}")
endif()

execute_process(
COMMAND ${VCPKG_EXEC} install ${ARGN} --allow-unsupported
WORKING_DIRECTORY ${VCPKG_ROOT}
)
endmacro()
29 changes: 29 additions & 0 deletions examples/POC_3D/cmake/compilers/Apple/armv8.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Set the system name
set(CMAKE_SYSTEM_NAME Darwin)

# Set the C and C++ compilers
set(CMAKE_C_COMPILER /usr/bin/clang)
set(CMAKE_CXX_COMPILER /usr/bin/clang++)

# Set the target architecture
set(CMAKE_OSX_ARCHITECTURES "arm64")

# Set the sysroot (if needed)
# set(CMAKE_SYSROOT /path/to/sysroot)

# Set the C and C++ flags
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -arch ${CMAKE_OSX_ARCHITECTURES}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -arch ${CMAKE_OSX_ARCHITECTURES}")

# Set the linker flags
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -arch ${CMAKE_OSX_ARCHITECTURES}")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -arch ${CMAKE_OSX_ARCHITECTURES}")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -arch ${CMAKE_OSX_ARCHITECTURES}")

# Set the find root path
# set(CMAKE_FIND_ROOT_PATH /path/to/find/root)
# set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)

# Set the search paths for libraries and includes
# set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH)
# set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH)
28 changes: 28 additions & 0 deletions examples/POC_3D/cmake/compilers/Apple/x64.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Set the system name
set(CMAKE_SYSTEM_NAME Darwin)

# Set the C and C++ compilers
set(CMAKE_C_COMPILER /usr/bin/clang)
set(CMAKE_CXX_COMPILER /usr/bin/clang++)

# Set the target architecture
set(CMAKE_OSX_ARCHITECTURES "x86_64")

# Set the sysroot (if needed)
# set(CMAKE_SYSROOT /path/to/sysroot)

# Set the C and C++ flags
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -arch ${CMAKE_OSX_ARCHITECTURES}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -arch ${CMAKE_OSX_ARCHITECTURES}")

# Set the linker flags
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -arch ${CMAKE_OSX_ARCHITECTURES}")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -arch ${CMAKE_OSX_ARCHITECTURES}")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -arch ${CMAKE_OSX_ARCHITECTURES}")

# Set the find root path
# set(CMAKE_FIND_ROOT_PATH /path/to/find/root)

# Set the search paths for libraries and includes
# set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH)
# set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
17 changes: 17 additions & 0 deletions examples/POC_3D/cmake/compilers/GNU/armv7.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR arm)

set(CMAKE_C_COMPILER "arm-linux-gnueabihf-gcc")
set(CMAKE_CXX_COMPILER "arm-linux-gnueabihf-g++")

set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

set(CMAKE_C_FLAGS "-march=armv7-a -mfloat-abi=hard -mfpu=neon")
set(CMAKE_CXX_FLAGS "-march=armv7-a -mfloat-abi=hard -mfpu=neon")

# cache flags
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}" CACHE STRING "c flags")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" CACHE STRING "c++ flags")
21 changes: 21 additions & 0 deletions examples/POC_3D/cmake/compilers/GNU/armv8.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Set the system name and processor
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR aarch64)
set(CMAKE_CROSSCOMPILING TRUE)

# Specify the cross compiler
set(CMAKE_C_COMPILER aarch64-linux-gnu-gcc)
set(CMAKE_CXX_COMPILER aarch64-linux-gnu-g++)

# Where is the target environment
set(CMAKE_FIND_ROOT_PATH /usr/aarch64-linux-gnu)
set(CMAKE_INCLUDE_PATH /usr/include/aarch64-linux-gnu)
set(CMAKE_LIBRARY_PATH /usr/lib/aarch64-linux-gnu)
set(CMAKE_PROGRAM_PATH /usr/bin/aarch64-linux-gnu)

# Search for programs in the build host directories
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)

# For libraries and headers in the target directories
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
23 changes: 23 additions & 0 deletions examples/POC_3D/cmake/compilers/GNU/x86.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Specify the C and C++ compilers
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR i386)
set(CMAKE_CROSSCOMPILING TRUE)

set(CMAKE_C_COMPILER gcc)
set(CMAKE_CXX_COMPILER g++)

# Add the -m32 flag to compile for 32-bit
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32")

set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m32")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -m32")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -m32")

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}" CACHE STRING "c flags")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" CACHE STRING "c++ flags")

# Ensure the find_XXX() commands search for 32-bit libraries
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
20 changes: 20 additions & 0 deletions examples/POC_3D/cmake/compilers/Windows/armv7.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
set(CMAKE_SYSTEM_NAME Windows)

# Specify the target architecture
set(CMAKE_SYSTEM_PROCESSOR ARM)

# Set the C and C++ compilers to use MSVC
set(CMAKE_C_COMPILER "cl.exe")
set(CMAKE_CXX_COMPILER "cl.exe")

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /arch:ARMv7")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:ARMv7")

# Set the platform to ARM
set(CMAKE_GENERATOR_PLATFORM "ARM" CACHE STRING "CMake generator platform" FORCE)

# Set the CMake find root path mode to only search in the specified directories
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

19 changes: 19 additions & 0 deletions examples/POC_3D/cmake/compilers/Windows/armv8.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
set(CMAKE_SYSTEM_NAME Windows)

# Specify the target architecture
set(CMAKE_SYSTEM_PROCESSOR ARM)

# Set the C and C++ compilers to use MSVC
set(CMAKE_C_COMPILER "cl.exe")
set(CMAKE_CXX_COMPILER "cl.exe")

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /arch:ARM64")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:ARM64")

# Set the platform to ARM
set(CMAKE_GENERATOR_PLATFORM "ARM" CACHE STRING "CMake generator platform" FORCE)

# Set the CMake find root path mode to only search in the specified directories
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
19 changes: 19 additions & 0 deletions examples/POC_3D/cmake/compilers/Windows/x86.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
set(CMAKE_SYSTEM_NAME Windows)

# Specify the target architecture
set(CMAKE_SYSTEM_PROCESSOR x86)

# Set the C and C++ compilers to use MSVC
set(CMAKE_C_COMPILER "cl.exe")
set(CMAKE_CXX_COMPILER "cl.exe")

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /arch:IA32")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:IA32")

# Set the platform to x86
set(CMAKE_GENERATOR_PLATFORM "Win32" CACHE STRING "CMake generator platform" FORCE)

# Set the CMake find root path mode to only search in the specified directories
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
Loading

0 comments on commit 7c73329

Please sign in to comment.