40 rem trap 300
44 h%=sch(0)
48 w%=scw(0)
50 gt 200
51 print "okay-okay, "+str$(obx%)
52 repaint
53 sleep 2000
54 ret
101 rem ----------
102 rem çàãðóçêà ðåñóðñîâ 200
105 rem çàãðóçêà êàðòû 900
106 rem ôèçèêà 1900
107 rem ïåðåìåùåíèå êàìåðû 2300
108 rem ïîðòàëû 3300
109 rem èãðîâîé öèêë 4900
110 rem You tested code. Code tested you.
111 rem ----------
200 path$="file:///c:/other/basic/portal/"
210 i2%=0 : img$="error"
212 gt%=250
220 for i%=0 to i2%
225 gl img$+str$(i%),path$+"img/"+img$+str$(i%)+".png"
230 sg img$+str$(i%),img$+str$(i%)
235 sm img$+str$(i%),-gw(img$+str$(i%)),-gh(img$+str$(i%))
240 next i%
245 gt gt%
250 i2%=0 : img$="tile" : gt%=254
252 gt 220
254 i2%=0 : img$="chell" : gt%=258
256 gt 220
258 i2%=5 : img$="portal" : gt%=910
260 gt 220
300 sg "err","error0"
310 sm "err",w%/2-gw("error0")/2,h%/2-gh("error0")/2
320 repaint
330 sleep 7000 : end
900 rem ÇÀÃÐÓÇÊÀ ÊÀÐÒÛ
910 open #0,path$+"maps/"+"test0"+".lvl","input"
919 rem ÐÀÇÌÅÐ ÊÀÐÒÛ X Y
920 get #0,xmp%
930 get #0,ymp%
935 get #0,layers%
949 rem îáùåå êîëâî òàéëîâ, òàéëû îòîáðàæåíèéà, èõ êîîðäèíàòû, òàéëû ñòîëêíîâåíèéà, ñ÷åò÷èê, ðàçìåð òàéëà, êîîðäèíàòû ðàñïîëîæåíèÿ
950 xym%=xmp%*ymp%-1
960 dim map$(xym%+1)
961 dim tix%(xym%+1)
962 dim tiy%(xym%+1)
965 dim allmap$(xym%+1)
970 tiles$=""
971 im%=0
975 tsize%=26
980 obx%=0
981 oby%=0
990 for i%=0 to xym%
991 if obx%=xmp% th oby%=oby%+1 : obx%=0
993 tix%(i%)=obx%*tsize%
994 tiy%(i%)=oby%*tsize%
1000 get #0,byte%
1020 if byte% <> 00 and byte% <> 02 th map$(i%)="map"+str$(i%) : tiles$=tiles$+str$(i%)+"|" : im%=im%+1
1080 if byte% = 00 th sg map$(i%),"tile0" : sm map$(i%),tix%(i%),tiy%(i%)
1100 if byte% = 01 th sg map$(i%),"tile0" : sm map$(i%),tix%(i%),tiy%(i%)
1110 if byte% = 02 th sm "chell0",obx%,oby% : x=tix%(i%)+gw("chell0")/2 : y=tiy%(i%)
1190 obx%=obx%+1
1200 next i%
1201 close #0
1929 rem ÎÐÃÀÍÈÇÀÖÈÉÀ ÒÀÉËÎÂ ÄËß ÑÒÎËÊÍÎÂÅÍÈÉÀ
1930 dim tile%(im%+1)
1931 ct%=len(tiles$) : i%=0
1932 a%=1 : b%=0
1935 tcr$=mid$(tiles$,a%,1)
1936 if tcr$ <> chr$(124) th a%=a%+1 : b%=b%+1 : gt 1935
1940 tile%(i%)=val(mid$(tiles$,1,b%))
1942 tiles$=right$(tiles$,ct%-(b%+1))
1944 ct%=len(tiles$)
1946 if ct%<2 th gt 1960
1948 i%=i%+1 : gt 1935
1950 rem ãðàâèòàöèéà, óñêîðåíèå, èíåðöèéà, ñîïðîòèâëåíèå âåòðó
1960 grav%=1
1965 usk=0
1970 iner=0
1975 sopr=0
1977 gt 2700
1990 rem ÔÈÇÈÊÀ
2000 grav%=1
2010 for i%=0 to im%
2020 if sh(chell$,map$(tile%(i%))) th gt 3000
2030 next i%
2040 if grav%=0 th x=x+iner
2050 if grav%=1 th y=y+usk : x=x+iner : usk=usk+0.5 : iner=iner/1.05
2060 if usk>10 th usk=10
2080 if iner>10 th iner=10
2090 if iner<-10 th iner=-10
2200 ret
2290 rem ÄÂÈÆÅÍÈÅ ÊÀÌÅÐÛ
2300 for c%=0 to 3
2301 if x>w%/2+cx%(c%) th x=x-cc%(c%) : gt 2340
2305 if x<w%/2-cx%(c%) th x=x+cc%(c%) : gt 2355
2310 if y>h%/2+cy%(c%) th y=y-cc%(c%) : gt 2370
2315 if y<h%/2-cy%(c%) th y=y+cc%(c%) : gt 2385
2320 next c%
2330 ret
2340 for i%=0 to im%
2345 tix%(tile%(i%))=tix%(tile%(i%))-cc%(c%)
2350 next i%
2351 if b%>-1 th ptx%=ptx%-cc%(c%)
2352 if c2%=1 th ptx2%=ptx2%-cc%(c%)
2353 gt 2400
2355 for i%=0 to im%
2360 tix%(tile%(i%))=tix%(tile%(i%))+cc%(c%)
2365 next i%
2366 if b%>-1 th ptx%=ptx%+cc%(c%)
2367 if c2%=1 th ptx2%=ptx2%+cc%(c%)
2368 gt 2400
2370 for i%=0 to im%
2375 tiy%(tile%(i%))=tiy%(tile%(i%))-cc%(c%)
2380 next i%
2381 if b%>-1 th pty%=pty%-cc%(c%)
2382 if c2%=1 th pty2%=pty2%-cc%(c%)
2383 gt 2400
2385 for i%=0 to im%
2390 tiy%(tile%(i%))=tiy%(tile%(i%))+cc%(c%)
2395 next i%
2396 if b%>-1 th pty%=pty%+cc%(c%)
2397 if c2%=1 th pty2%=pty2%+cc%(c%)
2400 for i%=0 to im%
2415 sm map$(tile%(i%)),tix%(tile%(i%)),tiy%(tile%(i%))
2430 next i%
2432 if b%>-1 th sm "portal"+str$(vr1%),ptx%,pty%
2434 if c2%=1 th sm "portal"+str$(vr2%),ptx2%,pty2%
2444 ret
2690 rem êàäð ×åëë, ìàññèâû êàìåðû, íàæàòàÿ êëàâèøà, íîìåð öâåòà ïîðòàëà
2700 chell$="chell0"
2720 dim cx%(4) : dim cy%(4)
2721 dim cc%(4)
2722 for c%=0 to 3
2724 cx%(c%)=w%/((c%+1)*2)
2726 cy%(c%)=h%/((c%+1)*2)
2728 cc%(c%)=4-c%
2730 next c%
2750 a%=0 : b%=-1 : c2%=0
2800 gt 5000
2990 rem ïðîâåðêà íà ñòîëêíîâåíèå ñî âñåìè ñòîðîíàìè òàéëîâ
3000 grav%=0
3005 iner=iner/2
3010 for i2%=1 to tsize%
3020 prx%=i2% : pry%=i2%
3030 sm chell$,x,y-pry%
3040 if not sh(chell$,map$(tile%(i%))) th y=y-pry% : usk=0 : gt 2040
3050 sm chell$,x-prx%,y
3060 if not sh(chell$,map$(tile%(i%))) th x=x-prx% : iner=-iner/5 : gt 2040
3070 sm chell$,x+prx%,y
3080 if not sh(chell$,map$(tile%(i%))) th x=x+prx% : iner=-iner/5 : gt 2040
3090 sm chell$,x,y+pry%
3100 if not sh(chell$,map$(tile%(i%))) th y=y+pry% : usk=0 : gt 2040
3110 next i2%
3120 gt 2040
3290 rem ÏÎÐÒÀËÛ
3300 if a%<>0 th gt 3420
3320 for p%=49 to 57
3322 if ik(0)=p% th a%=p%-48 : gt 3345
3324 next p%
3333 ret
3340 rem ñêîðîñòü âûñòðåëà è íàïðàâëåíèå ïî sx|sy*10, êàäð ïîðòàëà, ìåòêà ê êîîðäèíàòàì
3345 apx%=0 : apy%=0
3350 if a%=1 th sx%=-1 : sy%=-1 : vr%=4 : gt 3400
3354 if a%=2 th sx%=0 : sy%=-1 : vr%=4 : gt 3400
3358 if a%=3 th sx%=1 : sy%=-1 : vr%=4 : gt 3400
3362 if a%=4 th sx%=-1 : sy%=0 : vr%=2 : gt 3400
3366 if a%=5 and sx%=0 and sy%=0 th a%=0 : ret
3370 if a%=6 th sx%=1 : sy%=0 : vr%=2 : gt 3400
3374 if a%=7 th sx%=-1 : sy%=1 : vr%=4 : gt 3400
3378 if a%=8 th sx%=0 : sy%=1 : vr%=4 : gt 3400
3382 if a%=9 th sx%=1 : sy%=1 : vr%=4
3400 b%=b%+1
3405 if b%=1 th c2%=1
3410 if b%=2 th b%=0
3415 px%=x : py%=y
3420 px%=px%+sx%*10
3421 py%=py%+sy%*10
3440 sm "portal"+str$(b%),px%+9,py%+5
3452 for pi%=0 to im%
3454 if sh ("portal"+str$(b%),map$(tile%(pi%))) th gt 3460
3456 next pi%
3458 ret
3459 rem ÂÛ×ÈÑËÅÍÈÅ ÊÎÎÐÄÈÍÀÒ
3460 if px%+9>tix%(tile%(pi%))+tsize%/2 and vr%=2 th apx%=tsize%
3462 if px%+9<tix%(tile%(pi%))+tsize%/2 and vr%=2 th apx%=-1
3464 if py%+5>tiy%(tile%(pi%))+tsize%/2 and vr%=4 th apy%=tsize%
3466 if py%+5<tiy%(tile%(pi%))+tsize%/2 and vr%=4 th apy%=-1
3490 rem ÓÑÒÀÍÎÂÊÀ ÏÎÐÒÀËÀ
3500 sm "portal"+str$(b%),-10,-10
3505 if vr%=2 th sm "portal"+str$(vr%+2+b%),-10,-10
3510 if vr%=4 th sm "portal"+str$(vr%-2+b%),-10,-10
3610 if b%=1 th gt 3650
3612 ptx%=tix%(tile%(pi%))+apx%
3613 pty%=tiy%(tile%(pi%))+apy%
3615 vr1%=vr%
3620 sm "portal"+str$(vr1%),ptx%,pty%
3640 gt 3690
3650 ptx2%=tix%(tile%(pi%))+apx%
3651 pty2%=tiy%(tile%(pi%))+apy%
3655 vr2%=vr%+1
3660 sm "portal"+str$(vr2%),ptx2%,pty2%
3690 a%=0
3700 ret
3790 rem ÐÀÁÎÒÀ ÏÎÐÒÀËÎÂ
3800 if c2%<>1 th ret
3810 for i%=2 to 5
3820 if sh(chell$,"portal"+str$(i%)) th gt 3850
3830 next i%
3840 ret
3850 ret
4000 ret
4900 rem ÎÑÍÎÂÍÎÉ ÈÃÐÎÂÎÉ ÖÈÊË
5000 if ik(0)=-1 th usk=usk-1
5020 if ik(0)=-3 th iner=iner-0.8
5040 if ik(0)=-4 th iner=iner+0.8
5060 if ik(0)=-2 th end
5100 sm chell$,x,y
5500 gs 2000
5510 gs 2300
5520 gs 3300
5530 gs 3800
5540 repaint
5550 sleep 20
5555 gt 5000