scene.org File Archive

File download

<root>­/­parties­/­2023­/­vccc23­/­christmas-diamonds/zebulon_cpc_basic_vc3-2023.zip

File size:
28 158 bytes (27.50K)
File date:
2024-01-03 14:15:18
Download count:
all-time: 2

Preview

  • file_id.diz.txt 1.00K
  • result.png 14.62K
  • source.png 16.89K
  • source.txt 142B
  • star.dsk 190.25K

file_id.diz

Christmas Star 2023

Author: Zebulon
Category: Christmas Challenge
System:   CPC
Language: BASIC
Len source code: 142
Len exe file:    n/a
Len code only:   n/a
Instructions:
Install CaPriCe Forever, run it, drag and drop the dsk file into it, click A, type run"star.bas" and press enter.
Description:
Clear screen, set (x,y) coordinates of first star to draw and (a,b) directional vector. Then loop 139 times to print stars at (x,y) positions, update (x,y) with (a,b) vector, update (a,b) vector when limits are reached given that x and y must stay in [1..19] interval, like a ball bouncing in a box, the little trick is that when drawing 39th and 81th stars, the "ball" will make a 90° left turn to continue drawing the pattern, still bouncing. Hope that makes sense. Instead of using IF THEN control, (a,b) vector is updated by a combination of maths and boolean operations, so that the whole program fits in a single line.
Comments:
Thank you for this entertaining contest and warmest season's greetings! :-)
1 CLS:x=4:y=1:a=1:b=1:FOR n=1 TO 139:LOCATE x,y:PRINT "*":x=x+a:y=y+b:a=a*((x=1 OR x=19)+0.5)*2:b=b*((y=1 OR y=19 OR n=39 OR n=81)+0.5)*2:NEXT