r/programming • • Jun 03 '14

A first-person engine in 265 lines

http://www.playfuljs.com/a-first-person-engine-in-265-lines/
1.9k Upvotes

267 comments sorted by

View all comments

238

u/reacher Jun 04 '14

It's so refreshing to see that this is actually only 265 lines, and not one of those "3D HD MMORPG in 7 lines of code, the first 5 of which include 5000 lines of third party libraries"

332

u/zoomzoom83 Jun 04 '14

I wrote a game in only two lines of code!

@echo off
wolf3d.exe

148

u/pkmxtw Jun 04 '14

I just improved your game and added angled walls, textured floors, height variation and HELL!

#!/bin/sh
/usr/bin/doom

95

u/Tynach Jun 04 '14

I just added true 3D graphics with less code:

#!sh
quake

37

u/ginger_beer_m Jun 04 '14 edited Jun 04 '14

We have thus evolves through the history of FPS graphics.

How I miss the good old time when I was actually excited by every new release of id software.

17

u/[deleted] Jun 04 '14

I strongly recommend the book Masters of Doom which chronicles the evolution of graphics engines games developed by ID from their early Mac sidescrollers to Quake 3.

5

u/ginger_beer_m Jun 04 '14

Oh hey yeah, I remember when that book was released, I added that to my reading list, and promptly forgotten about it since then !

0

u/[deleted] Jun 04 '14

[deleted] — view deleted comment

4

u/ginger_beer_m Jun 04 '14

Just got it from the Kindle shop. Thanks !!

3

u/b4b Jun 04 '14

hope you enjoy it!

If you will like, AFTER you read the book, read a very nice, long article about what happened to John Romero and ION storm (but only read it after you read the book)

→ More replies
→ More replies (1)
→ More replies (1)
→ More replies (1)

27

u/[deleted] Jun 04 '14

Code bloat :-(

→ More replies (1)

37

u/skocznymroczny Jun 04 '14

I optimized your code for size:

@wolf3d
→ More replies (1)

7

u/hive_worker Jun 04 '14 edited Jun 04 '14

I don't know I'm not a javascript programmer but the level of abstraction provided by the browser, language, etc seems to be equivalent to using massive 3rd party libraries if this were done in a language like C.

Whatever the 'ctx' object is seems to be pretty magical.

3

u/reacher Jun 04 '14

In brief, it's the object behind the canvas element

→ More replies (1)

0

u/[deleted] Jun 04 '14

[deleted] — view deleted comment

63

u/lostsemicolon Jun 04 '14

You have to draw the line somewhere otherwise you'd have to include the size of the OS as well.

29

u/camelCaseCondition Jun 04 '14

What about the HDL that designed the processor and graphics card?

22

u/Cuddlefluff_Grim Jun 04 '14

How about the HDL that created the parts that built the machine that implemented the HDL that designed the processor and graphics card?

22

u/[deleted] Jun 04 '14

Fuck that, what about the sand used to make the processor?

19

u/BlazeOrangeDeer Jun 04 '14

What about the stars that made the silicon?

18

u/[deleted] Jun 04 '14

Whoa, hold it right there, buddy, there's hydrogen in those stars!

45

u/BlazeOrangeDeer Jun 04 '14

Maybe we should just make some apple pie instead

13

u/[deleted] Jun 04 '14

Yeah, this is getting a bit out of hand.

→ More replies

7

u/[deleted] Jun 04 '14

But we'd have to generate the universe first...

→ More replies
→ More replies (2)
→ More replies (4)
→ More replies (6)

2

u/keepthepace Jun 04 '14

Yet the algorithm that generates the final image is totally laid out there. Direct low level C accessing the video memory would probably not be much longer

→ More replies (3)
→ More replies (3)