How to draw a small running triangle from the top left corner to top right with Raylib in C

1 Answer

0 votes
#include "raylib.h"

#define WIDTH 800
#define HEIGHT 600

int main(void)
{
    InitWindow(WIDTH, HEIGHT, "Raylib - Draw a small running triangle from the top left corner to the end of the screen");

    SetTargetFPS(60);

    float pos = 0.0f;
    float gap = 0.0f;

    // Main game loop
    while (!WindowShouldClose())
    {
        BeginDrawing();

        ClearBackground(BLACK);
                   
        
        DrawTriangle((Vector2) { 5.0f + pos + gap, 0.0f },
                     (Vector2) { 0.0f + pos + gap, 5.0f },
                     (Vector2) { 10.0f + pos + gap, 5.0f}, GREEN);

        pos += 5.0f;
        gap += 4.0f;
   
        EndDrawing();
    }

    CloseWindow(); // Close window and OpenGL context

    return 0;
}



/*
run:


*/

 



answered Jan 28 by avibootz

Related questions

1 answer 54 views
1 answer 39 views
1 answer 55 views
1 answer 57 views
1 answer 40 views
...