Files
Your NameandClaude Opus 5.5 7cf9727bcd Rename the language from Dino to Rex
Files use .rex, the command is rex, and the crate, runtime prefixes,
docs, editor files and examples all use the new name.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 13:51:23 +01:00

34 lines
839 B
Rexx

// A game: bouncing square. Structs are values, no heap, no GC.
import gfx
struct Vec2 {
x, y: f32
func add(b: Vec2): Vec2 { return Vec2{x + b.x, y + b.y} }
func scale(k: f32): Vec2 { return Vec2{x * k, y * k} }
}
struct Player {
pos: Vec2
vel: Vec2
size: f32
func update(dt: f32) { // writes pos/vel: inferred as mutating
pos = pos.add(vel.scale(dt))
if pos.x < 0 || pos.x > 800 { vel.x = -vel.x }
if pos.y < 0 || pos.y > 600 { vel.y = -vel.y }
}
}
func main() {
var win = gfx.open("Rex", 800, 600)
var player = Player{pos: Vec2{100, 100}, vel: Vec2{200, 150}, size: 32}
for win.is_open() {
player.update(win.dt())
win.clear(gfx.BLACK)
win.rect(player.pos.x, player.pos.y, player.size, player.size, gfx.GREEN)
win.present()
}
}