본문 바로가기
[ChatGPT] Sample Code 샘플 코드

[ChatGPT][Raylib] Raylib를 사용하여 기본 창을 만들고 색상이 지정된 사각형을 그리는 간단한 샘플 코드

by byungwoo733 2024. 1. 2.
728x90
반응형
SMALL
gcc -o my_game my_game.c -lraylib -lopengl32 -lgdi32 -lwinmm​
#include "raylib.h"

int main(void)
{
    // Initialization
    const int screenWidth = 800;
    const int screenHeight = 450;

    InitWindow(screenWidth, screenHeight, "raylib Sample");

    SetTargetFPS(60); // Set the frames per second

    // Main game loop
    while (!WindowShouldClose()) // Detect window close button or ESC key
    {
        // Update

        // Draw
        BeginDrawing();

        ClearBackground(RAYWHITE); // Clear the background

        // Draw a colored rectangle
        DrawRectangle(screenWidth / 4, screenHeight / 4, screenWidth / 2, screenHeight / 2, RED);

        DrawText("Hello, raylib!", 10, 10, 20, DARKGRAY);

        EndDrawing();
    }

    // De-Initialization
    CloseWindow(); // Close the window and OpenGL context

    return 0;
}

Raylib를 사용하여 기본 창을 만들고 색상이 지정된 사각형을 그리는 간단한 샘플 코드

=============================

GCC를 사용한 컴파일 명령의 예

gcc -o my_game my_game.c -lraylib -lopengl32 -lgdi32 -lwinmm

 

728x90
LIST

댓글