dos33fsprogs/galaxy/galaxy_hgr.bas
2019-12-08 20:34:57 -05:00

94 lines
2.4 KiB
QBasic

' cls()
10 HGR
' ::_::
'for i=0,1600 do
20 FOR I=0 TO 1600
'if(i<15)pal(i,({0,128,130,2,136,8,142,137,9,10,135,7})[i+1],1)
30 REM
'x=rnd(128)
40 X=RND(1)*128
'y=rnd(128)
50 Y=RND(1)*128
'a=atan2(x-64,y-64)+.17
'60 A=ATN(X-20,Y-20)+.17
'60 IF Y-64>0 THEN A=ATN((X-64)/(Y-64)):GOTO 68
'61 IF Y-64=0 THEN A=1.57*SGN(X-64):GOTO 68
'62 A=ATN((X-64)/(Y-64))+3.14*SGN(X-64)
' PICO-8 uses TURNS instead of RADIANS so this is equivelant to roughly 1 radian
'68 A=A+1
60 IF X-64=0 AND Y-64=0 THEN GOTO 40
' X>0 case, plain ATN, Quadrants I and IV
64 IF X-64>0 THEN A=ATN((Y-64)/(X-64)):GOTO 68
' X=0 then pi/2 or -pi/2 depending on Y
65 IF X-64=0 THEN A=1.57*SGN(Y-64):GOTO 68
' X<0 and Y>=0, Quadrant II
67 IF Y-64>=0 THEN A=ATN((Y-64)/(X-64))+3.14:GOTO 68
' X<0 and Y<0 Quadrant III
67 A=ATN((Y-64)/(X-64))-3.14
68 A=A+1
'69 PRINT A
'd=rnd(7)
70 D=RND(1)*7
'pset(x+cos(a)*d,y+sin(a)*d/3-cos(a)*d/4,max(0,pget(x,y)+.87-rnd()))
' 1+.87-.99 = .88
' 1+.87-0.0 = 1.87
'80 C=SCRN(X/3.3,Y/3.3)+1.37-RND(1)
80 GOSUB 1100
81 C=C+0.87-RND(1)
82 IF C<0 THEN C=0
83 IF C>7 THEN C=7
84 HCOLOR=C
85 XX=(X+COS(A)*D)
87 YY=(Y+SIN(A)*D/3-COS(A)*D/4)
88 IF XX<0 OR XX>240 GOTO 100
89 IF YY<0 OR YY>192 GOTO 100
90 HPLOT XX,YY
'end
100 NEXT I
' circfill(64,64,5,11)
110 HCOLOR=7
115 HPLOT 61,60 TO 69,60:HPLOT 60,61 TO 70,61:HPLOT 60,62 TO 70,62
117 HPLOT 60,63 TO 70,63:HPLOT 60,64 TO 70,64:HPLOT 60,65 TO 70,65
119 HPLOT 60,66 TO 70,66:HPLOT 60,67 TO 70,67:HPLOT 61,68 TO 69,68
'125 INPUT A$
130 GOTO 20
'flip()goto _
1100 REM GET HCOLOR
1110 REM PARAMETERS: X Y
1120 REM RETURNS: C
1130 REM
1140 HP = 0:HX = X + 1:HY=Y
1150 ON (HX < 280) GOSUB 1300
1160 PR = HP:HP = 0:HX = HX - 2
1170 ON (HX > = 0) GOSUB 1300
1180 PL = HP:HX = HX + 1: GOSUB 1300
1190 ODD = HX - INT (HX / 2) * 2
1200 C = HH * 4
1210 IF NOT ((PL = PR) AND (PL < > HP)) THEN C = C + HP * 3: RETURN
1220 IF ODD THEN HP = NOT HP
1230 C = C + HP + 1
1240 RETURN
1250 REM
1260 REM GET PIXEL
1270 REM PARAMETERS: HX HY
1280 REM RETURNS: HH HP
1290 REM
1300 HH = INT (HX / 7)
1310 HV = INT (HY / 8)
1320 VO = PEEK (37)
1330 HO = PEEK (36)
1340 VTAB HV + 1: HTAB 1
1350 HA = PEEK (41) * 256
1360 HA = HA + PEEK (40) + HH
1370 VTAB VO + 1: HTAB HO + 1
1380 HA = HA + 8192 - 1024
1390 HP = PEEK (230) / 32
1400 IF HP = 2 THEN HA = HA + 8192
1410 HA = HA + (HY - HV * 8) * 1024
1420 HB = HX - HH * 7
1430 HV = PEEK (HA)
1440 HH = INT (HV / 128)
1450 HV = INT (HV / (2 ^ HB))
1460 HP = HV - INT (HV / 2) * 2
1470 RETURN