feat: re-organise files

This commit is contained in:
2025-11-05 23:18:44 +13:00
parent e925faf21e
commit 29d52c4578
12 changed files with 382 additions and 159 deletions

33
src/ScriptBindings.cpp Normal file
View File

@@ -0,0 +1,33 @@
#include "ScriptBindings.h"
#include "raylib.h"
#include <iostream>
#include <assert.h>
void ScriptBindings::RegisterAll(asIScriptEngine* engine) {
// Register Print function
int r = engine->RegisterGlobalFunction("void Print(const string &in)",
asFUNCTION(Print), asCALL_CDECL);
assert(r >= 0);
// Register DrawText function
r = engine->RegisterGlobalFunction("void DrawText(const string &in, int, int, int, uint)",
asFUNCTION(AS_DrawText), asCALL_CDECL);
assert(r >= 0);
}
void ScriptBindings::Print(const std::string &msg) {
std::cout << "[Script] " << msg << std::endl;
}
Color ColorFromUInt(unsigned int c) {
Color col;
col.r = (c >> 24) & 0xFF;
col.g = (c >> 16) & 0xFF;
col.b = (c >> 8) & 0xFF;
col.a = c & 0xFF;
return col;
}
void ScriptBindings::AS_DrawText(const std::string &text, int x, int y, int fontSize, unsigned int color) {
DrawText(text.c_str(), x, y, fontSize, ColorFromUInt(color));
}