Skip to content

Commit

Permalink
Merge branch 'feature/RB-22-network' of github.com:X-R-G-B/R-Bus into…
Browse files Browse the repository at this point in the history
… feature/RB-22-network
  • Loading branch information
romainpanno committed Oct 2, 2023
2 parents 6a8a258 + e456d85 commit 879d470
Show file tree
Hide file tree
Showing 67 changed files with 2,871 additions and 485 deletions.
22 changes: 10 additions & 12 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@ jobs:
- name: Build
run: ./scripts/bundle-windows.ps1

- name: LIST ALL
run: Get-ChildItem build -Recurse

- name: Upload To Release
if: github.ref == 'refs/heads/main'
env:
Expand Down Expand Up @@ -93,9 +90,6 @@ jobs:
- name: Build
run: ./scripts/bundle-linux.sh

- name: LIST ALL
run: ls -Rl build

- name: Upload To Release
if: github.ref == 'refs/heads/main'
env:
Expand Down Expand Up @@ -132,23 +126,27 @@ jobs:
- name: Build
run: ./scripts/bundle-macos.sh

- name: LIST ALL
run: ls -Rl build

- name: Upload To Release
if: github.ref == 'refs/heads/main'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release upload ${{ needs.release-create.outputs.release }} ./r-type-macos.zip
# gh release upload ${{ needs.release-create.outputs.release }} ./r-type-linux.sh
gh release upload ${{ needs.release-create.outputs.release }} ./r-type-macos.dmg
- name: Upload To Artifact
if: github.ref != 'refs/heads/main'
uses: actions/upload-artifact@v3
with:
name: r-type-macos.dmg
path: ./r-type-macos.dmg

- name: Upload To Artifact
if: github.ref != 'refs/heads/main'
uses: actions/upload-artifact@v3
with:
name: r-type-macos.sh
path: ./r-type-macos.sh
name: r-type-macos.zip
path: ./r-type-macos.zip

raylib-to-tar:
runs-on: ubuntu-latest
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,5 @@ r-type-windows.zip
r-type-macos.zip
cmake-build-debug/
*~

vgcore*
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ set(PROJECT_NAME r-type)
if(NOT DEFINED CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
SET(CMAKE_CONFIGURATION_TYPES ${CMAKE_BUILD_TYPE} CACHE STRING "" FORCE)

option(BUILD_SHARED_LIBS "Build using shared libraries" OFF)
option(WITH_PIC "Build with position independent code" ON)
Expand Down Expand Up @@ -179,7 +180,8 @@ set(CPACK_PACKAGE_VENDOR "X-L-R-G-B")
include(InstallRequiredSystemLibraries)

set(CPACK_PACKAGE_NAME "R-Type")
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_SYSTEM_NAME}")
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CMAKE_SYSTEM_NAME}")
set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CMAKE_SYSTEM_NAME}")
set(CPACK_PACKAGE_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${PROJECT_VERSION_MINOR}")
set(CPACK_PACKAGE_VERSION_PATCH "${PROJECT_VERSION_PATCH}")
Expand Down
5 changes: 0 additions & 5 deletions deps/boost/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,4 @@ foreach(lib ${BOOST_INCLUDE_LIBRARIES})
PRIVATE
Boost::${lib}
)
# if(WIN32)
# install(FILES Boost::${lib} DESTINATION ${CMAKE_INSTALL_BINDIR})
# else()
# install(FILES Boost::${lib} DESTINATION ${CMAKE_INSTALL_LIBDIR})
# endif()
endforeach()
68 changes: 68 additions & 0 deletions docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
[fork]: https://github.com/X-R-G-B/R-Bus/fork
[pr]: https://github.com/X-R-G-B/R-Bus/compare/
[doc-codeQL]: https://docs.github.com/en/code-security/code-scanning/using-codeql-code-scanning-with-your-existing-ci-system/about-codeql-code-scanning-in-your-ci-system

# CONTRIBUTING

Here is the instructions if you want to contribute to the project

## Submitting a pull request

1. [Fork][fork] and clone the repository
2. Create a new branch: See '[creating a branch](#creating-a-branch)'
3. Make your change, add tests, and make sure the tests still pass
4. Make sure that the code is codeQL compliant
5. Make sure that you had documentation to the new added code (obviously compliant with our doc)
6. Push to your fork and [submit a pull request][pr] with correct labels added if necessary
7. Wait for your pull request to be reviewed and merged.

Here are a few things you can do that will increase the likelihood of your pull request being accepted:

