'=========================================================================== ' Subject: RAY CASTER 3D ENGINE Date: 08-09-96 (10:31) ' Author: Peter Cooper Code: QB, QBasic, PDS ' Origin: peco@trenham.demon.co.uk Packet: GRAPHICS.ABC '=========================================================================== ' ========================================================================== ' RAY CASTER 3D sorta ENGINE thingymajig ' ========================================================================== ' Wrote this about a month ago, it's a sort of wolfenstien\doom lookalike ' but all in native QBasic source! Uses an interesting ray tracing technique ' could be optimized x1000 Infact, it's being converted to ASM and stuff ' like textures will be added and maybe a bit of shading ' ' Anyway, this code is _public domain_, change it, modify it, whatever, it ' only took about 40 mins in total, So whatever.. you have fun with it ' ' Cheers, {:o) Peter Cooper DECLARE SUB screensetup () DECLARE SUB makeworld () DECLARE SUB maketables () DIM SHARED st%(0 TO 360) DIM SHARED ct%(0 TO 360) DIM SHARED a$(1 TO 10) px% = 15: py% = 15: sa% = 0 PRINT "please wait.."; makeworld maketables screensetup lp1: 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$(CINT(by / 10)), CINT(bx / 10), 1)) - 48 LOOP UNTIL k% <> 0 'PRINT l% this would print the distance to wall from player x% = (t% - sa%) * 5 dd% = (1000 / l%) LINE (x%, 1)-(x% + 5, 99 - dd%), 15, BF LINE (x%, 101 + dd%)-(x% + 5, 200), 2, BF LINE (x%, 100 - dd%)-(x% + 5, 100 + dd%), k%, BF LINE (x%, 100 - dd%)-(x% + 5, 100 - dd%), 0 LINE (x%, 100 + dd%)-(x% + 5, 100 + dd%), 0 NEXT t% PCOPY 0, 1 in$ = INPUT$(1) IF in$ = "x" THEN sa% = sa% + 3 IF in$ = "z" THEN sa% = (sa% + 357) MOD 360 IF in$ = CHR$(27) THEN SCREEN 0: WIDTH 80, 25: SYSTEM IF in$ = " " THEN px% = px% + (st%(t% MOD 360) / 50) py% = py% + (ct%(t% MOD 360) / 50) END IF GOTO lp1: SUB maketables ' Peters boring _yawn_ table creation FOR tmp1% = 0 TO 360 st%(tmp1%) = SIN(tmp1% * .0174) * 100 IF tmp1% MOD 100 = 0 THEN PRINT ; "."; NEXT tmp1% FOR tmp1% = 0 TO 360 ct%(tmp1%) = COS(tmp1% * .0174) * 100 IF tmp1% MOD 100 = 0 THEN PRINT ; "."; NEXT tmp1% END SUB SUB makeworld ' Peter Coopers demonstration level. Change it if you wish! Each number 'is ' a color number 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" END SUB SUB screensetup SCREEN 8, , 0, 1 CLS WINDOW SCREEN (1, 1)-(320, 200) END SUB