Compare commits
10 Commits
a4c9774c28
...
0.0.1
| Author | SHA1 | Date | |
|---|---|---|---|
| 2427601120 | |||
| c747dab1fc | |||
| 4c33da0ecd | |||
| f0284e7975 | |||
| 8f62ee83a6 | |||
| d16319084b | |||
| 46c9bee008 | |||
| 1594e663eb | |||
| c35097b3d3 | |||
| 384c811a29 |
24
.gitea/workflows/test.yml
Normal file
24
.gitea/workflows/test.yml
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
name: Gol CI
|
||||||
|
|
||||||
|
# Run on the merge of a pull request to the main branch
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
branches: [main]
|
||||||
|
push:
|
||||||
|
branches: [main]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y cmake libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libgl1-mesa-dev
|
||||||
|
- name: Build and test
|
||||||
|
run: |
|
||||||
|
mkdir build
|
||||||
|
cd build
|
||||||
|
cmake ..
|
||||||
|
make
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -5,3 +5,4 @@ _deps
|
|||||||
CMakeSettings.json
|
CMakeSettings.json
|
||||||
.vs
|
.vs
|
||||||
.cache
|
.cache
|
||||||
|
build-win-x86_64
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ include_directories(${imgui_SOURCE_DIR} ${rlImGui_SOURCE_DIR})
|
|||||||
set(SRC_CXX_FILES "./src/main.cpp"
|
set(SRC_CXX_FILES "./src/main.cpp"
|
||||||
"./src/rules.cpp"
|
"./src/rules.cpp"
|
||||||
"./src/world.cpp"
|
"./src/world.cpp"
|
||||||
|
"./src/grid.cpp"
|
||||||
"./src/render.cpp"
|
"./src/render.cpp"
|
||||||
"./src/control_menu.cpp"
|
"./src/control_menu.cpp"
|
||||||
"./src/settings_menu.cpp"
|
"./src/settings_menu.cpp"
|
||||||
@@ -90,3 +91,25 @@ add_executable(${NAME} ${SRC_CXX_FILES})
|
|||||||
|
|
||||||
# Link raylib and raylib-cpp
|
# Link raylib and raylib-cpp
|
||||||
target_link_libraries(${NAME} PUBLIC raylib nlohmann_json::nlohmann_json)
|
target_link_libraries(${NAME} PUBLIC raylib nlohmann_json::nlohmann_json)
|
||||||
|
|
||||||
|
# Windows cross-compilation rule
|
||||||
|
|
||||||
|
if (NOT DEFINED CMAKE_CROSSCOMPILE_WINDOWS_HELPER_ADDED)
|
||||||
|
set(CMAKE_CROSSCOMPILE_WINDOWS_HELPER_ADDED TRUE)
|
||||||
|
|
||||||
|
set(WIN_TOOLCHAIN_FILE "${CMAKE_SOURCE_DIR}/toolchain-mingw-w64-x86_64.cmake" CACHE PATH "Toolchain for Win x86_64")
|
||||||
|
|
||||||
|
add_custom_target(cmake-win
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E echo "Configuring Windows x86_64 build in: ${CMAKE_SOURCE_DIR}/build-win-x86_64"
|
||||||
|
COMMAND ${CMAKE_COMMAND}
|
||||||
|
-S ${CMAKE_SOURCE_DIR}
|
||||||
|
-B ${CMAKE_SOURCE_DIR}/build-win-x86_64
|
||||||
|
-G "Ninja"
|
||||||
|
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
|
||||||
|
-DCMAKE_TOOLCHAIN_FILE=${WIN_TOOLCHAIN_FILE}
|
||||||
|
COMMAND ${CMAKE_COMMAND} --build ${CMAKE_SOURCE_DIR}/build-win-x86_64 -- -v
|
||||||
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||||
|
COMMENT "Configure & build for Windows x86_64 (MinGW-w64)"
|
||||||
|
VERBATIM
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|||||||
@@ -15,4 +15,4 @@ cmake ..
|
|||||||
make
|
make
|
||||||
```
|
```
|
||||||
|
|
||||||
> As for now I will not make this program Windows compatible.
|
> The windows version might exist one day
|
||||||
|
|||||||
28
includes/grid.hpp
Normal file
28
includes/grid.hpp
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
/*
|
||||||
|
* File name: grid.hpp
|
||||||
|
* Author: lejulien
|
||||||
|
* Date created: 01-01-1970 00:59:59
|
||||||
|
// Date modified: 12-01-2026 21:30:10
|
||||||
|
* ------
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <context.hpp>
|
||||||
|
#include <memory>
|
||||||
|
#include <settings_menu.hpp>
|
||||||
|
#include <world.hpp>
|
||||||
|
|
||||||
|
namespace gol {
|
||||||
|
|
||||||
|
class Grid {
|
||||||
|
public:
|
||||||
|
Grid(std::shared_ptr<ctx>);
|
||||||
|
~Grid() = default;
|
||||||
|
void display();
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::shared_ptr<ctx> context_;
|
||||||
|
};
|
||||||
|
|
||||||
|
}; // namespace gol
|
||||||
27
src/grid.cpp
Normal file
27
src/grid.cpp
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
/*
|
||||||
|
* File name: grid.cpp
|
||||||
|
* Author: lejulien
|
||||||
|
* Date created: 01-01-1970 00:59:59
|
||||||
|
// Date modified: 12-01-2026 21:30:10
|
||||||
|
* ------
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <raylib.h>
|
||||||
|
|
||||||
|
#include <grid.hpp>
|
||||||
|
|
||||||
|
namespace gol {
|
||||||
|
|
||||||
|
Grid::Grid(std::shared_ptr<ctx> context) : context_(context) {}
|
||||||
|
|
||||||
|
void Grid::display() {
|
||||||
|
auto cell_size = context_->settings_menu->getCellSize();
|
||||||
|
for (int j = 0; j < context_->world->getHeight(); j++) {
|
||||||
|
for (int i = 0; i < context_->world->getWidth(); i++) {
|
||||||
|
DrawRectangleLines(i * cell_size, j * cell_size, cell_size, cell_size,
|
||||||
|
GRAY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace gol
|
||||||
@@ -26,6 +26,7 @@
|
|||||||
#include <selection.hpp>
|
#include <selection.hpp>
|
||||||
#include <paterns_menu.hpp>
|
#include <paterns_menu.hpp>
|
||||||
#include <patern_preview.hpp>
|
#include <patern_preview.hpp>
|
||||||
|
#include <grid.hpp>
|
||||||
|
|
||||||
int main(int ac, char **av) {
|
int main(int ac, char **av) {
|
||||||
std::shared_ptr<gol::ctx> context = std::make_shared<gol::ctx>();
|
std::shared_ptr<gol::ctx> context = std::make_shared<gol::ctx>();
|
||||||
@@ -109,6 +110,7 @@ int main(int ac, char **av) {
|
|||||||
context->selection = std::make_shared<gol::Selection>(context);
|
context->selection = std::make_shared<gol::Selection>(context);
|
||||||
context->paterns_menu = std::make_shared<gol::PaternsMenu>(context);
|
context->paterns_menu = std::make_shared<gol::PaternsMenu>(context);
|
||||||
context->patern_preview = std::make_shared<gol::PaternPreview>(context);
|
context->patern_preview = std::make_shared<gol::PaternPreview>(context);
|
||||||
|
gol::Grid grid(context);
|
||||||
|
|
||||||
// Speed handling values
|
// Speed handling values
|
||||||
float sim_speed = 1.0f;
|
float sim_speed = 1.0f;
|
||||||
@@ -155,6 +157,7 @@ int main(int ac, char **av) {
|
|||||||
}
|
}
|
||||||
BeginDrawing();
|
BeginDrawing();
|
||||||
ClearBackground(BLACK);
|
ClearBackground(BLACK);
|
||||||
|
grid.display();
|
||||||
context->render->display(context->world);
|
context->render->display(context->world);
|
||||||
context->selection->display();
|
context->selection->display();
|
||||||
context->patern_preview->display();
|
context->patern_preview->display();
|
||||||
|
|||||||
21
toolchain-mingw-w64-x86_64.cmake
Normal file
21
toolchain-mingw-w64-x86_64.cmake
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
set(CMAKE_SYSTEM_NAME Windows)
|
||||||
|
set(CMAKE_SYSTEM_VERSION 1)
|
||||||
|
set(CMAKE_CROSSCOMPILING TRUE)
|
||||||
|
|
||||||
|
set(MINGW_TRIPLET "x86_64-w64-mingw32")
|
||||||
|
|
||||||
|
set(CMAKE_C_COMPILER ${MINGW_TRIPLET}-gcc)
|
||||||
|
set(CMAKE_CXX_COMPILER ${MINGW_TRIPLET}-g++)
|
||||||
|
set(CMAKE_RC_COMPILER ${MINGW_TRIPLET}-windres)
|
||||||
|
set(CMAKE_AR ${MINGW_TRIPLET}-ar)
|
||||||
|
set(CMAKE_RANLIB ${MINGW_TRIPLET}-ranlib)
|
||||||
|
set(CMAKE_OBJCOPY ${MINGW_TRIPLET}-objcopy)
|
||||||
|
|
||||||
|
set(CMAKE_FIND_ROOT_PATH /usr/${MINGW_TRIPLET})
|
||||||
|
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||||
|
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||||
|
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||||
|
|
||||||
|
set(CMAKE_C_FLAGS_INIT "-static -static-libgcc -static-libstdc++")
|
||||||
|
set(CMAKE_CXX_FLAGS_INIT "-static -static-libgcc -static-libstdc++")
|
||||||
|
|
||||||
Reference in New Issue
Block a user