Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
0993960
add angelscript
AlemSnyder Mar 21, 2026
a3a131d
slightly cleanup cmake file
AlemSnyder Mar 21, 2026
b2b9af6
add tests
AlemSnyder Apr 4, 2026
6fddc68
Angelscript tests and loading
AlemSnyder Apr 12, 2026
2384df5
initialize reference count to one.
AlemSnyder Apr 14, 2026
501ce46
angelscript return types
AlemSnyder Apr 15, 2026
8deeb91
angelscript logging and other tests
AlemSnyder Apr 16, 2026
da88497
comment out angelscript code in biome map
AlemSnyder Apr 16, 2026
073b13e
remove memory leaks from multithreading
AlemSnyder Apr 17, 2026
9f7b440
clean up
AlemSnyder Apr 17, 2026
a31234f
angelscript map test
AlemSnyder Apr 18, 2026
5388f28
Add a load time test
AlemSnyder Apr 18, 2026
27242b0
maybe clang 19
AlemSnyder Mar 3, 2026
8b422f6
apt install
AlemSnyder Mar 3, 2026
d192404
Merge branch 'fixes' into change_to_as
AlemSnyder Apr 18, 2026
bae239c
remove sol and lua
AlemSnyder Apr 19, 2026
70ef9aa
use plant map name for map
AlemSnyder Apr 25, 2026
97e2d74
formatting documentations and include
AlemSnyder Apr 27, 2026
b7c8f9c
suggested changes
AlemSnyder May 7, 2026
1cf7b62
suggested changes and angelscript namespace
AlemSnyder May 13, 2026
2dc938b
add error checking to interface
AlemSnyder May 14, 2026
2dc1f60
suggested changes
AlemSnyder May 26, 2026
1c759f6
error checking
AlemSnyder May 26, 2026
5cf688c
remove message callback from global context
AlemSnyder May 26, 2026
b26c21d
one run function
AlemSnyder May 30, 2026
93ad8c7
change how errors are processed
AlemSnyder May 31, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
# - macos-latest
compiler: [
{ cc: "gcc", cxx: "g++"},
{ cc: "clang", cxx: "clang++"}
{ cc: "clang-19", cxx: "clang++-19"}
]
build:
- Release
Expand All @@ -44,17 +44,17 @@ jobs:
with:
submodules: 'recursive'

- name: Install Ninja
- name: Install Ninja & Clang-19
run: |
sudo apt update
sudo apt install ninja-build -y
sudo apt install clang-19 -y

- name: Install Dependencies
run: |
sudo apt update

sudo apt install \
lua5.3 liblua5.3-dev \
libglfw3 libglfw3-dev \
libglew-dev \
libglm-dev \
Expand Down
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
[submodule "vendor/quill"]
path = vendor/quill
url = https://github.com/odygrd/quill.git
[submodule "vendor/sol2"]
path = vendor/sol2
url = https://github.com/ThePhD/sol2.git
[submodule "vendor/imgui"]
path = vendor/imgui/imgui
url = https://github.com/ocornut/imgui
Expand All @@ -19,3 +16,6 @@
[submodule "vendor/whereami"]
path = vendor/whereami
url = https://github.com/gpakosz/whereami.git
[submodule "vendor/angelscript"]
path = vendor/angelscript
url = https://github.com/anjo76/angelscript.git
57 changes: 34 additions & 23 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,39 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
# set the project name
project(FunGame VERSION 0.1.0)

# AngelScript
file(GLOB ANGELSCRIPT_SOURCE "vendor/angelscript/sdk/angelscript/source/*.c*")
file(GLOB ANGELSCRIPT_SOURCE_STRING "vendor/angelscript/sdk/add_on/scriptstdstring/*.c*")
file(GLOB ANGELSCRIPT_SOURCE_ARRAY "vendor/angelscript/sdk/add_on/scriptarray/*.c*")
add_library(angelscript OBJECT ${ANGELSCRIPT_SOURCE} ${ANGELSCRIPT_SOURCE_STRING} ${ANGELSCRIPT_SOURCE_ARRAY})
target_compile_definitions(angelscript PRIVATE "AS_USE_NAMESPACE")
target_compile_definitions(angelscript PRIVATE "AS_USE_STLNAMES")
target_include_directories(angelscript PRIVATE "vendor/angelscript/sdk/angelscript/include")

# where am I
file(GLOB WHEREAMI_SOURCE "vendor/whereami/src/**")
add_library(whereami OBJECT ${WHEREAMI_SOURCE})
target_include_directories(whereami PRIVATE "vendor/whereami/src")

# ImGUI
file(GLOB IMGUI_SOURCES1 "vendor/imgui/imgui/*.c*")
file(GLOB IMGUI_SOURCES2 "vendor/imgui/imgui/backends/imgui_impl_opengl3.cpp")
file(GLOB IMGUI_SOURCES3 "vendor/imgui/imgui/backends/imgui_impl_glfw.cpp")
add_library(dear_imgui OBJECT ${IMGUI_SOURCES1} ${IMGUI_SOURCES2} ${IMGUI_SOURCES3})
target_include_directories(dear_imgui PRIVATE "vendor/imgui/imgui")

