Qbasicnews.com
October 23, 2018, 12:02:39 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: [1] 2
  Print  
Author Topic: raycaster in 6 lines  (Read 41914 times)
ravenxau
New Member

Posts: 9


« on: March 31, 2004, 07:57:12 AM »

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 Smiley


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
Logged
na_th_an
*/-\*
*****
Posts: 8244



WWW
« Reply #1 on: March 31, 2004, 09:23:44 AM »

Really cool, and impressive.

But not 6 lines: you cheated using ":" Tongue. Anyways, impressive Smiley
Logged

SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
relsoft
*/-\*
*****
Posts: 3927



WWW
« Reply #2 on: April 01, 2004, 07:56:48 AM »

Hah! With colon joined lines, I could make a raycaster in 1 line!!! LOL

Nice job though. :*)
Logged

y smiley is 24 bit.


Genso's Junkyard:
http://rel.betterwebber.com/
ravenxau
New Member

Posts: 9


« Reply #3 on: May 05, 2004, 03:20:37 AM »

it is 6 lines of code. i forgot to specify it is 6 lines of GW-BASIC compatible code. sorry for the misdirection. Smiley
Logged
relsoft
*/-\*
*****
Posts: 3927



WWW
« Reply #4 on: May 05, 2004, 08:39:24 AM »

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. ;*)
Logged

y smiley is 24 bit.


Genso's Junkyard:
http://rel.betterwebber.com/
Zack
*/-\*
*****
Posts: 3974



WWW
« Reply #5 on: May 05, 2004, 10:38:08 AM »

Waitasec...Relsoft, YOU'RE Jelly?
Logged

f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
wildcard
*.*
Administrator
__/--\__
*****
Posts: 2369



« Reply #6 on: May 05, 2004, 03:51:11 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
Logged
relsoft
*/-\*
*****
Posts: 3927



WWW
« Reply #7 on: May 07, 2004, 08:17:34 AM »

Quote from: "Zack"
Waitasec...Relsoft, YOU'RE Jelly?


 :oops:  :oops:
Logged

y smiley is 24 bit.


Genso's Junkyard:
http://rel.betterwebber.com/
oracle
*/-\*
*****
Posts: 3652



WWW
« Reply #8 on: May 07, 2004, 08:54:57 PM »

Eh?Huh

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? Wink
Logged

relsoft
*/-\*
*****
Posts: 3927



WWW
« Reply #9 on: May 08, 2004, 03:34:39 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. :*)
Logged

y smiley is 24 bit.


Genso's Junkyard:
http://rel.betterwebber.com/
oracle
*/-\*
*****
Posts: 3652



WWW
« Reply #10 on: May 09, 2004, 06:41:32 PM »

Hahaha, the wierd ways nicks come about, eh?
Logged

relsoft
*/-\*
*****
Posts: 3927



WWW
« Reply #11 on: May 12, 2004, 08:15:07 AM »

Yeah, I wouldn't have used "Zebra" or "Xylophone" though. :*)
Logged

y smiley is 24 bit.


Genso's Junkyard:
http://rel.betterwebber.com/
Radical Raccoon
I hold this place together
*****
Posts: 914



WWW
« Reply #12 on: May 29, 2004, 06:52:00 AM »

Hey! Jelly is like, plasma! So you are Plasma too? Wink
Logged

Plasma
Na_th_an
*****
Posts: 1770


WWW
« Reply #13 on: May 29, 2004, 02:46:44 PM »

pfffffft Tongue
Logged
Dr_Davenstein
Na_th_an
*****
Posts: 2052


« Reply #14 on: May 29, 2004, 03:04:42 PM »

Well, that would realy suck. He would be the only smart  person in here... might as well call it  relsoftnews.com. :lol:
Logged
Pages: [1] 2
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!