Iris

0.1.0

Iris: A minimal 2D game engine in Swift.
Chandram-Dutta/Iris

What's New

v0.1.0

2025-12-30T11:25:36Z

Iris

Space Shooter Demo

A minimal 2D game engine in Swift.

Philosophy

Iris provides the bare minimum to make games: a window, a game loop, drawing primitives, and input. No scenes, no ECS, no editor. You write code, you draw pixels.

Public API

Engine.run(game:)     // Entry point
Game                  // Protocol: update() + draw()
Graphics              // Drawing: clear, fillRect, drawImage, drawText
Color                 // RGBA (Float 0-1)
Image                 // Image.load("path.png")
Font                  // Font.system(size: 16)
Input                 // Input.shared.isKeyDown(.space)
Key                   // .left, .right, .up, .down, .w, .a, .s, .d, .space, .escape
DebugInfo             // fps, deltaTime, frameNumber

Hello Game

import Iris

class MyGame: Game {
    func update(deltaTime: TimeInterval, debug: DebugInfo) {
        // game logic here
    }
    
    func draw(_ g: Graphics, debug: DebugInfo) {
        g.clear(Color(r: 0.1, g: 0.1, b: 0.2))
        g.fillRect(x: 100, y: 100, width: 50, height: 50, color: .red)
        g.drawText("Hello Iris", x: 100, y: 200, font: Font.system(size: 24), color: .white)
    }
}

@MainActor func main() {
    Engine().run(game: MyGame())
}

main()

Coordinate System

  • Origin: top-left corner
  • X: increases right
  • Y: increases down
  • Units: pixels

Error Handling

Situation Behavior
Missing image file Returns nil, logs warning
Drawing outside screen Allowed (GPU clips)
Double-loading assets Returns cached handle

Requirements

  • macOS (Metal)
  • Swift 6.2+

Description

  • Swift Tools 6.2.0
View More Packages from this Author

Dependencies

  • None
Last updated: Tue Dec 30 2025 02:10:36 GMT-1000 (Hawaii-Aleutian Standard Time)