# add the executable
file(GLOB_RECURSE SOURCES1 "src/*.cpp")

# this is one json file and whereami
file(GLOB SOURCES4 "vendor/whereami/src/*.c*")
file(GLOB SOURCES6 "vendor/imgui/imgui/*.c*")
file(GLOB SOURCES7 "vendor/imgui/imgui/backends/imgui_impl_opengl3.cpp")
file(GLOB SOURCES8 "vendor/imgui/imgui/backends/imgui_impl_glfw.cpp")
add_executable(FunGame ${SOURCES1} ${SOURCES4} ${SOURCES6} ${SOURCES7} ${SOURCES8})
add_executable(FunGame ${SOURCES1})

# Set standard version
set_property(TARGET FunGame PROPERTY CXX_STANDARD 23)
set_property(TARGET FunGame PROPERTY C_STANDARD 17)

target_compile_definitions(FunGame PRIVATE "AS_USE_NAMESPACE")
target_compile_definitions(FunGame PUBLIC GLM_ENABLE_EXPERIMENTAL)

# compile quill and sol2
# compile quill
block()
set(QUILL_BUILD_EXAMPLES OFF)
set(QUILL_BUILD_TESTS OFF)
Expand All @@ -36,8 +52,6 @@ block()
add_subdirectory("vendor/quill")
endblock()

add_subdirectory("vendor/sol2")

add_subdirectory("vendor/glaze")

add_subdirectory("vendor/argh")
Expand Down Expand Up @@ -69,17 +83,13 @@ else()
target_link_libraries(FunGame PRIVATE glm::glm)
endif()

# Lua 5.2 just uses the name "Lua" while 5.1, and 5.0 used "Lua51", and "Lua50"
# respectivly.
find_package(Lua REQUIRED)

include_directories(${LUA_INCLUDE_DIR})

# add quill and sol2
target_link_libraries_system(FunGame PRIVATE quill::quill)
target_link_libraries(FunGame PRIVATE quill::quill)

target_link_libraries_system(FunGame PRIVATE sol2::sol2)
target_link_libraries(FunGame PRIVATE ${LUA_LIBRARIES})
target_link_libraries(FunGame PRIVATE whereami)
target_link_libraries(FunGame PRIVATE dear_imgui)
target_link_libraries(FunGame PRIVATE angelscript)

# Add include dirs
target_include_directories(FunGame PRIVATE "vendor/whereami/src")
Expand All @@ -88,6 +98,8 @@ target_include_directories(FunGame PRIVATE "vendor/thread-pool/include")
target_include_directories(FunGame PRIVATE "vendor/glaze/include")
target_include_directories(FunGame PRIVATE "vendor/imgui")
target_include_directories(FunGame PRIVATE "vendor/imgui/imgui")
target_include_directories(FunGame PRIVATE "vendor/angelscript/sdk/angelscript/include")
target_include_directories(FunGame PRIVATE "vendor/angelscript/sdk/add_on/scriptstdstring")
target_include_directories(FunGame PRIVATE "src")
target_include_directories(FunGame PRIVATE "${PROJECT_BINARY_DIR}")