- The security of your code is analysed by [codeQL][doc-codeQL] the CI might fail if it's not secure.
- The style of your code must respect the clang-format style.
Normally we have the .clang-format if you want for your IDE.
If you don't want to use the .clang-format intergration in your IDE, you can still
launch the script format.sh (Linux and MacOs) or format.ps1 (Windows), this will format automaticlly your code.
**/!\ Warning ! If your code is not clang format compliant your CI will fail and your pr will be refused.**
- Write tests.
- Keep your change as focused as possible.
If there are multiple changes you would like to make that are not dependent upon each other, consider submitting them as separate pull requests.
- Write a commit message that respect the commit norm that we have, see '[Commit message norm](#commit-message-norm)'.


## Commit message norm
1. Define your context.
- CICD
- CLIENT-GAME
- DOCUMENTATION
- POC
- NETWORK
- SERVER
2. Followed by ":" + "action verb"
- : Add
- : Fix
- : Update
- etc ...
3. Explain what your commit introduce
- new feature for client-game
- bug inside network
- documentation for CLIENT-GAME
- etc...
4. Just after your commit message put a newline to indicate semver
- PATCH (If your commit introduce a bug fix)
- MINOR (If your commit introduce a new feature)
- MAJOR (If your commit introduce a new feature and the older version doesn't work anymore)

__/!\ Warning ! If your commit message doesn't respect those rules your pr might not be accepted__


## Creating a branch
If you need to contribute to our project, you will need to create a branch to submit a pull request.
Basicly, you must indicate what is the context of your branch followed by a '/'.
For exemple :
- feature/BRANCH-NAME
- doc/BRANCH-NAME
- refactor/BRANCH-NAME
- etc...

That's all you need to do to create a valid branch.
3 changes: 3 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# R-Bus

[![Release](https://github.com/X-R-G-B/R-Bus/actions/workflows/release.yml/badge.svg?branch=main)](https://github.com/X-R-G-B/R-Bus/actions/workflows/release.yml)

[![Compil](https://github.com/X-R-G-B/R-Bus/actions/workflows/compil.yml/badge.svg?branch=main)](https://github.com/X-R-G-B/R-Bus/actions/workflows/compil.yml)

```
R-Type[a] is a horizontally scrolling shooter arcade video game developed
Expand Down
2 changes: 1 addition & 1 deletion docs/contributors.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ Thanks to this amazing contributors that made this project possible!
- [@Saverio976](https://github.com/Saverio976)
- [@TTENSHII](https://github.com/TTENSHII)
- [@guillaumeAbel](https://github.com/guillaumeAbel)
- [KitetsuK](https://github.com/KitetsuK)
- [@KitetsuK](https://github.com/KitetsuK)
- [@romainpanno](https://github.com/romainpanno)
4 changes: 3 additions & 1 deletion scripts/bundle-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

set -ex

rm -rf build

cmake -S . -B build -DCMAKE_BUILD_TYPE=Release

cmake --build build
Expand All @@ -15,4 +17,4 @@ mv R-Type-Linux.sh ../r-type-linux.sh

cpack --config CPackSourceConfig.cmake -G TGZ

mv R-Type-Source.tar.gz ../r-type-linux.tar.gz
mv R-Type-Linux.tar.gz ../r-type-linux.tar.gz
6 changes: 5 additions & 1 deletion scripts/bundle-macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

set -ex

rm -rf build

cmake -S . -B build -DCMAKE_BUILD_TYPE=Release

cmake --build build
Expand All @@ -11,6 +13,8 @@ cd build || exit 14

cpack --config CPackConfig.cmake -G DragNDrop || (cat "./_CPack_Packages/Darwin/DragNDrop/PreinstallOutput.log" && exit 1)

cp R-Type-Darwin.dmg ../r-type-macos.dmg

cpack --config CPackSourceConfig.cmake -G ZIP

ls -l
cp R-Type-Darwin.zip ../r-type-macos.zip
10 changes: 5 additions & 5 deletions scripts/bundle-windows.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

$ErrorActionPreference = "SilentlyContinue"

./scripts/compil.ps1
rm -Recurse build

cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_CONFIGURATION_TYPES="Release;Release" -DCONFIG=Release
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_CONFIGURATION_TYPES="Release"

cmake --build build
cmake --build build --config Release

cd build

Expand All @@ -17,10 +17,10 @@ if ($LASTEXITCODE -ne 0) {
type _CPack_Packages/win64/NSIS/NSISOutput.log
}

Copy-Item R-Type-win64.exe ../r-type-windows.exe
Copy-Item R-Type-Windows.exe ../r-type-windows.exe

cpack --config CPackSourceConfig.cmake -G ZIP

Copy-Item R-Type-Source.zip ../r-type-windows.zip
Copy-Item R-Type-Windows.zip ../r-type-windows.zip

cd ..
11 changes: 2 additions & 9 deletions scripts/compil.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,6 @@

$ErrorActionPreference = 'Stop'

cmake -S . -B build -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=ON

cmake --build build

$file = "build/_deps/raylib-build/raylib/Release/raylib.lib"

if (-not(Test-Path -Path $file -PathType Leaf)) {
New-Item -Name "build/_deps/raylib-build/raylib/Release" -Type Directory -Force
Copy-Item "build/_deps/raylib-build/raylib/Debug/raylib.lib" $file
}
cmake --build build -- /m
14 changes: 0 additions & 14 deletions scripts/format.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,3 @@ if ($args.Count -gt 0 -and $args[0] -eq '--dry-run') {
$files = Get-Childitem -Path src -Include *.cpp,*.hpp -Recurse -ErrorAction SilentlyContinue

clang-format --style=file $argClangFormat -i $files

# $found = Select-String -Path $files -Pattern '"raylib.h"' -CaseSensitive
#
# if ($found) {
# echo $found
# exit 1
# }
#
# $found = Select-String -Path $files -Pattern '"raylib.hpp"' -CaseSensitive
#
# if ($found) {
# echo $found
# exit 1
# }
6 changes: 0 additions & 6 deletions scripts/format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,3 @@ if [ "$1" == "--dry-run" ]; then
fi

find src/ \( -name '*.cpp' -o -name '*.hpp' \) -print0 | xargs -0 clang-format --style=file $ARGS -i

# found=$(find src/ \( -name '*.cpp' -o -name '*.hpp' \) -print0 | xargs -0 grep -e '"raylib.h"' -e '"raylib.hpp"')
# if [ -n "$found" ]; then
# echo "$found"
# exit 1
# fi
11 changes: 9 additions & 2 deletions scripts/install-deps-windows.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
#!/bin/pwsh
# Install deps

winget install --accept-package-agreements --accept-source-agreements LLVM -e
winget install --accept-package-agreements --accept-source-agreements CMake -e
winget list -e LLVM
if ($LASTEXITCODE -ne 0) {
winget install --accept-package-agreements --accept-source-agreements LLVM -e
}

winget list -e CMake
if ($LASTEXITCODE -ne 0) {
winget install --accept-package-agreements --accept-source-agreements CMake -e
}
3 changes: 2 additions & 1 deletion src/Client/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ target_include_directories(
target_sources(
${PROJECT_NAME_CLIENT}
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/SceneManager.cpp
)

add_subdirectory(Systems)
add_subdirectory(Raylib)
add_subdirectory(EventManager)
7 changes: 3 additions & 4 deletions src/Client/EventManager/EventManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

#include "EventManager.hpp"
#include <algorithm>
#include "raylib.h"
#include "Events.hpp"

// NOLINTBEGIN(cppcoreguidelines-avoid-non-const-global-variables)
Expand All @@ -23,18 +22,18 @@ void EventManager::updateEvents()
{
_activeEvents.clear();
for (auto event : Events::events) {
if (IsKeyDown(event)) {
if (Raylib::isKeyDown(event)) {
_activeEvents.push_back(event);
}
}
}

bool EventManager::checkEvent(int event)
bool EventManager::checkEvent(Raylib::KeyboardKey event)
{
return std::any_of(
_activeEvents.begin(),
_activeEvents.end(),
[event](int e) {
[event](Raylib::KeyboardKey e) {
return e == event;
});
}
5 changes: 3 additions & 2 deletions src/Client/EventManager/EventManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,19 @@
#pragma once

#include <vector>
#include "Raylib.hpp"

class EventManager {
public:
static EventManager &getInstance();
void updateEvents();
bool checkEvent(int event);
bool checkEvent(Raylib::KeyboardKey event);

private:
EventManager() = default;

// NOLINTBEGIN(cppcoreguidelines-avoid-non-const-global-variables)
static EventManager instance;
// NOLINTEND(cppcoreguidelines-avoid-non-const-global-variables)
std::vector<int> _activeEvents;
std::vector<Raylib::KeyboardKey> _activeEvents;
};
12 changes: 6 additions & 6 deletions src/Client/EventManager/Events.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@

#include <array>
#include <vector>
#include "raylib.h"
#include "Raylib.hpp"

namespace Events {
static constexpr auto events = {
KEY_LEFT,
KEY_RIGHT,
KEY_UP,
KEY_DOWN,
static const auto events = {
Raylib::KeyboardKey::KB_LEFT,
Raylib::KeyboardKey::KB_RIGHT,
Raylib::KeyboardKey::KB_UP,
Raylib::KeyboardKey::KB_DOWN,
};
}
Loading

0 comments on commit 879d470

Please sign in to comment.