Skip to main content

Prerequisites

Before you begin, make sure you have:
  • Talon installed on your system (Installation Guide)
  • A text editor or IDE of your choice
  • Basic familiarity with programming concepts
New to Wren? Check out the Wren documentation - you can learn the basics in under 30 minutes!

Create Your First Game

Let’s create a simple “Hello World” window with Talon. This will introduce you to the core concepts of Talon game development.
1

Create a Project Directory

Create a new directory for your game and navigate into it:
mkdir my-first-game
cd my-first-game
2

Create Your Main Script

Create a file called index.wren and open it in your text editor:
touch index.wren
3

Write Your Game Code

Add the following code to index.wren:
index.wren
import "raylib" for Color, Raylib, Rectangle, Vector2, Camera2D, KeyCode, Texture2D

var width = 800
var height = 450
var title = "Sample"

Raylib.initWindow(width, height, title)
Raylib.setTargetFPS(60)

var camera = Camera2D.new(
   Vector2.new(2.0, 0.0),
   Vector2.new(0.0, 0.0),
   0.0,
   1.0
)

var target = Raylib.loadRenderTexture(width, height)

while (!Raylib.windowShouldClose()) {
  Raylib.beginDrawing()

  Raylib.clearBackground(Color.Red)

  Raylib.drawText("Congrats! You created your first window!", 190, 200, 20, Color.Green)

  Raylib.getScreenWidth()
  Raylib.getScreenHeight()

  if (Raylib.isKeyDown(KeyCode.KEY_SPACE)) {
      System.print("Space is Pressed")
  }

  Raylib.drawTexturePro(target.texture,
    Rectangle.new(0.0, 0.0, target.texture.width, target.texture.height),
    Rectangle.new(0.0, 0.0, target.texture.width, target.texture.height),
    Vector2.new(0.0, 0.0),
    0.0,
    Color.new(255, 255, 255, 255 )
  )

  Raylib.endDrawing()
}

Raylib.clearBackground(Color.Gray)
Raylib.unloadRenderTexture(target)
Raylib.closeWindow()
4

Run Your Game

Execute your game with Talon:
talon index.wren
You should see a window with a red background and green text!

Understanding the Code

Let’s break down what each part of the code does:
import "raylib" for Color, Raylib, Rectangle, Vector2, Camera2D, KeyCode, Texture2D
This imports the Raylib module and specific classes you’ll use. The raylib module provides access to all Raylib functionality.
var width = 800
var height = 450
var title = "Sample"

Raylib.initWindow(width, height, title)
Raylib.setTargetFPS(60)
This creates a window with the specified dimensions and title, then sets the target frame rate to 60 FPS.
var camera = Camera2D.new(
   Vector2.new(2.0, 0.0),  // offset
   Vector2.new(0.0, 0.0),  // target
   0.0,                     // rotation
   1.0                      // zoom
)
Creates a 2D camera for more advanced rendering. The camera allows you to control viewport, zoom, and rotation.
while (!Raylib.windowShouldClose()) {
  Raylib.beginDrawing()
  // ... drawing code ...
  Raylib.endDrawing()
}
The main game loop runs until the user closes the window. All drawing must happen between beginDrawing() and endDrawing().
if (Raylib.isKeyDown(KeyCode.KEY_SPACE)) {
    System.print("Space is Pressed")
}
Checks if the spacebar is pressed and prints a message to the console.
Raylib.clearBackground(Color.Gray)
Raylib.unloadRenderTexture(target)
Raylib.closeWindow()
Always clean up resources and close the window when your game exits.

Try Hot Reload

One of Talon’s best features is hot reload. Let’s try it!
1

Run with Hot Reload

Start your game with the --hot flag:
talon --hot index.wren
2

Make a Change

While the game is running, edit index.wren and change the background color:
Raylib.clearBackground(Color.Blue)  // Changed from Color.Red
3

See Instant Updates

Save the file and watch your game automatically reload with the new background color!
Hot reload is perfect for tweaking colors, positions, and game parameters without restarting.

Next Steps

Congratulations! You’ve created your first Talon game. Here’s what to explore next:

Learn Wren

Master the Wren language to unlock Talon’s full potential.

Core Concepts

Understand the game loop, project structure, and more.

Explore Examples

Study complete game examples like Breakout and Asteroids.

API Reference

Explore all available Raylib functions and data types.

Build a Simple Interactive Game

Ready for something more interactive? Here’s a simple example with movement:
simple-movement.wren
import "raylib" for Color, Raylib, KeyCode

var screenWidth = 800
var screenHeight = 450

Raylib.initWindow(screenWidth, screenHeight, "Simple Movement")
Raylib.setTargetFPS(60)

// Player position
var playerX = 400
var playerY = 225
var playerSpeed = 5

while (!Raylib.windowShouldClose()) {
  // Update: Handle input
  if (Raylib.isKeyDown(KeyCode.KEY_RIGHT)) playerX = playerX + playerSpeed
  if (Raylib.isKeyDown(KeyCode.KEY_LEFT)) playerX = playerX - playerSpeed
  if (Raylib.isKeyDown(KeyCode.KEY_DOWN)) playerY = playerY + playerSpeed
  if (Raylib.isKeyDown(KeyCode.KEY_UP)) playerY = playerY - playerSpeed
  
  // Draw
  Raylib.beginDrawing()
  Raylib.clearBackground(Color.RayWhite)
  
  // Draw player as a circle
  Raylib.drawCircle(playerX, playerY, 20, Color.Blue)
  
  Raylib.drawText("Use arrow keys to move", 10, 10, 20, Color.DarkGray)
  
  Raylib.endDrawing()
}

Raylib.closeWindow()
Save this as movement.wren and run it:
talon movement.wren
Use the arrow keys to move the blue circle around!

Common Patterns

Here are some common patterns you’ll use in Talon games:

Update-Draw Cycle

while (!Raylib.windowShouldClose()) {
  // 1. Update game state
  // Handle input, update positions, check collisions, etc.
  
  // 2. Draw
  Raylib.beginDrawing()
  Raylib.clearBackground(Color.RayWhite)
  
  // Draw your game objects here
  
  Raylib.endDrawing()
}

Working with Colors

// Use built-in colors
Color.Red
Color.Green
Color.Blue

// Create custom colors (R, G, B, Alpha)
var customColor = Color.new(255, 128, 0, 255)

Input Handling

// Keyboard
if (Raylib.isKeyPressed(KeyCode.KEY_SPACE)) { /* one-time press */ }
if (Raylib.isKeyDown(KeyCode.KEY_SPACE)) { /* held down */ }

// Mouse
var mouseX = Raylib.getMouseX()
var mouseY = Raylib.getMouseY()
if (Raylib.isMouseButtonPressed(0)) { /* left click */ }
Tip: The difference between isKeyPressed() and isKeyDown() is that isKeyPressed() triggers once per press, while isKeyDown() returns true every frame the key is held.

Troubleshooting

Make sure you’re calling Raylib.initWindow() before any other Raylib functions, and check that your screen dimensions are reasonable (not too large or negative).
Use Raylib.setTargetFPS(60) to set a consistent frame rate. The default may vary by system.
Make sure you’re importing the correct module name ("raylib") and that you’re importing the classes you need (like Color, Raylib, etc.).
Ensure you’re running with the --hot flag and saving your file. Note that some errors may prevent hot reload from working until the syntax is corrected.

Need Help?

If you’re stuck, check the GitHub issues or create a new issue for help.

Build docs developers (and LLMs) love