A kiválasztott változat és az aktuális verzió közötti különbségek a következők.
Előző változat mindkét oldalon Előző változat Következő változat | Előző változat | ||
muszaki_informatika:raylib [2024/01/28 16:59] knehez [Telepítés és konfiguráció] |
muszaki_informatika:raylib [2024/02/20 10:24] (aktuális) knehez [Telepítés és konfiguráció] |
||
---|---|---|---|
Sor 19: | Sor 19: | ||
* **Példák és Tutorialok**: Sok példa és oktatóanyag található az oldalon | * **Példák és Tutorialok**: Sok példa és oktatóanyag található az oldalon | ||
+ | ===== Egyszerű telepítés ===== | ||
+ | |||
+ | A raylib függőséggekkel, példakóddal telepíthető fejlesztőkörnyezet: | ||
+ | |||
+ | {{ :muszaki_informatika:codeblocks.zip | Hordozható codeblocks }} | ||
===== Telepítés és konfiguráció ===== | ===== Telepítés és konfiguráció ===== | ||
+ | |||
+ | Ha már korábban letöltött CodeBlocks rendszeren szeretnénk használni a raylib-et, akkor az alábbi leírás alapján használjuk: | ||
- Van saját telepítője is, de egyszerűbb ha letöltjük az **include** és **lib** fájlokat tartalmazó {{ :muszaki_informatika:raylib.zip |}}-et. | - Van saját telepítője is, de egyszerűbb ha letöltjük az **include** és **lib** fájlokat tartalmazó {{ :muszaki_informatika:raylib.zip |}}-et. | ||
Sor 41: | Sor 48: | ||
// Initialization | // Initialization | ||
- | SetTargetFPS(60); // Set our game to run at 60 frames-per-second | + | SetTargetFPS(60); // Set our app to run at 60 frames-per-second |
// Main game loop | // Main game loop | ||
Sor 74: | Sor 81: | ||
return 0; | return 0; | ||
} | } | ||
- | </sxh> | ||
- | |||
- | <sxh c> | ||
- | #include <raylib.h> | ||
- | #include <math.h> | ||
- | |||
- | int main() { | ||
- | // Initialization | ||
- | const int screenWidth = 800; | ||
- | const int screenHeight = 450; | ||
- | InitWindow(screenWidth, screenHeight, "Sinus Function Plot - raylib"); | ||
- | |||
- | SetTargetFPS(60); // Set FPS | ||
- | |||
- | while (!WindowShouldClose()) { // Main game loop | ||
- | // Update | ||
- | |||
- | // Draw | ||
- | BeginDrawing(); | ||
- | |||
- | ClearBackground(RAYWHITE); // Clear the background | ||
- | |||
- | // Draw the axes | ||
- | Vector2 origin = { (float)screenWidth/2, (float)screenHeight/2 }; | ||
- | DrawLine(origin.x, 0, origin.x, screenHeight, BLACK); // Y-axis | ||
- | DrawLine(0, origin.y, screenWidth, origin.y, BLACK); // X-axis | ||
- | |||
- | // Draw the sine function | ||
- | for(int i = -screenWidth/2; i < screenWidth/2; i++) { | ||
- | // Calculating points | ||
- | float x1 = (float)i; | ||
- | float y1 = sinf(x1 * DEG2RAD) * 100; // Scale the sine wave | ||
- | float x2 = x1 + 1; | ||
- | float y2 = sinf(x2 * DEG2RAD) * 100; // Scale the sine wave | ||
- | |||
- | // Transform points to screen space | ||
- | x1 += origin.x; | ||
- | y1 = origin.y - y1; // Invert y1 to match screen coordinates | ||
- | x2 += origin.x; | ||
- | y2 = origin.y - y2; // Invert y2 to match screen coordinates | ||
- | |||
- | // Draw line segment | ||
- | DrawLine(x1, y1, x2, y2, BLUE); | ||
- | } | ||
- | |||
- | DrawText("Sinus Function Plot", 10, 10, 20, BLACK); // Title | ||
- | DrawText("X-Axis", screenWidth - 50, origin.y + 10, 10, BLACK); // X-axis label | ||
- | DrawText("Y-Axis", origin.x + 10, 10, 10, BLACK); // Y-axis label | ||
- | |||
- | EndDrawing(); | ||
- | } | ||
- | |||
- | CloseWindow(); | ||
- | |||
- | return 0; | ||
- | } | ||
- | |||
</sxh> | </sxh> |