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>
This commit is contained in:
1 parent
2f44f09b6a
commit
7cf9727bcd
94 files changed
+858
-858
No files matched your search
@@ -0,0 +1,33 @@
|
||||
// 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()
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user