
A first-person engine in 265 lines (2014) - WoodenChair
http://www.playfuljs.com/a-first-person-engine-in-265-lines/
======
userbinator
I believe this is the smallest application of the concept I've seen, using
only 128 _bytes_ of binary:
[https://news.ycombinator.com/item?id=16538367](https://news.ycombinator.com/item?id=16538367)

 _For example, raycasts run in constant time, so you can load up a massive
world and it will just work, without optimization, as quickly as a tiny
world._

If someone has some more time to try this out, the layer images of the 6502
processor here might make a good world to play around in:
[http://www.visual6502.org/images/6502/layers_index.html](http://www.visual6502.org/images/6502/layers_index.html)
(that site appears down/intermittent currently, but archive.org has copies.)

~~~
mrspeaker
That article is great - though (after looking at the shadertoy version
[https://www.shadertoy.com/view/MdXXz2](https://www.shadertoy.com/view/MdXXz2))
I didn't know that WebGL didn't have an XOR operation. Is that true? Does
anyone know more about that?

------
taneq
Aah, this brings back memories of people writing raycasting engines in QBasic.
That language was really not suited to this kind of thing, but people made it
work! :D

~~~
mysterydip
I loved how much people made QBasic do that it wasn't suited for, part of what
made the scene great :)

------
cannedslime
Drunk vision/walking:

    
    
      var i = 0, s;
      setInterval(function(){
        i+=0.02;
        s = Math.sin(i)
        camera.focalLength = 0.8 + s * 0.2;
        player.rotate(s * 0.02 - 0.01);
      }, 16);

------
keypusher
Previously:
[https://news.ycombinator.com/item?id=7842037](https://news.ycombinator.com/item?id=7842037)

------
CryoLogic
Does this actually count as 3D?

I thought 2.5D was the term used for 2D assets used in a way to appear 3D.

Pardon my lack of familiarity with game engines if I miss-understood this.

~~~
chungy
2.5D is more of a retronym after the age of "full" 3D engines came to be.
Before then, we'd call anything 3D that looked 3D, and the lines do certainly
get blurred.

Wolfenstein 3D for example is practically a 2D game, you could redisplay it as
a top-down shooter reminiscent of early 1980s games (much like the early
Wolfenstein games, actually), and not lose anything. There is no Z axis in
consideration for any game logic.

Doom, on the other hand, actually does have a Z axis, determining which floors
can and cannot be reached, how they are displayed, whether projectiles hit
enemies or not, and so forth. The (original) engine and map format don't allow
any rooms-over-rooms though, so it is still considered 2.5D -- somewhere in
between a 2D game and Quake.

~~~
blihp
I remember many of the isometric drawn/pre-rendered games with a fixed PoV
(i.e. Zaxxon etc) being described as 2.5D back in the day. We knew they
weren't exactly 3D but then again, they weren't your typical 2D
platformer/side-scroller either. Battlezone was considered a 3D game back in
its day so the rendering technology wasn't really the dividing line. It was
more a question of if the game environment being navigated was 3D and if it
had a reasonably realistic spatial representation on the screen.

~~~
Andrex
To make things more confusing, 2.5D these days is also often used to describe
(actually) 3D-rendered sidescrollers, like the New Super Mario Bros. games.

~~~
Wowfunhappy
Indeed.

The term 2.5D has been obscured to the point that it no longer carries any
useful meaning. We should all stop using it.

New Super Mario Bros is a 2D platformer with 3D graphics.

------
billpg
If only it could have been reduced by just nine lines.

------
krige
Also compare this:
[https://lodev.org/cgtutor/raycasting.html](https://lodev.org/cgtutor/raycasting.html)

It's a bit old but also explains a lot of the underlying logic. And it's not
written in javascript so it may be more readable to some.

------
praptak
I'm not convinced the complexity is really independent from the size of the
map. With large emptyish maps the rays can travel a long distance before they
hit something. And tracking the ray is linear wrt its length.

~~~
joshvm
Complexity is proportional to the size of the view distance (linearly? Or
square if you do a field of view). The map size doesn't matter, assuming array
lookup is instant.

------
atum47
I love this article since the first day I lay my eyes on it. The first time
around I wasn't so much of good programmer to try and implement it myself, I
now feel more confident, as soon as I get some time I'll get to it. I made a
3D version of a similar "game" some time ago using three.js, but it's not the
same. I love those old graphics.

------
hrydgard
Pedantic correction: Daggerfall didn't use a raycaster, it was a full polygon
engine (although with sprite characters).

Its predecessor Arena did appear to use one though.

~~~
sclangdon
Duke Nukem 3D didn't use raycasting, either [0].

0 -
[http://fabiensanglard.net/duke3d/build_engine_internals.php](http://fabiensanglard.net/duke3d/build_engine_internals.php)

------
lbj
Fantastic explanations & kudos for boiling this down to the bare essentials!

------
bl4ckneon
Should there be a 2014 tag?

Pretty cool article though!

~~~
dang
Added. Thanks!

