# Qbasicnews.com

Full Version: raycaster in 6 lines
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
Really cool, never done anything of that kind though :oops: So just for better understandability(for myself) I rewrote it to n+1 lines, but gives a better overview.

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 13 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, 99 - H)-(s + 169, 99 - H), 4 'this line is also my creation       LINE (s + 160, 101 + H)-(s + 169, 320), 0, BF       LINE (s + 160, 101 + H)-(s + 169, 101 + H), 2 'and added this line 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)    ELSEIF a\$ = CHR\$(27) THEN END    END IF 6  GOTO 2 DATA 1, 1, 1, 1, 1, 1, 1 ,1 DATA 1, 0, 0, 1, 0, 0, 0, 1 DATA 1, 1, 0, 1, 0, 1, 0, 1 DATA 1, 0, 0, 0, 0, 1, 0, 1 DATA 0, 1, 1, 1, 0, 1, 0, 1 DATA 1, 0, 1, 1, 0, 1, 1, 1 DATA 1, 0, 0, 0, 0, 0, 0, 1 DATA 1, 1, 1, 1, 1, 1, 1, 1```
Sorry for reviving this topic, but I really have to say something

Quote:Waitasec...Relsoft, YOU'RE Jelly?
HA! I already suspected that! That's why you won 1st prize on the 9-line gfx demo contest, and I got 2nd prize! (Btw, I also had a translucent plasma entry )

Quote:Yeah, I wouldn't have used "Zebra" or "Xylophone" though. :*)
Jelly is cool lol

Quote:Hey! Jelly is like, plasma! So you are Plasma too?
Yeah right... then everyone is everyone. So I'm oracle because Neo has something to do with The Oracle in the Matrix...

Quote:Well, that would realy suck. He would be the only smart person in here... might as well call it relsoftnews.com.
Because he is everyone here? Or is it just because because we aren't smart?

Quote:Well, they both are ASM geniuses, and how come we have never seen them in the same room together?
Hmn, good question . #1: Plasma is always busy. #2: Relsoft probably can't go to America for no reason

Quote:Hell on Earth
Since when are the Phillipines hell on earth? And since when is the USA the country with the coolest salaries?

Quote:raycast\$ = 'machine code for raycaster
CALL Absolute(raycast,...)
You are allowed to do this, unless you have to make it in QB. That code technically isn't QB
Neo: The place itself is pretty good. But bad governance is ruining everything. Err... A guy who operates a xerox copy machine in the sates for 6 hours makes a lot more than a surgeon here. :*)

Sigh, this "relsoft is smart thingy" is so lame. Heh, I could never make a half decent gui even if I try to.

;*)
Rel, stop comparing Phillipines to US. The cost of living is proportional to their salaries . The government eats away ~40-50% of their salaries but they get facilities in return. But that really leaves you only half of you're salary to spend =P. Also, converting USD to Pesos(did u know the acronym for pesos is PHP =P?) isnt very wise either. The conversion rate is very high .
Quote:Because he is everyone here? Or is it just because because we aren't smart?
Nah, everyone (with a few exceptions) here is smart in their own little ways. You gotta be a cut above the rest of humanity to be able to withstand the suffrage and outright masochistic lifestyle of a computer programmer.
:lol: Hear hear...
Hi. Sorry to revive this years-dead thread, but I thought it was a fun challenge to make the shortest 1-line RC!Â  You can make it into 1 line in QB with a bit of editing.Â  All fixed up, note the changes Â  Press , . to turn, space forward, esc.

Code:
```FOR X = 0 TO 63: L(X AND 7, X\8)=VAL(MID\$("1111111110010001100409011000010120110701101101011000000112345671",X+1,1)): NEXT: X = 1.5:Y = X: F = ATN(1): u = F / 9: SCREEN 7: DO: FOR S = -160 TO 159: t = ATN(S / 304): R = F + t: I = COS(R) / 80:J = SIN(R) / 80: o = X: p = Y: n = 0: DO: o = o + I: p = p + J: n = n + 1: c = L(o, p): LOOP UNTIL c: H = 9000 / n / COS(t): v = S + 160: LINE (v, 0)-(v, 99 - H), 0: LINE -(v, 99 + H), c: LINE -(v, 319), 8: NEXT: a = INP(96): I = COS(F) / 9: JÂ  = SIN(F) / 9: m = a = 57 AND L(X + I, Y + J) = 0: X = X - I * m: Y = Y - J * m: F = F + u * ((a = 51) - (a = 52)): LOOP UNTIL a = 1```
Thought I'd bump this thread, as I did start it 12 years ago....I have just started programming in qbasic again...using version 1.1 under dosbox....will be interesting to revisit some of my old stuff and see if it goes anywhere new........
Hi ravenau.Â  I keep coming back to QB programming too.Â  Have you tried QB64?Â  These raycaster codes will run in that too, compile to EXE and doesn't need DosBox.Â

Anyway, glad to see you (and anyone!) around here.

- Dav
Yes sir. Studying stuff like this is what made me who I am today... As far as programming goes.
Pages: 1 2 3