Skip to content

theundergroundsorcerer/RaylibSwiftExamples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

86 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RaylibSwiftExamples

A collection of examples demonstrating the use of RaylibSwift, a Swift wrapper for the Raylib game development library.

Examples

Core Examples

Shapes Examples

  • 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)

Getting Started

Prerequisites

  • Swift 6.0 or later
  • macOS, Linux, or other platform supported by Swift

Running Examples

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 CoreInputMouseWheel

Creating New Examples

To add a new example:

  1. Create a new directory under the appropriate category in the Sources directory
  2. Add your Swift code with a main.swift file
  3. Update the Package.swift file with a new executable target
  4. Include a link to the original raylib example in your code comments and in the README

Directory Structure

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

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

When contributing new examples, please:

  1. Follow the naming convention of the original raylib examples
  2. Include a link to the corresponding original raylib example
  3. Add proper documentation comments

License

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.

About

Port of Raylib examples to RaylibSwift

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages