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
|
# Colysis
|
||||||
A little Videogame with a custom engine written in C/C++.
|
A little video game 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.
|
It uses [Flecs](https://github.com/SanderMertens/flecs) as an ECS framework and [Raylib](https://www.raylib.com/) as a 2D graphics library.
|
||||||
|
|
||||||
## Building
|
## Building
|
||||||
To build the project, you need to have [CMake](https://cmake.org/) installed.
|
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.
|
After building, you can run the game by executing the `colysis` executable.
|
||||||
|
|
||||||
## License
|
## 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
|
#define MANGLE_RES_PATH(path) ASSETS_PATH "/" path
|
||||||
|
|
||||||
int init();
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
size_t init(size_t task);
|
||||||
|
|
||||||
void update(float dt);
|
void update(float dt);
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
#include <alyson.hpp>
|
#include <alyson.hpp>
|
||||||
#include <raylib.h>
|
#include <raylib.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
@ -16,31 +15,42 @@ int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
Texture2D logo = LoadTexture(MANGLE_RES_PATH("Raylib_logo.png"));
|
Texture2D logo = LoadTexture(MANGLE_RES_PATH("Raylib_logo.png"));
|
||||||
|
|
||||||
std::cout << "alyson: init" << std::endl;
|
|
||||||
|
|
||||||
int g = init();
|
Camera2D camera = { 0 };
|
||||||
if(g != 0) {
|
camera.target = (Vector2){ 0, 0 };
|
||||||
std::cout << "alyson: init failed with error code " << g << std::endl;
|
camera.offset = (Vector2){ 0, 0 };
|
||||||
return g;
|
camera.rotation = 0.0f;
|
||||||
}
|
camera.zoom = 1.0f;
|
||||||
|
|
||||||
|
init(0);
|
||||||
|
|
||||||
while (!WindowShouldClose()) {
|
while (!WindowShouldClose()) {
|
||||||
|
float dt = GetFrameTime();
|
||||||
|
|
||||||
if (IsWindowResized()) {
|
if (IsWindowResized()) {
|
||||||
SetWindowTitle((std::string(WINDOW_TITLE) + " -- " + std::to_string(GetScreenWidth()) + "x" + std::to_string(GetScreenHeight())).c_str());
|
SetWindowTitle((std::string(WINDOW_TITLE) + " -- " + std::to_string(GetScreenWidth()) + "x" + std::to_string(GetScreenHeight())).c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
BeginDrawing();
|
BeginDrawing();
|
||||||
DrawTexture(logo, GetScreenWidth() / 2 - logo.width / 2, GetScreenHeight() / 2 - logo.height / 2, WHITE);
|
BeginMode2D(camera);
|
||||||
DrawTextFull(
|
ClearBackground(RAYWHITE);
|
||||||
GetFontDefault(),
|
camera.rotation += dt;
|
||||||
WINDOW_TITLE,
|
camera.rotation = (int)camera.rotation % 360;
|
||||||
{ GetScreenWidth() / 2.f, GetScreenHeight() - 60.f },
|
|
||||||
TEXT_ORIENTATION_CENTER, 0.f,
|
|
||||||
40.f, 5.f,
|
|
||||||
0.f, BLACK
|
|
||||||
);
|
|
||||||
|
|
||||||
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();
|
EndDrawing();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,46 +1,46 @@
|
||||||
|
|
||||||
#include <rlyson.h>
|
#include <rlyson.h>
|
||||||
|
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
|
|
||||||
#include "raymath.h"
|
#include "raymath.h"
|
||||||
|
|
||||||
void DrawTextFull(
|
void DrawTextFull(
|
||||||
Font font,
|
const Font font,
|
||||||
const char *text,
|
const char* text,
|
||||||
Vector2 origin,
|
Vector2 origin,
|
||||||
text_orientation_t orientation,
|
const text_orientation_t orientation,
|
||||||
float rotation,
|
const float rotation,
|
||||||
float fontSize,
|
const float fontSize,
|
||||||
float spacing,
|
const float spacing,
|
||||||
float lineSpacing,
|
const float lineSpacing,
|
||||||
Color tint
|
const Color tint
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
Vector2 textSize = MeasureTextEx(font, text, fontSize, spacing);
|
const Vector2 textSize = MeasureTextEx(font, text, fontSize, spacing);
|
||||||
|
|
||||||
DrawCircleV(origin, 10, RED);
|
DrawCircleV(origin, 10, RED);
|
||||||
|
|
||||||
Vector2 pos = origin;
|
const Vector2 pos = origin;
|
||||||
origin = (Vector2){0,0};
|
origin = (Vector2){0,0};
|
||||||
|
|
||||||
switch (orientation) {
|
switch (orientation) {
|
||||||
case TEXT_ORIENTATION_LEFT:
|
case TEXT_ORIENTATION_LEFT:
|
||||||
origin.x += textSize.x;
|
origin.x += textSize.x;
|
||||||
break;
|
break;
|
||||||
case TEXT_ORIENTATION_RIGHT:
|
case TEXT_ORIENTATION_RIGHT:
|
||||||
break;
|
break;
|
||||||
case TEXT_ORIENTATION_CENTER:
|
case TEXT_ORIENTATION_CENTER:
|
||||||
origin.x += (textSize.x / 2);
|
origin.x += (textSize.x / 2);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
origin.y += textSize.y / 2;
|
origin.y += textSize.y / 2;
|
||||||
|
|
||||||
DrawCircleV(Vector2Add(origin, pos), 10, DARKGREEN);
|
DrawCircleV(Vector2Add(origin, pos), 10, DARKGREEN);
|
||||||
|
|
||||||
SetTextLineSpacing(lineSpacing);
|
SetTextLineSpacing((int)lineSpacing);
|
||||||
|
|
||||||
DrawTextPro(font, text, pos, origin, rotation, fontSize, spacing, tint);
|
DrawTextPro(font, text, pos, origin, rotation, fontSize, spacing, tint);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,9 +2,12 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <alyson.hpp>
|
#include <alyson.hpp>
|
||||||
|
|
||||||
int init() {
|
size_t init(size_t task) {
|
||||||
std::cout << "colysis: init" << std::endl;
|
if(task == 0)
|
||||||
return 0;
|
return 2;
|
||||||
|
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void update(float dt) {
|
void update(float dt) {
|
||||||
|
|
Loading…
Reference in a new issue