A collection of examples demonstrating the use of RaylibSwift, a Swift wrapper for the Raylib game development library.
- CoreBasicWindow: Demonstrates how to create a basic window using RaylibSwift (core_basic_window)
- CoreInputKeys: Shows how to handle keyboard input (core_input_keys)
- CoreInputMouse: Illustrates mouse input handling (core_input_mouse)
- CoreInputMouseWheel: Demonstrates mouse wheel interaction (core_input_mouse_wheel)
- CoreInputMultitouch: Demonstrates handling multitouch input (core_input_multitouch)
- CoreInputGestures: Shows how to detect and use touch gestures (core_input_gestures)
- CoreInputVirtualControls: Illustrates creation of virtual input controls (core_input_virtual_controls)
- ShapesBasicShapes: Demonstrates drawing basic shapes with RaylibSwift (shapes_basic_shapes)
- ShapesBouncingBall: Shows a simple physics simulation with a bouncing ball (shapes_bouncing_ball)
- ShapesColorsPalette: Displays a color palette with interactive hover effects (shapes_colors_palette)
- ShapesLogoRaylib: Creates the Raylib logo using basic shape primitives (shapes_logo_raylib)
- ShapesLogoRaylibAnim: Animates the Raylib logo with a multi-stage sequence (shapes_logo_raylib_anim)
- ShapesRectangleScaling: Interactive rectangle scaling with mouse drag handles (shapes_rectangle_scaling)
- ShapesLinesBezier: Interactive cubic Bezier curves with draggable control points (shapes_lines_bezier)
- ShapesCollisionArea: Demonstrates rectangle collision detection with area calculation (shapes_collision_area)
- ShapesFollowingEyes: Creates interactive eyes that follow the mouse cursor (shapes_following_eyes)
- ShapesEasingsBallAnim: Shows ball animations using different easing functions (shapes_easings_ball_anim)
- ShapesEasingsBoxAnim: Demonstrates box animations with various easing functions (shapes_easings_box_anim)
- ShapesEasingsRectangleArray: Demonstrates easing animations applied to a grid of rectangles (shapes_easings_rectangle_array)
- ShapesDrawRing: Interactive demo for drawing and customizing ring/circle shapes (shapes_draw_ring)
- ShapesDrawSector: Interactive demo for drawing and customizing circle sectors (shapes_draw_circle_sector)
- ShapesDrawRectangleRounded: Interactive demo for drawing rectangles with rounded corners (shapes_draw_rectangle_rounded)
- Swift 6.0 or later
- macOS, Linux, or other platform supported by Swift
Clone the repository and use Swift package manager to run any example:
# Clone the repository
git clone https://github.com/yourusername/RaylibSwiftExamples.git
cd RaylibSwiftExamples
# Run a specific example
swift run CoreBasicWindow
swift run CoreInputKeys
swift run CoreInputMouse
swift run CoreInputMouseWheelTo add a new example:
- Create a new directory under the appropriate category in the
Sourcesdirectory - Add your Swift code with a
main.swiftfile - Update the
Package.swiftfile with a new executable target - Include a link to the original raylib example in your code comments and in the README
The examples are organized to mirror the Raylib examples repository structure:
Sources/
├── Core/ # Basic window/context and input examples
├── Shapes/ # Drawing basic shapes and primitives
├── Textures/ # Loading and drawing textures
├── Text/ # Font loading and text drawing
├── Models/ # 3D models loading and drawing
├── Shaders/ # Shaders usage examples
├── Audio/ # Audio loading and playing
└── Others/ # Other miscellaneous examples
Contributions are welcome! Please feel free to submit a Pull Request.
When contributing new examples, please:
- Follow the naming convention of the original raylib examples
- Include a link to the corresponding original raylib example
- Add proper documentation comments
This project is licensed under the MIT License - see the LICENSE file for details.
The original Raylib examples that these Swift ports are based on are licensed under the zlib/libpng license. See the Raylib license for details.