ZX BASIC Coded Warning Sign
Radioactivity
Every week I try to enter #WCCChallenge, which is held every Sunday by SableRaph.
This week the topic chosen is Radioactivity. The idea is to come up with some creative coding loveliness based on the chosen topic. I entered ZX Spectrum as a hopeful topic but it wasn't picked. But...I thought why not Zoidberg do both?
I had an idea last night to load up FUSE and see what I could do with it on the topic (it was in a slim lead against Gears at the time. Click to see my possible entry to that subject). It's been around 35 years since I last tried any Spectrum coding. I wasn't going to touch assembly though (see this post for my last foray into that!) so I used ZX BASIC to make a Danger Radioactive sign. The original takes almost two minutes to render so I sped up the video.
Below is the code, written in Boriel ZX BASIC style (no line numbers needed). To convert to a workable .tap file you should use zmakebas with the following command: zmakebas file.bas -l -o file.tap
REM Radioactive Warning Sign
REM Works on ZX Spectrum or Boriel ZX BASIC
REM Set colors: Black ink (0) on Yellow paper (6)
BRIGHT 1
BORDER 0: PAPER 6: INK 0: CLS
REM Centre coordinates
LET cx = 128
LET cy = 88
REM Draw the Hub (Filled inner circle)
FOR r = 1 TO 12
CIRCLE cx, cy, r
NEXT r
REM Draw 3 radiation blades (60 degrees wide each)
REM We draw lines from the inner radius (12) to outer (60)
FOR b = 0 TO 240 STEP 120
REM Draw every 0.5 degrees for a smooth fill
FOR d = 0 TO 60 STEP 0.5
REM Calculate angle in radians
LET rad = (b + d) * PI / 180
REM Start at the edge of the hub
LET x1 = cx + 12 * COS(rad)
LET y1 = cy + 12 * SIN(rad)
REM Calculate the length to draw (60 - 12 = 48 pixels)
LET dx = 48 * COS(rad)
LET dy = 48 * SIN(rad)
PLOT x1, y1
DRAW dx, dy
NEXT d
NEXT b
REM Draw the outer circular border (optional outline)
FOR r = 65 TO 75
CIRCLE cx, cy, r
NEXT r
PRINT AT 0, 13; "DANGER"
PRINT AT 21, 11; "RADIOACTIVE"

Comments
Post a Comment