Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
raycaster in 6 lines
#21
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
url]http://fbide.sourceforge.net/[/url]
Reply
#22
Sorry for reviving this topic, but I really have to say something Tongue

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

Quote:Yeah, I wouldn't have used "Zebra" or "Xylophone" though. :*)
Jelly is cool Wink 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... Wink

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

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

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

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 Wink
Reply
#23
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.

;*)
y smiley is 24 bit.
[Image: anya2.jpg]

Genso's Junkyard:
http://rel.betterwebber.com/
Reply
#24
Rel, stop comparing Phillipines to US. The cost of living is proportional to their salaries Wink. 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 Wink.
Reply
#25
Quote:Because he is everyone here? Or is it just because because we aren't smart? Wink
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. Big Grin
I'd knock on wood, but my desk is particle board.
Reply
#26
:lol: Hear hear...
Reply
#27
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 Smile  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
Reply
#28
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........
Reply
#29
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. Big Grin

- Dav
Reply
#30
Yes sir. Studying stuff like this is what made me who I am today... As far as programming goes. Smile
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)