• 0 Vote(s) - 0 Average
• 1
• 2
• 3
• 4
• 5
 raycaster in 6 lines ravenxau Junior Member  Posts: 9 Threads: 3 Joined: Jun 2003 03-31-2004, 03:57 PM here is a raycaster i knocked up in 6-lines. anybody else want to share their take on the subject? (btw - this code is gwbasic compatible too!) Matt Code:```1 DIM L(7, 7): FOR Y = 0 TO 7: FOR X = 0 TO 7: READ L(X, Y): NEXT X: NEXT Y: X = 24: Y = 24: F = 45: SCREEN 1 2 FOR S = -160 TO 149 STEP 10: R = F + (S * .1875): R = R + 360 * ((R > 360) - (R < 0)): XI = COS(R / 57): YI = SIN(R / 57): X1 = X: Y1 = Y 3 X1 = X1 + XI: Y1 = Y1 + YI: IF L(X1 / 16, Y1 / 16) = 0 THEN GOTO 3 4 D = ABS((X - X1) / COS(R / 57)): H = (1816 / D): LINE (S + 160, 100 - H)-(S + 169, 100 + H), 1, BF: LINE (S + 160, 0)-(S + 169, 99 - H), 0, BF: LINE (S + 160, 101 + H)-(S + 169, 320), 0, BF 5 NEXT S: A\$ = INKEY\$: F = F + 5 * (A\$ = ",") - 5 * (A\$ = "."): F = F - 355 * (F = -5) + 360 * (F = 365): IF A\$ = " " AND (L((X + COS(F / 57)) / 16, (Y + SIN(F / 57)) / 16) = 0) THEN X = X + COS(F / 57): Y = Y + SIN(F / 57) 6 GOTO 2: DATA 1,1,1,1,1,1,1,1,1,0,0,1,0,0,0,1,1,1,0,1,0,1,0,1,1,0,0,0,0,1,0,1,1,0,1,1,0,1,0,1,1,0,1,1,0,1,1,1,1,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1``` na_th_an Posting Freak     Posts: 6,419 Threads: 74 Joined: Mar 2002 03-31-2004, 05:23 PM Really cool, and impressive. But not 6 lines: you cheated using ":" . Anyways, impressive SCUMM (the band) on Myspace! ComputerEmuzone Games Studio underBASIC, homegrown musicians [img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i relsoft Posting Freak     Posts: 3,288 Threads: 167 Joined: Nov 2001 04-01-2004, 03:56 PM Hah! With colon joined lines, I could make a raycaster in 1 line!!! LOL Nice job though. :*) y smiley is 24 bit. Genso's Junkyard: http://rel.betterwebber.com/ ravenxau Junior Member  Posts: 9 Threads: 3 Joined: Jun 2003 05-05-2004, 11:20 AM it is 6 lines of code. i forgot to specify it is 6 lines of GW-BASIC compatible code. sorry for the misdirection.  relsoft Posting Freak     Posts: 3,288 Threads: 167 Joined: Nov 2001 05-05-2004, 04:39 PM Actually I was with the assumption that each line should not have colons for joining. Like this: Code:```'Felix the Helix 'By Jelly 1 IF I% = 0 THEN SCREEN 7, , 0, 1 ELSE PCOPY 0, 1 2 A! = (A! + .03) * -(A! < 6.283186) 3 FOR I% = 0 TO 200 4 x! = ((50 * COS(4 * 3.141593 / 200 * I%)) * (COS(A!) * COS(A!)) + (50 * SIN(8 * 3.141593 / 200 * I%)) * (SIN(A!) * SIN(A!) * COS(A!) - COS(A!) * SIN(A!)) + (I% - (200 / 2)) * (COS(A!) * SIN(A!) * COS(A!) + SIN(A!) * SIN(A!))) 5 y! = ((50 * COS(8 * 3.141593 / 200 * I%)) * (COS(A!) * SIN(A!)) + (50 * SIN(8 * 3.141593 / 200 * I%)) * (COS(A!) * COS(A!) + SIN(A!) * SIN(A!) * SIN(A!)) + (I% - (200 / 2)) * (-SIN(A!) * COS(A!) + COS(A!) * SIN(A!) * SIN(A!))) 6 z! = ((50 * COS(8 * 3.141593 / 200 * I%)) * (-SIN(A!)) + (50 * SIN(8 * 3.141593 / 200 * I%)) * (SIN(A!) * COS(A!)) + (I% - (200 / 2)) * COS(A!) * COS(A!)) 7 IF I% > 1 THEN CIRCLE ((160 + (256 * x! \ (256 - z!))), (100 - (256 * y! \ (256 - z!)))), 512 \ (256 - z!), (A! * 57.29577 + I%) AND 15 ELSE LINE (0, 0)-(319, 199), 0, BF 8 NEXT I% 9 IF INKEY\$ = "" THEN 1``` Code:```'Translucency is me! Redux... 'by Jelly 1 IF i& = 0 THEN SCREEN 13 ELSE IF i& <= 256 THEN PALETTE i& - 1, 65536 * INT(32 - 31 * SIN(i& * 3.14151693# / 128)) + 256 * INT(32 - 31 * SIN(i& * 3.14151693# / 64)) + INT(32 - 31 * SIN(i& * 3.14151693# / 32)) ELSE z% = 64 * (((i& AND 1) = 1) OR 1) 2 IF xa% = 0 THEN DIM Lsin%(1024) ELSE i& = (i& + 1) AND &H7FFFFFFF 3 FOR ya% = 0 TO 127 4 IF i& < 385 THEN Lsin%(i&) = SIN((i&) / 25) * 64 ELSE xsin% = SIN((ya% + i&) / 20) * 32 5 FOR xa% = 0 TO 254 6 z% = -z% 7 IF i& > 384 THEN PSET (32 + xa%, 36 + ya%), (xa% + xsin%) + Lsin%(ya% + 64 + z%) + Lsin%(xa% + ya%) 8 NEXT xa%, ya% 9 IF INKEY\$ = "" THEN 1``` Code:```'Lovelier, Wobblier and Bigger!!!! 'by Jelly 1 IF i& = 0 THEN SCREEN 13 ELSE IF i& <= 256 THEN PALETTE i& - 1, 65536 * INT(32 - 31 * SIN(i& * 3.14151693# / 128)) + 256 * INT(32 - 31 * SIN(i& * 3.14151693# / 64)) + INT(32 - 31 * SIN(i& * 3.14151693# / 32)) 2 IF xa% = 0 THEN DIM Lsin%(256, 3) ELSE i& = (i& + 1) AND &H7FFFFFFF 3 FOR ya% = 0 TO 127 4 IF i& < 257 THEN Lsin%(i&, 0) = SIN((i&) / 30) * 60 ELSE xsin% = SIN((ya% + i&) / 20) * 50 5 FOR xa% = 0 TO 255 6 PSET (32 + xa%, 36 + ya%), (xa% + xsin%) XOR (ya% + (Lsin%((xa%), 0))) 7 NEXT xa%, ya% 8 IF INKEY\$ = "" THEN 1``` Note that I had to strain my brain just to get it to work fast enough and there is no colon joined line. ;*) y smiley is 24 bit. Genso's Junkyard: http://rel.betterwebber.com/ Zack Posting Freak     Posts: 3,616 Threads: 287 Joined: Jan 2003 05-05-2004, 06:38 PM Waitasec...Relsoft, YOU'RE Jelly? f only life let you press CTRL-Z. -------------------------------------- Freebasic is like QB, except it doesn't suck. wildcard Administrator       Posts: 1,138 Threads: 211 Joined: Feb 2020 05-05-2004, 11:51 PM Great work. Using the colon has it limitis, e.g. you can't do that much in terms of if statements/etc. Remeber pasco's climber that was using colons relsoft Posting Freak     Posts: 3,288 Threads: 167 Joined: Nov 2001 05-07-2004, 04:17 PM Quote:Waitasec...Relsoft, YOU'RE Jelly? :oops: :oops: y smiley is 24 bit. Genso's Junkyard: http://rel.betterwebber.com/ oracle Posting Freak     Posts: 3,343 Threads: 83 Joined: Mar 2003 05-08-2004, 04:54 AM Eh???? I suspected you two were "related" after the 9-line compo at QBNZ, but you're actually the same person?? What, did you forget your password or something? size=9]Oracle QBNZ | GeSHi - Generic Syntax Highlighter for PHP | PHPClasses[/size] relsoft Posting Freak     Posts: 3,288 Threads: 167 Joined: Nov 2001 05-08-2004, 11:34 AM LOL. Nahh. I was making my first entry, the "circle interference" while teaching my daughter how to read the ABC's. And my daughter kept on going back to "J" 'cause she likes the picture. Guess what? The pic on the letter J is Jelly. :*) So I guess it stuck. :*) y smiley is 24 bit. Genso's Junkyard: http://rel.betterwebber.com/ « Next Oldest | Next Newest »

Forum Jump:

Users browsing this thread: 1 Guest(s) 