'This is the Erland Rovik's porting to RapidQ of the Peter Cooper's QB Raytracer. 'I simply put it to work. Finally it behaves more or less as Peter's original 'It's the simplest one in the ABC packets, so donīt expect textures and things 'It uses DirectX so it will not work in Linux 'The keys are Z for left, X for right and space to go forward 'You will have a black window until you press the first key. 'Enjoy! 'Antoni Gual agual@eic.ictnet.es declare sub raytrace declare sub key(key as byte) declare sub paint declare sub size DIM st%(0 TO 360) as integer DIM ct%(0 TO 360) as integer DIM a$(1 TO 10) as string dim QBclrs(0 to 15) as long dim sa% as integer,tmp1% as integer,px% as integer,py% as integer,t% as integer dim xb as integer,yb as integer,bx as integer,by as integer,l% as integer,k% as integer dim x% as integer,dd% as integer QBclrs(0) =0 QBclrs(1) =&H800000 QBclrs(2) =&H008000 QBclrs(3) =&H808000 qbclrs(4) =&h000080 qbclrs(5) =&H800080 qbclrs(6) =&h808000 qbclrs(7) =&h808080 'don't use this one qbclrs(8) =&h404040 'don't use this one qbclrs(9) =&hff0000 qbclrs(10)=&H00FF00 qbclrs(11)=&H00FFFF qbclrs(12)=&HFF0000 qbclrs(13)=&Hff00FF qbclrs(14)=&HffFF00 qbclrs(15)=&HffFFff 'maze defs a$(1) = "1919191919" a$(2) = "9000000001" a$(3) = "1000000409" a$(4) = "9010005001" a$(5) = "1020040009" a$(6) = "9030000001" a$(7) = "1000078009" a$(8) = "9050087001" a$(9) = "1060000009" a$(10)= "9191919191" 'TRIGONOMETRIC TABLES FOR tmp1% = 0 TO 360 st%(tmp1%) = (SIN(tmp1% * .0174)) * 100 NEXT tmp1% FOR tmp1% = 0 TO 360 ct%(tmp1%) = (COS(tmp1% * .0174)) * 100 NEXT tmp1% px% = 15: py% = 15: sa% = 0 create tim as qtimer 'this paints the first frame, before user hits any key interval=1000 ontimer=raytrace end create Create form as qform clientheight=200 clientwidth=300 center create can as qdxscreen width=form.clientwidth height=form.clientheight end create onkeypress=key end create sub key(key as byte) select case chr$(key) case "x":sa% = sa% + 3 case "z":sa% = (sa% + 357) MOD 360 case " " px% = px% + (st%(t% MOD 360) / 50) py% = py% + (ct%(t% MOD 360) / 50) case else exit sub end select raytrace end sub sub raytrace can.fill(qbclrs(15)) FOR t% = sa% TO sa% + 59 STEP 1 xb!=st%(t% MOD 360) / 100 'get inc yb!=ct%(t% MOD 360) / 100 'get inc bx!=px% 'decimal copy by!=py% 'decimal copy l%=0 'reset length DO bx!=bx!+xb! by!=by!+yb! l%=l%+1 k%=asc(MID$(a$(by!\10),bx!\10,1))-48 LOOP UNTIL k% x%=(t%-sa%)*5 dd%=(1000/l%) can.fillrect x%,100-dd%,x%+5,100+dd%,qbclrs(k%) can.LINE x%,100-dd%,x%+5,100-dd%,0 can.LINE x%,100+dd%,x%+5,100+dd%,0 NEXT t% can.flip end sub tim.enabled=1 form.showmodal