home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
64'er 1987 October
/
64er_Magazin_87-10_1987_Markt__Technik_de.d64
/
fr.berge.flaeche
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-10-26
|
4KB
|
148 lines
10 rem ****************************
20 rem * fraktale berge *
30 rem * 1987 by stefan vilsmeier *
40 rem ****************************
50 :
60 if a=0 then a=1:load "fractal.obj",8,1
70 dim h%(128,128),s%(319,1),f%(7,7)
80 open 1,8,15,"u9":close 1: rem diese zeeile kann bei problemen mit dem
90 rem floppyspeeder weggelassen werden!
100 poke53280,15:poke53281,15
110 input "[147][151]grad ";g
120 input "meereshoehe ";n
130 input "lichtquelle ";l1,l2,l3
140 l=sqr(l1*l1+l2*l2+l3*l3)
150 l1=l1/l:l2=l2/l:l3=l3/l
160 rem *********** variablen *****
170 w=128:d=.5:h=128:u=180:r=10:ge=2.25:sq=.866
180 gosub 3500
200 rem ********* anfangswerte ****
210 rem (koennen variiert werden)
220 h%(0,0)=0
230 h%(128,0)=0
240 h%(0,128)=0
250 h%(64,0)=0
260 h%(0,64)=0
270 h%(64,64)=0
300 rem ********* grafik ein ******
310 sys50176,11,15:sys50179,1:sys50194
350 :
360 :
370 rem ****************************
380 rem * berge berechnen *
390 rem ****************************
400 :
410 for m=1 to g
420 :br=w*10:w2=w/2
430 :for t=0 to 127 step w
440 : for i=0 to 127-t step w
450 : b=(h%(i,t)+h%(i+w,t))/2
460 : h%(i+w2,t)=b+(rnd(1)-d)*br
470 : b=(h%(t,i)+h%(t,i+w))/2
480 : h%(t,i+w2)=b+(rnd(1)-d)*br
490 : b=(h%(128-t-i,i)+h%(128-t-i-w,i+w))/2
500 : h%(128-t-i-w2,i+w2)=b+(rnd(1)-d)*br
510 : next i
520 :next t
530 w=w/2
540 next m
650 :
660 :
670 rem ****************************
680 rem * berge zeichnen *
690 rem ****************************
700 :
710 for t=0 to 127 step w
720 :a=t/2:b=a+w:c=(t+w)/2:f=c+w
730 :ss=ge*w:hh=sq*ss:v3=ss*hh
740 :ya=(t+w)+u-h:yb=t+u-h
750 :for i=0 to 127-t step w
760 : ii=127-t-w
770 : h1=h%(i,t)/10:if h1<n then h1=n
780 : h2=h%(i,t+w)/10:if h2<n then h2=n
790 : h3=h%(i+w,t)/10:if h3<n then h3=n
800 : h4=h%(i+w,t+w)/10:if h4<n then h4=n
810 : x1=(i+a)*ge+r:y1=yb-h1
820 : x2=(i+c)*ge+r:y2=ya-h2
830 : x3=(i+b)*ge+r:y3=yb-h3
840 : x4=(i+f)*ge+r:y4=ya-h4
850 : gosub 3200:gosub 3300:ifh1=0andh2=0andh3=0thenfa=0
860 : x=x1:xx=x3:y=y1:yy=y3:gosub 2000
870 : x=x2:xx=x1:y=y2:yy=y1:gosub 2000
880 : x=x2:xx=x3:y=y2:yy=y3:gosub 2000
890 : if i>ii goto 1010
900 : gosub 3200:gosub 3320:ifh2=0andh3=0andh4=0thenfa=0
910 : x=x3:xx=x4:y=y3:yy=y4:gosub 2000
920 : x=x4:xx=x2:y=y4:yy=y2:gosub 2000
930 : x=x2:xx=x3:y=y2:yy=y3:gosub 2000
1010 :next i
1020 next t
1500 get a$:if a$="" goto 1500
1510 sys 50179,0:if a$<>"s" then goto 80:rem neustart
1540 :
1550 :
1560 rem ***************************
1570 rem * 'grafik speichern' *
1580 rem ***************************
1590 :
1600 input "grafik-name ";n$
1610 open 2,8,2,"pi."+n$+",p,w":sys 50191:close 2
1620 goto 80:rem neustart
1950 :
1960 :
1970 rem ***************************
1980 rem * schattieren *
1990 rem ***************************
2000 :
2010 we=abs(x-xx)/(x-xx)
2020 sg=(y-yy)/(x-xx):ys=yy
2030 for xs=xx to x step we
2040 :ys=ys+sg*we
2050 :ifs%(xs,0)=0ands%(xs,1)=0thens%(xs,0)=ys:s%(xs,1)=ys:goto2080
2060 :ifys>s%(xs,1)thens%(xs,1)=ys:gosub3000:goto2080
2070 :ifys<s%(xs,0)thens%(xs,0)=ys:gosub3000
2080 next
2090 return
3000 if s%(xs,0)=0 or s%(xs,1)=0 then return
3010 bx=7 and xs
3020 for v=s%(xs,0) to s%(xs,1)
3030 :zm=0:if fa<f%(bx,vand7)then zm=1
3040 :if bx<0 or bx>319 or v<0 or v>199 goto 3060
3050 :sys 50182,xs,v,zm
3060 next v
3070 return
3200 for p=0 to 319:s%(p,0)=0:s%(p,1)=0:next:return
3250 :
3260 :
3270 rem ***************************
3280 rem * winkel zum licht ber. *
3290 rem ***************************
3300 :
3310 v1=-hh*(h3-h1):v3=ss*((h1+h3)/2-h2):goto 3330
3320 v1=-hh*(h2-h0):v3=ss*((h0+h2)/2-h1)
3330 l=sqr(v1*v1+v2*v2+v3*v3):if l=0 then l=.000000001
3340 co=abs((l1*v1+l2*v2+l3*v3)/l)
3350 if co>1 then co=1
3360 fa=co*50
3370 return
3450 :
3460 :
3470 rem ***************************
3480 rem * raster einlesen *
3490 rem ***************************
3500 :
3510 for i=0 to 7
3520 :for t=0 to 7
3530 : read f%(t,i)
3540 :next t
3550 next i
3560 return
3600 data 0, 8,53,61, 2,10,55,63
3610 data 16,24,37,45,18,26,39,47
3620 data 49,57, 4,12,51,59, 6,14
3630 data 33,41,20,28,35,43,22,30
3640 data 3,11,54,62, 1, 9,52,60
3650 data 19,27,38,46,17,25,36,44
3660 data 50,58, 7,15,48,56, 5,13
3670 data 34,42,23,31,32,40,21,29