Skip to content

Commit 4eebab8

Browse files
committed
BOING
1 parent 27c37ed commit 4eebab8

2 files changed

Lines changed: 80 additions & 0 deletions

File tree

examples/boing.bas

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
#OPTION petscii
2+
3+
REM ================================
4+
REM BOING!
5+
REM Amiga Boing Ball Tribute
6+
REM for RGC-BASIC
7+
REM ================================
8+
REM
9+
REM Uses SCREEN 1 bitmap for the grid
10+
REM and a PNG sprite sheet for the ball.
11+
REM
12+
REM Requires: boing_sheet.png (768x64
13+
REM sprite sheet, 12 frames of 64x64)
14+
15+
REM Switch to 320x200 bitmap mode
16+
SCREEN 1
17+
COLOR 1
18+
BACKGROUND 6
19+
20+
REM Load the ball sprite sheet
21+
REM 12 frames, each 64x64 pixels
22+
LOADSPRITE 1, "boing_sheet.png", 64, 64
23+
LOADSPRITE 2, "boing_shadow.png"
24+
SPRITEMODULATE 2, 150, 255, 255, 255
25+
SPRITEVISIBLE 1, 1
26+
SPRITEVISIBLE 2, 1
27+
28+
29+
REM Draw the grid background
30+
GOSUB DrawGrid
31+
32+
REM Ball position, velocity, sprite frame index (BF — avoid name FRAME; clashes with SPRITEFRAME in some editors)
33+
REM One line keeps numbered-line IDEs from inserting an unnumbered "FRAME = 1" (that breaks parsing).
34+
BX = 40 : BY = 10 : VX = 2 : VY = 2 : BF = 1
35+
36+
REM ~10 animation fps: 60 jiffies/s / 10 = 6 jiffies per sprite frame (TI = wall clock in canvas/basic-gfx)
37+
JIFFIES_PER_FRAME = 6
38+
LAST = TI
39+
40+
REM === Main Loop ===
41+
DO
42+
43+
DRAWSPRITE 2, BX+8, BY+8, 1
44+
REM Draw ball at current rotation frame
45+
DRAWSPRITETILE 1, BX, BY, BF, 2
46+
47+
48+
49+
SLEEP 1
50+
51+
REM Update position every frame (movement speed unchanged)
52+
BX = BX + VX
53+
BY = BY + VY
54+
55+
REM Advance rotation on TI — independent of movement
56+
IF TI - LAST >= JIFFIES_PER_FRAME THEN
57+
LAST = TI
58+
BF = BF + 1
59+
IF BF > 12 THEN BF = 1
60+
END IF
61+
62+
REM Bounce off edges
63+
IF BX < 0 OR BX > 256 THEN VX = -VX
64+
IF BY < 0 OR BY > 130 THEN VY = -VY
65+
66+
LOOP
67+
68+
REM ----- Draw grid with LINE -----
69+
DrawGrid:
70+
REM Vertical lines
71+
FOR X = 20 TO 300 STEP 20
72+
LINE X, 0 TO X, 199
73+
NEXT X
74+
75+
REM Horizontal lines
76+
FOR Y = 14 TO 199 STEP 14
77+
LINE 0, Y TO 319, Y
78+
NEXT Y
79+
RETURN
80+

examples/boing_shadow.png

1.74 KB
Loading

0 commit comments

Comments
 (0)