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.

66 lines
2.8 KiB

  1. -------------------------------------------------------------------------------------------
  2. --
  3. -- raylib [models] example - Draw some basic geometric shapes (cube, sphere, cylinder...)
  4. --
  5. -- This example has been created using raylib 1.6 (www.raylib.com)
  6. -- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
  7. --
  8. -- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
  9. --
  10. -------------------------------------------------------------------------------------------
  11. -- Initialization
  12. -------------------------------------------------------------------------------------------
  13. local screenWidth = 800
  14. local screenHeight = 450
  15. InitWindow(screenWidth, screenHeight, "raylib [models] example - geometric shapes")
  16. -- Define the camera to look into our 3d world
  17. local camera = Camera(Vector3(0.0, 10.0, 10.0), Vector3(0.0, 0.0, 0.0), Vector3(0.0, 1.0, 0.0), 45.0)
  18. SetTargetFPS(60) -- Set our game to run at 60 frames-per-second
  19. -------------------------------------------------------------------------------------------
  20. -- Main game loop
  21. while not WindowShouldClose() do -- Detect window close button or ESC key
  22. -- Update
  23. ---------------------------------------------------------------------------------------
  24. -- TODO: Update your variables here
  25. ---------------------------------------------------------------------------------------
  26. -- Draw
  27. ---------------------------------------------------------------------------------------
  28. BeginDrawing()
  29. ClearBackground(RAYWHITE)
  30. Begin3dMode(camera) -- ERROR: Lua Error: attempt to index a number value
  31. DrawCube(Vector3(-4.0, 0.0, 2.0), 2.0, 5.0, 2.0, RED)
  32. DrawCubeWires(Vector3(-4.0, 0.0, 2.0), 2.0, 5.0, 2.0, GOLD)
  33. DrawCubeWires(Vector3(-4.0, 0.0, -2.0), 3.0, 6.0, 2.0, MAROON)
  34. DrawSphere(Vector3(-1.0, 0.0, -2.0), 1.0, GREEN)
  35. DrawSphereWires(Vector3(1.0, 0.0, 2.0), 2.0, 16, 16, LIME)
  36. DrawCylinder(Vector3(4.0, 0.0, -2.0), 1.0, 2.0, 3.0, 4, SKYBLUE)
  37. DrawCylinderWires(Vector3(4.0, 0.0, -2.0), 1.0, 2.0, 3.0, 4, DARKBLUE)
  38. DrawCylinderWires(Vector3(4.5, -1.0, 2.0), 1.0, 1.0, 2.0, 6, BROWN)
  39. DrawCylinder(Vector3(1.0, 0.0, -4.0), 0.0, 1.5, 3.0, 8, GOLD)
  40. DrawCylinderWires(Vector3(1.0, 0.0, -4.0), 0.0, 1.5, 3.0, 8, PINK)
  41. DrawGrid(10, 1.0) -- Draw a grid
  42. End3dMode()
  43. DrawFPS(10, 10)
  44. EndDrawing()
  45. ---------------------------------------------------------------------------------------
  46. end
  47. -- De-Initialization
  48. -------------------------------------------------------------------------------------------
  49. CloseWindow() -- Close window and OpenGL context
  50. -------------------------------------------------------------------------------------------