feat: Inital Commit
This commit is contained in:
@@ -0,0 +1 @@
|
||||
build/
|
||||
@@ -0,0 +1,6 @@
|
||||
[submodule "external/raylib"]
|
||||
path = external/raylib
|
||||
url = https://github.com/raysan5/raylib.git
|
||||
[submodule "external/angelscript"]
|
||||
path = external/angelscript
|
||||
url = https://github.com/angelcode/angelscript.git
|
||||
Vendored
+28
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"tasks": [
|
||||
{
|
||||
"type": "cppbuild",
|
||||
"label": "C/C++: cl.exe build active file",
|
||||
"command": "cl.exe",
|
||||
"args": [
|
||||
"/Zi",
|
||||
"/EHsc",
|
||||
"/nologo",
|
||||
"/Fe${fileDirname}\\${fileBasenameNoExtension}.exe",
|
||||
"${file}"
|
||||
],
|
||||
"options": {
|
||||
"cwd": "${fileDirname}"
|
||||
},
|
||||
"problemMatcher": [
|
||||
"$msCompile"
|
||||
],
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": true
|
||||
},
|
||||
"detail": "Task generated by Debugger."
|
||||
}
|
||||
],
|
||||
"version": "2.0.0"
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
cmake_minimum_required(VERSION 3.25)
|
||||
project(SimianProject)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
# -------------------------
|
||||
# 1️⃣ Raylib
|
||||
# -------------------------
|
||||
add_subdirectory(external/raylib)
|
||||
|
||||
# -------------------------
|
||||
# 2️⃣ AngelScript
|
||||
# -------------------------
|
||||
add_subdirectory(external/angelscript/sdk/angelscript/projects/cmake)
|
||||
|
||||
# -------------------------
|
||||
# 3️⃣ scriptstdstring add-on
|
||||
# -------------------------
|
||||
add_library(scriptstdstring STATIC
|
||||
external/angelscript/sdk/add_on/scriptstdstring/scriptstdstring.cpp
|
||||
)
|
||||
|
||||
target_include_directories(scriptstdstring PUBLIC
|
||||
external/angelscript/sdk/angelscript/include
|
||||
)
|
||||
|
||||
# -------------------------
|
||||
# 4️⃣ Your executable
|
||||
# -------------------------
|
||||
add_executable(simian main.cpp)
|
||||
|
||||
target_include_directories(simian PUBLIC
|
||||
external/raylib/src
|
||||
external/angelscript/sdk/angelscript/include
|
||||
external/angelscript/sdk/add_on/scriptstdstring
|
||||
)
|
||||
|
||||
target_link_libraries(simian
|
||||
raylib
|
||||
angelscript
|
||||
scriptstdstring
|
||||
)
|
||||
|
||||
# Windows: Raylib needs extra libs
|
||||
if (WIN32)
|
||||
target_link_libraries(simian winmm gdi32)
|
||||
endif()
|
||||
+1
Submodule external/angelscript added at dcad5815cb
+1
Submodule external/raylib added at 12ce106661
@@ -0,0 +1,72 @@
|
||||
#include "raylib.h"
|
||||
#include <angelscript.h>
|
||||
#include <scriptstdstring.h>
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
// -------------------------
|
||||
// Functions exposed to AngelScript
|
||||
// -------------------------
|
||||
void Print(const std::string &msg) {
|
||||
std::cout << "[Script] " << msg << std::endl;
|
||||
}
|
||||
|
||||
// -------------------------
|
||||
// AngelScript message callback
|
||||
// -------------------------
|
||||
void AngelScriptMessageCallback(const asSMessageInfo* msg, void* param) {
|
||||
std::cout << msg->section << " (" << msg->row << "): " << msg->message << std::endl;
|
||||
}
|
||||
|
||||
// -------------------------
|
||||
// Main
|
||||
// -------------------------
|
||||
int main() {
|
||||
// Initialize Raylib
|
||||
InitWindow(800, 600, "Raylib + AngelScript");
|
||||
SetTargetFPS(60);
|
||||
|
||||
// Initialize AngelScript
|
||||
asIScriptEngine* engine = asCreateScriptEngine();
|
||||
assert(engine);
|
||||
|
||||
RegisterStdString(engine);
|
||||
|
||||
// Register the message callback
|
||||
int r = engine->SetMessageCallback(asFUNCTION(AngelScriptMessageCallback), nullptr, asCALL_CDECL);
|
||||
assert(r >= 0);
|
||||
|
||||
// Register the Print function for scripts
|
||||
r = engine->RegisterGlobalFunction("void Print(const string &in)", asFUNCTION(Print), asCALL_CDECL);
|
||||
assert(r >= 0);
|
||||
|
||||
// Create a module and add a simple script
|
||||
asIScriptModule* mod = engine->GetModule("Game", asGM_ALWAYS_CREATE);
|
||||
const char* scriptCode =
|
||||
"void main() { "
|
||||
" Print('Hello from AngelScript!'); "
|
||||
"}";
|
||||
mod->AddScriptSection("test", scriptCode);
|
||||
r = mod->Build();
|
||||
if (r < 0) std::cerr << "Failed to build script.\n";
|
||||
|
||||
// Prepare and execute the script
|
||||
asIScriptFunction* func = mod->GetFunctionByDecl("void main()");
|
||||
asIScriptContext* ctx = engine->CreateContext();
|
||||
ctx->Prepare(func);
|
||||
ctx->Execute();
|
||||
ctx->Release();
|
||||
|
||||
// Main loop
|
||||
while (!WindowShouldClose()) {
|
||||
BeginDrawing();
|
||||
ClearBackground(RAYWHITE);
|
||||
DrawText("Raylib + AngelScript running!", 180, 280, 20, DARKGRAY);
|
||||
EndDrawing();
|
||||
}
|
||||
|
||||
// Clean up
|
||||
CloseWindow();
|
||||
engine->Release();
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
void main() {
|
||||
Print("Hello from file script!");
|
||||
}
|
||||
Reference in New Issue
Block a user