Expand Down Expand Up @@ -139,9 +151,8 @@ add_test(NAME Logging COMMAND FunGame Test Logging)
add_test(NAME ChunkDataTest COMMAND FunGame Test ChunkDataTest)
add_test(NAME LoadManifest COMMAND FunGame Test LoadManifest)
add_test(NAME PathFinderTest COMMAND FunGame Test PathFinderTest)
add_test(NAME LuaMap COMMAND FunGame Test Lua Map)
add_test(NAME LuaLogging COMMAND FunGame Test Lua Logging)
add_test(NAME LuaLoadTime COMMAND FunGame Test Lua LoadTime)
add_test(NAME LuaLoadScript COMMAND FunGame Test Lua LoadScript)
add_test(NAME LuaTransferScript COMMAND FunGame Test Lua TransferScript)
add_test(NAME AngelScriptNap COMMAND FunGame Test AngelScript Map)
add_test(NAME AngelScriptLogging COMMAND FunGame Test AngelScript Logging)
add_test(NAME AngelScriptLoadTime COMMAND FunGame Test AngelScript LoadTime)
add_test(NAME AngelScriptLoadScript COMMAND FunGame Test AngelScript LoadScript)
add_test(NAME EngineTest COMMAND FunGame Test EngineTest)
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ pacman -Su \
mingw-w64-x86_64-ninja \
mingw-w64-x86_64-glew \
mingw-w64-x86_64-glfw \
mingw-w64-x86_64-glm \
mingw-w64-x86_64-lua # not 100% sure this is the right lua version
mingw-w64-x86_64-glm
```

## Building
Expand Down
2 changes: 2 additions & 0 deletions TODO.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ GUI
make trees function like entities # here
same shader etc

Generally fix TODOs in the code
Want to get the correct module name for as code, and make sure modules can communicate with needed.
4 changes: 2 additions & 2 deletions data/Base/biome_data.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"map_generator_path": "./biome_map.lua",
"map_generator_path": "./biome_map.as",
"image_path": "path/to/image",
"description": "This is a test biome",
"name": "Base",
Expand Down Expand Up @@ -730,7 +730,7 @@
{
"identification": "base/Flower_Test",
"map_name": "Flower_1",
"map_generator_path": "biome_map.lua"
"map_generator_path": "biome_map.as"
}
]
}
78 changes: 78 additions & 0 deletions data/Base/biome_map.as
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
// Biome map files must define a function that returns a structure with a "map".
// The map function is called from c++ and reads the x and y lengths. Using this
// information the "map" key of the returned structure can be used as if it were
// a 2D array.

// Anyway, do something like this and it should work as long as there are
// correctly defined tile types and tile macros.

// Base = Base or {}
// Base.biome_map = Base.biome_map or {}

// Base.biome_map.spacing = .8

namespace Base {

namespace biomes {

class biome_map {

TerrainGeneration::FractalNoise noise;
TerrainGeneration::AlternativeWorleyNoise flower_noise;
float spacing;

biome_map() {
noise = TerrainGeneration::FractalNoise(4, 0.6, 3);
flower_noise = TerrainGeneration::AlternativeWorleyNoise(32, 0.5, 32);
spacing = 0.8;
}

int sample(int x, int y) {
// sample noise and set a value
float height = 12.0 * noise.sample(float(x) * spacing, float(y) * spacing) - 4.0;
// each value must be integers. math.floor changes doubles to ints
int height_map_value = int(height) ;
// This biome only defines tile types between 0, and 6
if (height_map_value > 6) {
height_map_value = 6;
}
else if (height_map_value < 0) {
height_map_value = 0;
}
return height_map_value;
}

// Maps for trees and bushes
// name should be used in json file
float sample_plants(string plant_id, int x, int y) {
if (plant_id == "Trees_1") {
int height = sample(x, y);
if (height == 1) {
return 0.1;
}
else {
return 0.0;
}
}
else if (plant_id == "Flower_1") {
int flower_height = int(flower_noise.sample(x * 4, y * 4));
if (flower_height > 0) {
return 0.10;
}
else {
return 0.0;
}
}
else {
return 0.0;
}
}
}

}

}

void do_something() {
Base::biomes::biome_map@ map = Base::biomes::biome_map();
}
4 changes: 2 additions & 2 deletions data/Base/biomes/Test_Biome.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"map_generator_path": "../biome_map.lua",
"map_generator_path": "../biome_map.as",
"image_path": "path/to/image",
"description": "This is a test biome",
"name": "Base",
Expand Down Expand Up @@ -730,7 +730,7 @@
{
"identification": "base/Flower_Test",
"map_name": "Flower_1",
"map_generator_path": "../biome_map.lua"
"map_generator_path": "../biome_map.as"
}
]
}
2 changes: 1 addition & 1 deletion data/Base/models/Test_Entity/Test.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
}
],
"listeners":"",
"ai":"ai.lua"
"ai":"ai.as"
}
2 changes: 2 additions & 0 deletions data/Base/models/Test_Entity/ai.lua

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make an issue for this or update it

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I was confused by what you meant by this. I will make a sub issue on #104.

Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
-- Leaving this one for now because I need it to chang to as

Base = Base or {}
Base.entities = Base.entities or {}
Base.entities.Test_Entity = Base.entities.Test_Entity or {}
Expand Down
34 changes: 34 additions & 0 deletions resources/as/test.as
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
void test1() {
int x = 5;
return;
}

int test2() {
int x = 1 * 2 * 3 * 4 * 5 * 6;
if (x % 2 == 0) {
return 2;
}
return 1;
}

int test3() {
LOGGING::LOG_BACKTRACE("Backtrace log 1");
LOGGING::LOG_BACKTRACE("Backtrace log 2");

LOGGING::LOG_INFO("Welcome to AngelScript!");
LOGGING::LOG_ERROR("An error message. error code 123");
LOGGING::LOG_WARNING("A warning message.");
LOGGING::LOG_CRITICAL("A critical error.");
LOGGING::LOG_DEBUG("Debugging foo 1234");

return 0;
}

bool is_prime(int N) {
for (int x = 2; x * x < N; x++) {
if (N % x == 0) {
return false;
}
}
return true;
}
14 changes: 0 additions & 14 deletions resources/lua/is_prime_test.lua

This file was deleted.

58 changes: 0 additions & 58 deletions resources/lua/logging.lua

This file was deleted.

Loading
Loading