feat: re-organise files
This commit is contained in:
33
src/ScriptBindings.cpp
Normal file
33
src/ScriptBindings.cpp
Normal 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));
|
||||
}
|
||||
Reference in New Issue
Block a user