| 1 | #include <math.h> |
| 2 | #include "raylib.h" |
| 3 | |
| 4 | int main() |
| 5 | { |
| 6 | int screenWidth = 800; |
| 7 | int screenHeight = 450; |
| 8 | |
| 9 | InitWindow(screenWidth, screenHeight, "raylib"); |
| 10 | |
| 11 | Camera cam; |
| 12 | cam.position = (Vector3){ 0.0f, 10.0f, 8.f }; |
| 13 | cam.target = (Vector3){ 0.0f, 0.0f, 0.0f }; |
| 14 | cam.up = (Vector3){ 0.0f, 1.f, 0.0f }; |
| 15 | cam.fovy = 60.0f; |
| 16 | |
| 17 | Vector3 cubePos = { 0.0f, 0.0f, 0.0f }; |
| 18 | |
| 19 | SetTargetFPS(60); |
| 20 | |
| 21 | while (!WindowShouldClose()) |
| 22 | { |
| 23 | cam.position.x = sin(GetTime())*10.0f; |
| 24 | cam.position.z = cos(GetTime())*10.0f; |
| 25 | |
| 26 | BeginDrawing(); |
| 27 | ClearBackground(RAYWHITE); |
| 28 | BeginMode3D(cam); |
| 29 | DrawCube(cubePos, 2.f, 2.f, 2.f, RED); |
| 30 | DrawCubeWires(cubePos, 2.f, 2.f, 2.f, MAROON); |
| 31 | DrawGrid(10, 1.f); |
| 32 | EndMode3D(); |
| 33 | DrawText("This is a raylib example", 10, 40, 20, DARKGRAY); |
| 34 | DrawFPS(10, 10); |
| 35 | EndDrawing(); |
| 36 | } |
| 37 | |
| 38 | CloseWindow(); |
| 39 | return 0; |
| 40 | } |