{"id":13465747,"url":"https://github.com/STREGAsGate/Raylib","last_synced_at":"2025-03-25T16:32:50.726Z","repository":{"id":41980883,"uuid":"408223788","full_name":"STREGAsGate/Raylib","owner":"STREGAsGate","description":"A Swift package for Raylib. Builds Raylib from source so no need to fiddle with libraries. Just add as a dependency in you game package and go!","archived":false,"fork":false,"pushed_at":"2022-12-29T15:59:42.000Z","size":2392,"stargazers_count":117,"open_issues_count":6,"forks_count":17,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-11T23:05:06.640Z","etag":null,"topics":["gamedev","raylib","raylib-swift","swift"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/STREGAsGate.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["raysan5","STREGAsGate"],"patreon":"STREGAsGate","ko_fi":"STREGAsGate"}},"created_at":"2021-09-19T19:57:12.000Z","updated_at":"2025-02-24T09:08:34.000Z","dependencies_parsed_at":"2023-01-31T09:16:06.568Z","dependency_job_id":null,"html_url":"https://github.com/STREGAsGate/Raylib","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/STREGAsGate%2FRaylib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/STREGAsGate%2FRaylib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/STREGAsGate%2FRaylib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/STREGAsGate%2FRaylib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/STREGAsGate","download_url":"https://codeload.github.com/STREGAsGate/Raylib/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245500462,"owners_count":20625586,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gamedev","raylib","raylib-swift","swift"],"created_at":"2024-07-31T15:00:34.794Z","updated_at":"2025-03-25T16:32:49.328Z","avatar_url":"https://github.com/STREGAsGate.png","language":"C","readme":"# Raylib for Swift\n\u003ca href=\"https://swift.org\"\u003e\u003cimg style=\"vertical-align:middle\" src=https://aws1.discourse-cdn.com/swift/original/1X/0a90dde98a223f5841eeca49d89dc9f57592e8d6.png width=\"50\"\u003e\u003c/a\u003e\u003ca href=\"https://www.raylib.com\"\u003e\u003cimg style=\"vertical-align:middle\" src=https://www.raylib.com/common/img/raylib_logo.png width=\"50\"\u003e\u003c/a\u003e\n\n[![Windows](https://github.com/STREGAsGate/Raylib/actions/workflows/Windows.yml/badge.svg)](https://github.com/STREGAsGate/Raylib/actions/workflows/Windows.yml) [![macOS](https://github.com/STREGAsGate/Raylib/actions/workflows/macOS.yml/badge.svg)](https://github.com/STREGAsGate/Raylib/actions/workflows/macOS.yml) [![Linux](https://github.com/STREGAsGate/Raylib/actions/workflows/Linux.yml/badge.svg)](https://github.com/STREGAsGate/Raylib/actions/workflows/Linux.yml) \n\n[![Twitter](https://img.shields.io/twitter/follow/stregasgate?style=social)](https://twitter.com/stregasgate)\n[![YouTube](https://img.shields.io/youtube/channel/subscribers/UCBXFkK2B4w9856wBJfCGufg?label=Subscribe\u0026style=social)](https://youtube.com/stregasgate)\n[![Reddit](https://img.shields.io/reddit/subreddit-subscribers/stregasgate?style=social)](https://www.reddit.com/r/stregasgate/)\n[![Discord](https://img.shields.io/discord/641809158051725322?label=Hang%20Out\u0026logo=Discord\u0026style=social)](https://discord.gg/5JdRJhD)\n\nThis package brings [Raylib](https://www.raylib.com/) to [Swift](https://www.swift.org/).\n\nRaylib for Swift uses Swift's C interoperability and compiler to build Raylib from source code. Just add the package as a dependency (to your swift executable package) and start making games!\n\n## Requirements \u0026 Setup\n\nOn Windows and macOS you only need Swift. For Linux, see [install required libraries](https://github.com/raysan5/raylib/wiki/Working-on-GNU-Linux#install-required-libraries).\n\n### Creating a new project\n\n**1.** Create a Swift package for your project.\n\n```Bash\n$ cd my/projects/folder/path\n$ mkdir MyGame\n$ cd MyGame\n$ swift package init --type executable\n```\n\n**2.** Edit the newly created `Package.swift` to add Raylib to the dependencies array:\n\n```swift\n.package(url: \"https://github.com/STREGAsGate/Raylib.git\", branch: \"master\")\n```\n\nOn Windows and macOS you only need Swift. For linux, see [install required libraries](https://github.com/raysan5/raylib/wiki/Working-on-GNU-Linux#install-required-libraries).\n\n  \u003e Note: `.branch(\"master\")` is required, you cannot use tags, commits, or versions. Swift doesn't allow unsafe build flags for specific versions and build flags are required to build Raylib, so you must use master at this time or you will get an error from SwiftPM.\n\n**3.** Add the following to the `static func main()` in MyGame.swift.\n\n```Swift\n    let screenWidth: Int32 = 800\n    let screenHeight: Int32 = 450\n\n    Raylib.initWindow(screenWidth, screenHeight, \"MyGame\")\n    Raylib.setTargetFPS(30)\n    let randomColors: [Color] = [.blue, .red, .green, .yellow, .darkBlue, .maroon, .magenta]\n    var ballColor: Color = .maroon\n    var ballPosition = Vector2(x: -100, y: -100)\n    var previousBallPosition: Vector2\n    while Raylib.windowShouldClose == false {\n        // update\n        previousBallPosition = ballPosition\n        ballPosition = Raylib.getMousePosition()\n        if Raylib.isMouseButtonDown(.left) {\n            ballColor = randomColors.randomElement() ?? .black\n        }\n        let size = max(abs(ballPosition.x - previousBallPosition.x) + abs(ballPosition.y - previousBallPosition.y), 10)\n\n        // draw\n        Raylib.beginDrawing()\n        Raylib.clearBackground(.rayWhite)\n        Raylib.drawText(\"Hello, world!\", 425, 25, 25, .darkGray)\n        Raylib.drawCircleV(ballPosition, size, ballColor)\n        Raylib.drawFPS(10, 10)\n        Raylib.endDrawing()\n    }\n    Raylib.closeWindow()\n```\n\n## About\n\nOriginal Raylib global functions are now static members of the `Raylib` type.\n\n```swift\nRaylib.initWindow(screenWidth, screenheight, \"My First Raylib Window!\")\n```\n\nIt's a goal of this project to have all the global functions available on their respective types as members.\n\nAs an example `Image`, now has new initializers.\n```swift\nlet image = Image(color: .green, width: 256, height: 256)\n```\nDoing this for the entire API will increase discoverability and make Raylib for Swift a more Swifty experience.\n","funding_links":["https://github.com/sponsors/raysan5","https://github.com/sponsors/STREGAsGate","https://patreon.com/STREGAsGate","https://ko-fi.com/STREGAsGate"],"categories":["Libs","C"],"sub_categories":["Game Engine"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSTREGAsGate%2FRaylib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FSTREGAsGate%2FRaylib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSTREGAsGate%2FRaylib/lists"}