formating; alyson licence; Camera2D
This commit is contained in:
parent
04d7c97e93
commit
39abfaa978
6 changed files with 85 additions and 49 deletions
|
@ -1,6 +1,6 @@
|
|||
# Colysis
|
||||
A little Videogame with a custom engine written in C/C++.
|
||||
It uses [Flecs](https://github.com/SanderMertens/flecs) as a ECS framework and [Raylib](https://www.raylib.com/) as a 2D graphics library.
|
||||
A little video game with a custom engine written in C/C++.
|
||||
It uses [Flecs](https://github.com/SanderMertens/flecs) as an ECS framework and [Raylib](https://www.raylib.com/) as a 2D graphics library.
|
||||
|
||||
## Building
|
||||
To build the project, you need to have [CMake](https://cmake.org/) installed.
|
||||
|
@ -33,4 +33,4 @@ cmake --build . --config Release
|
|||
After building, you can run the game by executing the `colysis` executable.
|
||||
|
||||
## License
|
||||
This `colysis` is currently closed source and will not be open sourced. The engine will be licensed under the [MIT license](LICENSE) as soon as it is finished.
|
||||
The game "colysis" will not be open source, but the engine will be licensed under the [MIT license](alyson/LICENSE) as soon as it is finished.
|
||||
|
|
21
alyson/LICENSE
Normal file
21
alyson/LICENSE
Normal file
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2025 n0ffie (noffie.github@icloud.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
|
@ -8,7 +8,9 @@
|
|||
|
||||
#define MANGLE_RES_PATH(path) ASSETS_PATH "/" path
|
||||
|
||||
int init();
|
||||
#include <stdlib.h>
|
||||
|
||||
size_t init(size_t task);
|
||||
|
||||
void update(float dt);
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
#include <alyson.hpp>
|
||||
#include <raylib.h>
|
||||
#include <iostream>
|
||||
|
@ -16,31 +15,42 @@ int main(int argc, char *argv[]) {
|
|||
|
||||
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;
|
||||
}
|
||||
Camera2D camera = { 0 };
|
||||
camera.target = (Vector2){ 0, 0 };
|
||||
camera.offset = (Vector2){ 0, 0 };
|
||||
camera.rotation = 0.0f;
|
||||
camera.zoom = 1.0f;
|
||||
|
||||
init(0);
|
||||
|
||||
while (!WindowShouldClose()) {
|
||||
float dt = GetFrameTime();
|
||||
|
||||
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, 0.f,
|
||||
40.f, 5.f,
|
||||
0.f, BLACK
|
||||
);
|
||||
BeginMode2D(camera);
|
||||
ClearBackground(RAYWHITE);
|
||||
camera.rotation += dt;
|
||||
camera.rotation = (int)camera.rotation % 360;
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
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, 0.f,
|
||||
40.f, 5.f,
|
||||
0.f, BLACK
|
||||
);
|
||||
|
||||
update(dt);
|
||||
render(dt);
|
||||
|
||||
EndMode2D();
|
||||
EndDrawing();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,46 +1,46 @@
|
|||
|
||||
#include <rlyson.h>
|
||||
|
||||
#include "raylib.h"
|
||||
|
||||
#include "raymath.h"
|
||||
|
||||
void DrawTextFull(
|
||||
Font font,
|
||||
const char *text,
|
||||
Vector2 origin,
|
||||
text_orientation_t orientation,
|
||||
float rotation,
|
||||
float fontSize,
|
||||
float spacing,
|
||||
float lineSpacing,
|
||||
Color tint
|
||||
)
|
||||
const Font font,
|
||||
const char* text,
|
||||
Vector2 origin,
|
||||
const text_orientation_t orientation,
|
||||
const float rotation,
|
||||
const float fontSize,
|
||||
const float spacing,
|
||||
const float lineSpacing,
|
||||
const Color tint
|
||||
)
|
||||
{
|
||||
Vector2 textSize = MeasureTextEx(font, text, fontSize, spacing);
|
||||
const Vector2 textSize = MeasureTextEx(font, text, fontSize, spacing);
|
||||
|
||||
DrawCircleV(origin, 10, RED);
|
||||
|
||||
Vector2 pos = origin;
|
||||
const Vector2 pos = origin;
|
||||
origin = (Vector2){0,0};
|
||||
|
||||
|
||||
switch (orientation) {
|
||||
case TEXT_ORIENTATION_LEFT:
|
||||
origin.x += textSize.x;
|
||||
break;
|
||||
case TEXT_ORIENTATION_RIGHT:
|
||||
break;
|
||||
case TEXT_ORIENTATION_CENTER:
|
||||
origin.x += (textSize.x / 2);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
case TEXT_ORIENTATION_LEFT:
|
||||
origin.x += textSize.x;
|
||||
break;
|
||||
case TEXT_ORIENTATION_RIGHT:
|
||||
break;
|
||||
case TEXT_ORIENTATION_CENTER:
|
||||
origin.x += (textSize.x / 2);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
origin.y += textSize.y / 2;
|
||||
|
||||
DrawCircleV(Vector2Add(origin, pos), 10, DARKGREEN);
|
||||
|
||||
SetTextLineSpacing(lineSpacing);
|
||||
SetTextLineSpacing((int)lineSpacing);
|
||||
|
||||
DrawTextPro(font, text, pos, origin, rotation, fontSize, spacing, tint);
|
||||
}
|
||||
|
|
|
@ -2,9 +2,12 @@
|
|||
#include <iostream>
|
||||
#include <alyson.hpp>
|
||||
|
||||
int init() {
|
||||
std::cout << "colysis: init" << std::endl;
|
||||
return 0;
|
||||
size_t init(size_t task) {
|
||||
if(task == 0)
|
||||
return 2;
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void update(float dt) {
|
||||
|
|
Loading…
Reference in a new issue