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.

37 lines
983 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.0f, 10.0f, 8.f };
  9. cam.target = (Vector3){ 0.0f, 0.0f, 0.0f };
  10. cam.up = (Vector3){ 0.0f, 1.f, 0.0f };
  11. cam.fovy = 60.0f;
  12. Vector3 cubePos = { 0.0f, 0.0f, 0.0f };
  13. SetTargetFPS(60);
  14. while (!WindowShouldClose()) {
  15. cam.position.x = sin(GetTime()) * 10.0f;
  16. cam.position.z = cos(GetTime()) * 10.0f;
  17. BeginDrawing();
  18. ClearBackground(RAYWHITE);
  19. BeginMode3D(cam);
  20. DrawCube(cubePos, 2.f, 2.f, 2.f, RED);
  21. DrawCubeWires(cubePos, 2.f, 2.f, 2.f, MAROON);
  22. DrawGrid(10, 1.f);
  23. EndMode3D();
  24. DrawText("This is a raylib example", 10, 40, 20, DARKGRAY);
  25. DrawFPS(10, 10);
  26. EndDrawing();
  27. }
  28. CloseWindow();
  29. return 0;
  30. }