Add easing functions

This commit is contained in:
2023-12-29 13:30:37 +01:00
parent 7ec5e2122e
commit 4c39e621fe
5 changed files with 291 additions and 0 deletions

View File

@@ -22,3 +22,6 @@ target_link_libraries(pan_test LINK_PRIVATE Breeze)
add_executable(ui_test ui_test.c)
target_link_libraries(ui_test LINK_PRIVATE Breeze)
add_executable(ease_test ease_test.c)
target_link_libraries(ease_test LINK_PRIVATE Breeze)

59
engine/tests/ease_test.c Normal file
View File

@@ -0,0 +1,59 @@
#define BZ_ENTRYPOINT
#include <breeze.h>
#include <raylib.h>
#include <rlImGui.h>
bool init(int *game) {
rlImGuiSetup(true);
return true;
}
void render(float dt, int *game) {
static f32 x = 0;
x += dt * 2;
//f32 eased = bzEase(BZ_EASE_INOUT_SINE, x);
f32 eased = bzEase(BZ_EASE_OUT_ELASTIC, x);
Rectangle rect = {
500, 500, 200, 400
};
Vector2 origin = {rect.width * 0.5f, rect.height};
BeginDrawing();
ClearBackground(WHITE);
f32 rotation = 45 * (1 - eased);
DrawRectanglePro(rect, origin, rotation, RED);
if (IsKeyReleased(KEY_SPACE)) {
x = 0.0f;
}
rlImGuiBegin();
igBegin("Easing", NULL, 0);
igText("x: %.2f", x);
igText("eased: %.2f", eased);
igText("rotation: %.2f", rotation);
if (igSmallButton("Reset")) {
x = 0.0f;
}
igEnd();
rlImGuiEnd();
EndDrawing();
}
bool bzMain(BzAppDesc *appDesc, int argc, const char **argv) {
appDesc->init = (BzAppInitFunc) init;
appDesc->render = (BzAppRenderFunc) render;
return true;
}