Add easing functions
This commit is contained in:
@@ -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
59
engine/tests/ease_test.c
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user