Review ALL examples
This commit is contained in:
parent
a43a7980a3
commit
b525039e0a
96 changed files with 1301 additions and 1317 deletions
|
@ -13,7 +13,7 @@
|
|||
|
||||
#include "easings.h" // Required for easing functions
|
||||
|
||||
int main()
|
||||
int main(void)
|
||||
{
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
@ -21,16 +21,16 @@ int main()
|
|||
const int screenHeight = 450;
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib [shapes] example - easings box anim");
|
||||
|
||||
|
||||
// Box variables to be animated with easings
|
||||
Rectangle rec = { GetScreenWidth()/2, -100, 100, 100 };
|
||||
float rotation = 0.0f;
|
||||
float alpha = 1.0f;
|
||||
|
||||
|
||||
int state = 0;
|
||||
int framesCounter = 0;
|
||||
|
||||
SetTargetFPS(60);
|
||||
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
|
@ -43,12 +43,12 @@ int main()
|
|||
case 0: // Move box down to center of screen
|
||||
{
|
||||
framesCounter++;
|
||||
|
||||
|
||||
// NOTE: Remember that 3rd parameter of easing function refers to
|
||||
// desired value variation, do not confuse it with expected final value!
|
||||
rec.y = EaseElasticOut(framesCounter, -100, GetScreenHeight()/2 + 100, 120);
|
||||
|
||||
if (framesCounter >= 120)
|
||||
if (framesCounter >= 120)
|
||||
{
|
||||
framesCounter = 0;
|
||||
state = 1;
|
||||
|
@ -59,8 +59,8 @@ int main()
|
|||
framesCounter++;
|
||||
rec.height = EaseBounceOut(framesCounter, 100, -90, 120);
|
||||
rec.width = EaseBounceOut(framesCounter, 100, GetScreenWidth(), 120);
|
||||
|
||||
if (framesCounter >= 120)
|
||||
|
||||
if (framesCounter >= 120)
|
||||
{
|
||||
framesCounter = 0;
|
||||
state = 2;
|
||||
|
@ -70,8 +70,8 @@ int main()
|
|||
{
|
||||
framesCounter++;
|
||||
rotation = EaseQuadOut(framesCounter, 0.0f, 270.0f, 240);
|
||||
|
||||
if (framesCounter >= 240)
|
||||
|
||||
if (framesCounter >= 240)
|
||||
{
|
||||
framesCounter = 0;
|
||||
state = 3;
|
||||
|
@ -81,8 +81,8 @@ int main()
|
|||
{
|
||||
framesCounter++;
|
||||
rec.height = EaseCircOut(framesCounter, 10, GetScreenWidth(), 120);
|
||||
|
||||
if (framesCounter >= 120)
|
||||
|
||||
if (framesCounter >= 120)
|
||||
{
|
||||
framesCounter = 0;
|
||||
state = 4;
|
||||
|
@ -92,7 +92,7 @@ int main()
|
|||
{
|
||||
framesCounter++;
|
||||
alpha = EaseSineOut(framesCounter, 1.0f, -1.0f, 160);
|
||||
|
||||
|
||||
if (framesCounter >= 160)
|
||||
{
|
||||
framesCounter = 0;
|
||||
|
@ -101,7 +101,7 @@ int main()
|
|||
} break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
|
||||
// Reset animation at any moment
|
||||
if (IsKeyPressed(KEY_SPACE))
|
||||
{
|
||||
|
@ -112,7 +112,7 @@ int main()
|
|||
framesCounter = 0;
|
||||
}
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
@ -120,7 +120,7 @@ int main()
|
|||
ClearBackground(RAYWHITE);
|
||||
|
||||
DrawRectanglePro(rec, (Vector2){ rec.width/2, rec.height/2 }, rotation, Fade(BLACK, alpha));
|
||||
|
||||
|
||||
DrawText("PRESS [SPACE] TO RESET BOX ANIMATION!", 10, GetScreenHeight() - 25, 20, LIGHTGRAY);
|
||||
|
||||
EndDrawing();
|
||||
|
@ -128,7 +128,7 @@ int main()
|
|||
}
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
//--------------------------------------------------------------------------------------
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue