mirror of
https://github.com/imjasonh/nescript
synced 2026-07-08 08:55:38 +00:00
- CI: new "Build Examples" job compiles all .ne files and validates the output ROMs have correct iNES headers - Examples: add notes explaining that sprite names (Smiley, Ball) are parsed but not yet resolved — all draws use the built-in CHR tile 0. Custom sprite declarations come in M3. - Codegen: explicit `let _ = &draw.sprite_name` to document the intentional skip, with comment about M2/M3 scope https://claude.ai/code/session_01W6eQFStA66EuMKHUFo2rx3
41 lines
906 B
Text
41 lines
906 B
Text
// Bouncing Ball — a sprite that bounces around the screen automatically.
|
|
//
|
|
// Build: cargo run -- build examples/bouncing_ball.ne
|
|
// Output: examples/bouncing_ball.nes
|
|
//
|
|
// Note: In M1 the sprite name in `draw` is parsed but not resolved.
|
|
// All sprites use tile 0 from the built-in CHR data (a smiley face).
|
|
// Custom sprite declarations come in M3.
|
|
|
|
game "Bouncing Ball" {
|
|
mapper: NROM
|
|
}
|
|
|
|
var px: u8 = 64
|
|
var py: u8 = 64
|
|
var dx: u8 = 1 // 1 = moving right, 0 = moving left
|
|
var dy: u8 = 1 // 1 = moving down, 0 = moving up
|
|
|
|
on frame {
|
|
// Move horizontally
|
|
if dx == 1 {
|
|
px += 1
|
|
if px >= 240 { dx = 0 }
|
|
} else {
|
|
px -= 1
|
|
if px == 0 { dx = 1 }
|
|
}
|
|
|
|
// Move vertically
|
|
if dy == 1 {
|
|
py += 1
|
|
if py >= 224 { dy = 0 }
|
|
} else {
|
|
py -= 1
|
|
if py == 0 { dy = 1 }
|
|
}
|
|
|
|
draw Ball at: (px, py)
|
|
}
|
|
|
|
start Main
|