You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
1005 B

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