top | item 37358063

Build Your Own Flight Sim in C++ (1996)

272 points| stefankuehnel | 2 years ago |archive.org | reply

59 comments

order
[+] DanHulton|2 years ago|reply
Oh, this book!

I remember playing Wolfenstein and Ken's Labyrinth, and Doom, and wondering just how the heck it all was done. Then I came across a copy of this book in a "computer store" I was working at who couldn't (or wouldn't) pay wages. He told me I could have any book in the store for my work that day, and I grabbed this one on impulse.

I remember missing my stop on the bus ride home, because even though it was about flight sims, the algorithms and methods inside were about 3D programming - the very thing I'd been wondering about!

I never built a flight sim, but I _did_ build a rudimentary 3d game with the knowledge I gleaned from this book. There wasn't any collision on the walls, and the sprite-base object pickups with get corrupted randomly after a while, and I never really got the hang of doing matrix multiplications instead of geometric transforms, but this book cemented my love of programming at a point where I may not have really pursued it much more without an in-depth project to spur me on!

[+] whartung|2 years ago|reply
This was me only 15 years earlier. My math teacher had a TRS-80 and an early flight sim. For terrain it had a grid, an airport, and a simple, flat, mountain range. It was loaded from cassette.

He didn’t know the math. In fact when he was teaching us matrices in Algebra II, he really couldn’t answer how matrices were used in the “real world”.

But somehow I managed to track down a couple year old Byte magazine that had an article on 3D graphics, and it was all about matrices and points to do rotations and what not.

With that, I got a cube to rotate on a PET 2001. In all it’s 40x24 glory. Well, there were 8 dots. If you squinted in low light, it would look like a cube.

Later, in college I got access to a textronix storage tube microcomputer. It was standalone in contrast to their terminals. That was able to render a cube quite well. And the car I painstakingly created on graph paper and keyed into DATA statements using the machines built in BASIC.

By then, early Foley-Van Dam was the coveted graphics book to get.

[+] gvd|2 years ago|reply
It's the kind of stuff that got me into programming. I never worked in this space but it was a huge inspiration. I used to buy cdroms that were dumps of certain website like drdobbs and alike
[+] bovermyer|2 years ago|reply
Wait, why would you do matrix multiplications instead of geometric transforms?

I got a C in "Survey of Physics" in college, and struggled _hard_ with any math that was meant to model physical phenomena. I aced calculus and anything abstract. I dunno what that says about me.

[+] Buttons840|2 years ago|reply
Anyone interested in this might also be interested in this online course I'm taking: https://pikuma.com/courses/learn-3d-computer-graphics-progra...

The instructor teaches this material at a university in London and it's obvious to me that he has a lot of experience teaching it. The course has been perfectly paced so far and exactly what it claims to be. After I finish his graphics course I will be taking another course or two from him.

He teaches how to program graphics from scratch using C. The only dependency is SDL2. The first steps of the course are to setup a SDL2 abstraction that allows you to set the color of individual pixels, and then the rest of the course builds on that abstraction. That's what the course teaches, given you can set the color of a pixel, can you then draw the rest of the 3D textured owl? I've been doing the course in Rust, using Rust's SDL2 bindings and nothing else.

I've been enjoying the course and felt it was an honest transaction and a good course, so I wanted to share. I haven't seen much talk about these courses elsewhere.

[+] atan2|2 years ago|reply
I agree. Great content.
[+] ilimilku|2 years ago|reply
I remember having this book. I was probably 14 or 15 years old, and I was just getting into aviation after being given my first flying lesson. I had a copy of MS Flight Simulator, and I had taught myself some C++, but of course the content of the book was a bit beyond my capacity at the time. It's nice to relive the excitement of getting this book with the idea of being able to make my own flight sim. Of course, the sim they make in the book, IIRC, was nigh unplayable!
[+] yayitswei|2 years ago|reply
This and "The Black Art of 3D Game Programming" were my two favorites from my childhood!

https://archive.org/details/BlackArt3DEBook

[+] zeroc8|2 years ago|reply
Tricks of the Windows Game Programming Gurus was great too. And tricks of the 3D Game Programming Gurus contains a full 3D engine in C starting from drawing a pixel (a software rasterizer).
[+] metadat|2 years ago|reply
I wish there were more articles published like this today! So cool.

BTW, the ePub link can't download:

https://ia904505.us.archive.org/epub/index.php?id=build-your...

> No valid doc name could be determined

Bummer, but I'll settle for the PDF. Unfortunate that IA's webviewer sucks.

Working PDF link: https://archive.org/download/build-your-own-flight-sim-in-c-...

[+] pronoiac|2 years ago|reply
Huh. I was able to get a working epub, but I'd recommend the pdf version instead. The OCR and formatting for the epub are automated rough drafts.
[+] sixothree|2 years ago|reply
ePub I think gets generated on first request.
[+] physicles|2 years ago|reply
I still have the programs I wrote when I went through this book. The experience of bringing a 3D world to life felt like magic: you start with a black screen, draw some lines, and when you move them around in just the right way there’s suddenly a world inside the screen. It’s hard to get that same feeling today.

I think I was gifted this book for my 13th birthday so some of the math was a bit beyond me. But learning assembly and working out some of the more intricate algorithms like polygon clipping were both great training for a new programmer.

[+] kqr|2 years ago|reply
Why is it hard today? A few months ago I started writing a software rasteriser and got that exact feeling.
[+] jandrese|2 years ago|reply
It's impressive how many pages are devoted to creating the universe in the book. Back then you didn't just fire up the OpenGL library to initialize the stack. This book starts off with how to set the registers on your VGA card to put it in the right mode, how to read in bitmaps and their palettes from the disk, how to write your own run length encoder to save memory on those bitmaps, what registers to set on the joystick port, and so on.
[+] JKCalhoun|2 years ago|reply
Yeah, worked through this book (had to make changes since I was on a Mac). Implemented Bresenham's, polygon clipping, rear-face culling ....

Normally the math would have tripped me up with the new-to-me matrices, dot products, cross products, etc. As chance would have it I was taking a summer course on Linear Algebra at college so the book dovetailed rather nicely with the lectures.

[+] JoeDaDude|2 years ago|reply
IIRC, this book had a 5.25" floppy inside that allowed one to fly the simulator around some pyramid shaped mountains. This brings back fond memories, thanks for posting.
[+] pronoiac|2 years ago|reply
There's an 11 meg iso file included, and there are some exe files among its contents.
[+] tibbon|2 years ago|reply
Is it just me, or were so many books from this era just outright bad?

I spent a few years teaching at General Assembly, and in that time I learned so much about pedology, how I often learn, how others learn, and that I can't always assume the way I learn will be appropriate for others, particularly in text format.

I had Teach Yourself Game Programming in 21 Days, by Andre LaMothe when I was an early teen. I made repeated attempts at learning game programming with it, finding only failure each time. Maybe I wasn't cut out for programming? I put it away, and went to school for music instead.

Years later, no thanks to this book, I'm a pretty good programmer. I've looked over it again, and I'm aghast at what I see. It bills itself as needing no real experience. It jumps from "this is a mouse" in chapter 1, to some pretty advanced VGA screen manipulation between chapters 2 and 3. Loops, functions, OOP, data types? Nah - it just throws code at you without concepts. It is shocking if anyone learned from this. I was worse off having read it, and nearly 30 years later kinda salty about it!

I'm good at learning from books too! I taught myself Ruby after reading _why's poigiant guide, Agile Development with Ruby on Rails, the Pickaxe book, POODR, and the Ruby internals book. If a book structures information well, and I can sit and work on practice problems, I can get the concept.

Maybe we learned a lot about how to write programming books around this era? I've generally found books on O'Reilly, Addison-Wesley, No Starch Press, etc to be rather good. They generally consider how to structure learning and information in a way that is progressive and don't make too many leaps. These "Learn in X days" style books in the 90's were basically info dumps, and without Google it was nearly impossible as a kid in the 90's to get help. No adults around me had any idea, and if it didn't work - it didn't work.

I'm curious what the breakthrough was, or what changed. The first decent programming book I ever read was Programming Perl by Larry Wall. I came to it much later, but the ANSI C book made a ton of sense upon first read too.

A good modern intro to game development (and Rust) can be found with Hands-on Rust: Effective Learning through 2D Game Development and Play. It doesn't dive deep into the more difficult parts of Rust, but it also doesn't make you feel like an idiot.

For a look back at 90's games, the Game Engine Black Book: DOOM by Fabien Sanglard really helped me understand the systems and logic of Doom and other similar games.

[+] tralarpa|2 years ago|reply
I agree that many books were bad simply because the authors could not write well and had no idea about pedagogy. I think the number of people who knew something about a particular subject was just smaller and that's why it wasn't questioned much by the publishers.

Another reason may be the fact that a lot of information could not yet be found on the Internet. That is why some authors were more interested in listing the information than in pedagogical communication. The result were books like "Chapter 1: How to start the compiler from command line", "Chapter 2: List of all functions of the standard library", no chapter 3.

[+] NikkiA|2 years ago|reply
There was another similar book, that predated C++ / OOP popularity, that made a big fuss on the cover about how it taught quaternions.
[+] TuringTourist|2 years ago|reply
Do you happen to recall the title of that book? Or what it was about?
[+] MathMonkeyMan|2 years ago|reply
A contemporary explanation of near and far pointers on page 16. Today I learned.
[+] couchand|2 years ago|reply
The dedication of this book is quite fitting: "to the continued free exchange of ideas on the net."

This was the book that opened my eyes to big projects. Until I found this it had been mostly just keying in monster basic programs.

[+] ilrwbwrkhv|2 years ago|reply
Wow I actually remember this. That cover was sharply buried somewhere in my memory. It's a shame websites don't have that same level of tactical and visual information to seed a deep memory.
[+] carl_sandland|2 years ago|reply
Great book and great memories, now get off my lawn.

I'd love a book in similar spirit, targeting say OSx/Metal, that started from first principles and built a 3d (flight|space) sim, in a fun language (simple C++). And yeah that means a blank screen, then some lines, then a triangle... etc. I'd take a series of followup books adding more to engine, perhaps targeting different styles of games and their engine tradeoffs.

I guess it would be hard to decide between software/hardware rendering, as software would just teach so much.

[+] password4321|2 years ago|reply
What about all the game dev books by Andre LaMothe?

I recycled my collection... I should check to see if I kept the included CD-ROMs.

[+] badsectoracula|2 years ago|reply
I have Andre LaMothe's "Tricks of the 3D Game Programming Gurus", which in recent years i've been using as a height lift for stuff (like a CRT in this photo[0]) as it is massive :-P

The book is nice but LaMothe needed an editor badly, not only there are endless reams of source code in the book (despite coming with a CD-ROM), he was also often incredibly verbose to the point where by the time i finished some section i forgot how it all began. IIRC the book was so big that it couldn't all be put in print and the last chapter (or chapters) were on CD-ROM. And the parts that were printed were still so physically big that i had a hard time reading it.

Also i think his focus was a bit too lopsided, he spent way too much on some things but barely on others. For example he spent a lot of time for various ways to do slightly different rasterizations (e.g. bilinear filtering - which, ok, it is the only gamedev related book or tutorial i know that mixed software rendering and bilinear filtering) but on the part about optimizing the renderer to not render invisible stuff (which at least IMO would be more important than doing bilinear filtering for a software rendering engine) he largely handwaved things.

[0] https://i.imgur.com/RlGm2X7.jpg

[+] tibbon|2 years ago|reply
I hate trash talking someone's hard work, but Andre's books actively set me back as a programmer and made me feel stupid. I'm glad they worked for some people, but they really shouldn't have sold themselves as for anyone, but rather for people who already knew C/C++ rather well

> This book is for anyone remotely interested in game programming, from the arcade junkie wanting to test his programming skills to current game program- mers looking for new ways to market their games. This book uses a unique day-by-day approach to teach major concepts, industry terms, and little-known secrets about game programming.

I said more about it in this comment:

https://news.ycombinator.com/item?id=37367507

[+] bvan|2 years ago|reply
Those were great books. Also, the regular column on math/physics in the Game Developer magazine - forget the name of the author.
[+] pjmlp|2 years ago|reply
Books and game consoles as well.
[+] rezmason|2 years ago|reply
I wonder if this book informed the programmers who created the Excel 97 magic carpet / flight simulator easter egg