switching to cmake; alyson setup

This commit is contained in:
n0ffie 2025-02-06 22:47:32 +01:00
parent 9504620227
commit 23a40216de
20 changed files with 307 additions and 125300 deletions

43
alyson/src/alyson.cpp Normal file
View file

@ -0,0 +1,43 @@
#include <alyson.hpp>
#include <raylib.h>
#include <iostream>
#include <string>
#include <rlyson.h>
#define WINDOW_TITLE "Alyson Engine"
int main(int argc, char *argv[]) {
SetTargetFPS(60);
InitWindow(900, 500, WINDOW_TITLE " -- 900x500");
Texture2D logo = LoadTexture(MANGLE_RES_PATH("Raylib_logo.png"));
std::cout << "alyson: init" << std::endl;
int g = init();
if(g != 0) {
std::cout << "alyson: init failed with error code " << g << std::endl;
return g;
}
while (!WindowShouldClose()) {
if (IsWindowResized()) {
SetWindowTitle((std::string(WINDOW_TITLE) + " -- " + std::to_string(GetScreenWidth()) + "x" + std::to_string(GetScreenHeight())).c_str());
}
BeginDrawing();
DrawTexture(logo, GetScreenWidth() / 2 - logo.width / 2, GetScreenHeight() / 2 - logo.height / 2, WHITE);
DrawTextFull(GetFontDefault(), WINDOW_TITLE, { GetScreenWidth() / 2.f, GetScreenHeight() - 60.f }, TEXT_ORIENTATION_CENTER, 40.f, 0.f, 0.f, WHITE);
ClearBackground(RAYWHITE);
EndDrawing();
}
UnloadTexture(logo);
CloseWindow();
return 0;
}

28
alyson/src/rlyson.c Normal file
View file

@ -0,0 +1,28 @@
#include <rlyson.h>
void DrawTextFull(
Font font,
const char *text,
Vector2 origin,
text_orientation_t orientation,
float fontSize,
float spacing,
float lineSpacing,
Color tint
)
{
Vector2 textSize = MeasureTextEx(font, text, fontSize, spacing);
switch (orientation) {
case TEXT_ORIENTATION_LEFT:
origin.x -= textSize.x;
break;
case TEXT_ORIENTATION_RIGHT:
origin.x += textSize.x;
break;
case TEXT_ORIENTATION_CENTER:
origin.x -= textSize.x / 2;
break;
}
DrawTextPro(font, text, textSize, origin, 0, spacing, lineSpacing, tint);
}