Hacker News new | past | comments | ask | show | jobs | submit login
How I wrote Game Programming Patterns (stuffwithstuff.com)
290 points by munificent on April 25, 2014 | hide | past | favorite | 43 comments



This was a great post. I enjoyed the book, and it's always interesting to hear about a writer's process. Everyone tackles the big challenge in a different way.

The only detail I disagree with is the one about telling your friends and family what you're doing as a way to keep motivated. A few years ago I read a paper about the psychological effects of talking about goals. [0]

The takeaway was that, for most people, sharing a goal provides a sense of satisfaction and self-validation. While it is pleasing, the sensation makes us significantly less likely to accomplish goals such as writing books, losing weight, etc.

Again, I enjoyed the post very much and don't mean to nitpick. I just think this is another interesting perspective to consider when you're setting out to tackle a big goal.

[0] Unfortunately, my memory is failing me, but if anyone knows of the paper - or an article or paper along these lines - please feel free to contribute.


> Unfortunately, my memory is failing me, but if anyone knows of the paper - or an article or paper along these lines - please feel free to contribute

I believe it's normally referred to as the "Substitution effect", there's a paper by Gollwitzer et al called "When Intentions go Public"[1] that might be the one you're thinking of?

[1] http://www.psych.nyu.edu/gollwitzer/09_Gollwitzer_Sheeran_Se...


> The only detail I disagree with is the one about telling your friends and family what you're doing as a way to keep motivated.

Yeah, I didn't mention this in the post, but it ended up doing nothing for me. I did it because at the time I saw some stuff recommending it, but I don't intend to do this again.


This talk from Derek Sivers comes to mind:

http://www.ted.com/talks/derek_sivers_keep_your_goals_to_you...


I saw this paper as well. But I suspect for some people the effects of telling others will be net positive, even if that's not the average. Anecdotally, I believe that to be true for myself.


I dont have a link, but I know the paper you are referring to (and have found it to be true to my own real life experience). Congrats to the author for using that as motivation to keep up writing.


Awesome post. I'm finishing my third book, and totally recognize the agonizing over whether the book will ever get done!

On not using a conventional publisher: my first two books were with mainstream publishers (Cambridge University Press and Princeton University Press). For my third book I decided to self-publish online only, because that makes it possible to integrate animations, interactive Javascript, and so on. Four publishers have asked about publishing paper editions of the book, but it's hard to imagine going back to the printed page as the primary target medium. Having the web as the primary target is so much more powerful.


Michael Nielsen as in "Quantum Computing and Quantum Information"? If so great book.


Thanks!


I'm just replying to you so I can say to people that I've replied to you :)

Nielsen & Chuang is one of the bibles of my universities physics dept.!


Hey Micheal, just wanted to let you know i'm very, very keen on reading your DL book! The first two chapters u've put out are great, and i can't wait to read the rest of it :)


For anyone wondering about the book itself: It covers a lot of very practical, nuts-and-bolts challenges in structuring a game's codebase. It doesn't succumb to the temptation of architecture astronautics.[1] It's more like, "I'm about to type out a class that handles keyboard input. How should I write it?" For that reason, I found it to be one of the most helpful references on game programming I've yet discovered.

[1] http://www.joelonsoftware.com/articles/fog0000000018.html


This was a fantastic read! Congratulations on finishing your book.

Ever since John Resig wrote about Write Code Every Day [1], I've fallen into the habit of writing some code on a new side project of mine. Every day, at least 30 minutes of work. Not saving up things to do for the weekend makes it a lot less stressful and has increased my productivity significantly. And whatever I've been working on is constantly on my mind instead of put aside until the weekend or some other period of free time. I'm definitely reaping the benefits of not "breaking the chain."

[1] http://ejohn.org/blog/write-code-every-day/


Thanks for taking the time to write this post. It was incredibly motivating to me. A weird side effect is that I now have a scanner in my Amazon shopping cart. Once it arrives, I will start a chain where I doodle something every day, scan it and post it online. I am going to read your book so I can learn more about programming patterns in general—I'm not so interested in programming games yet. Reading the first few chapters, I can tell I'm going to learn a lot.

Also, you can put your own animal drawing on your cover now—and you get to choose which animal!

I'm looking forward to reading new posts about how you need to call your bank every few days to make more room in your account due to all the book sales. Congratulations on getting to done.


> It was incredibly motivating to me. A weird side effect is that I now have a scanner in my Amazon shopping cart. Once it arrives, I will start a chain where I doodle something every day, scan it and post it online.

This is awesome!

I used to draw (hence the hand-drawn illustrations in the book), but it's one of the many hobbies that didn't make the cut after I had kids. As someone who spends way too much time staring at a screen, there's something really therapeutic about actually working with my hands in an analog medium.


I started out as a graphic designer as well, then gradually moved into programming. I have four kids (evenly spaced between 2 and 11), so I know how you feel about extra time for fun hobbies like drawing. (we are a few weeks away from our first dog too.)

Your post reminded me that I shouldn't be spending all of my time in code working on client projects. Yes, it pays the bills, but I should (need to) do a little drawing each day to keep that part of me alive. It's not as big as writing a book, but it will be fun to see how long I can keep the chain going.

I also agree with your comment about screens vs. paper—I have one of those fancy Wacom drawing tablets, but it doesn't come close to the feel of a nice sharp 4H pencil or Pilot v5 pen on copy paper.

Thanks again for the inspiration.


I had been wondering if writing a book on GitHub in markdown was a legitimate idea or just based on my inexperience with other writing tools. I still don't know, but the author's work has convinced me that's how I want to do my next writing project.


Yes, I really loved the workflow I ended up with. Putting it on GitHub has been hugely helpful. I merged four pull requests and closed twenty bugs this morning. How awesome is that?


It really is wonderful to work on documents with git and markdown is the perfect pairing of text format. There seems to be a huge opportunity waiting for someone to make a GitHub marketed to non-techie writers.


I believe Loren already made it: https://www.penflip.com/

(Caveat: I've signed up but never used it.)


if you already know git (or github), it'll work for books.

but i doubt it's the best change-tracking system for them.

too much irrelevant crap, and it doesn't cut to the heart of those things that actually need to be done for a book.

plus, most writers will never slog through learning github.

to make a system that is writer-friendly _and_ does what a book-writing change-tracking system ideally _should_ do, you'd have to hack github so much that -- in the end -- it would have been order-of-magnitude simpler (and better) to program a purpose-built system instead, from scratch.

and yes, i told loren this from day one.

he didn't believe me then.

but if you ask him now, i'll bet he won't be quite so sure.

and by the time he's done, i have no doubt he will agree.

yes, writers need a version-control system.

but no, it is most definitely _not_ github.

-bowerbird


What you say is interesting, but how much time would he have lost before he could launch if he had to write a system from scratch?

On the other hand when using something ready like git allowed him to launch quicker. If he gets traction he can always write a new system later, if not then he has saved up on a lot of time.


perhaps you meant penflip's loren, not the original poster?

if so, then yes, what i'm saying exactly is that _loren_ could have saved himself time and trouble, in the long run, by coding a purpose-built system, instead of hacking github.

what it would've cost him, however, is the huge "jumpstart" he received by proclaiming his goal as "github for writers".

the kneejerk response to that, from the tech circles, was something that created huge word-of-mouth and mind-share, not to mention a great starting user-base, of technoids.

but that was months ago, and now there's some sense of "whatever happened to penflip?" and when he goes out to sell the system to writers, the "github" label will not be a benefit at all. (if anything, it will be a liability; but i think in general writers are fully unaware of it.)

all of this is my opinion. you, like loren, may disagree.

-bowerbird


i wasn't saying this person should've built a new system.

indeed, what i said is, if you already know git/hub, use it, as you can sidestep its problem areas, to get what you need.

but in the long run, github won't work for most writers. so a purpose-built system needs to be built for them/us...

-bowerbird


I write all of my internal documentation in Markdown and then use a pandoc script to convert it to offline PDFs, rendered HTML, and break out internal vs. public facing documentation.


I have also found very similar things with my writing; one of my books is on GitHub, one is in a private repo, and a third is with a publisher. Merging pull requests is _waaaay_ easier than reading through emails or forum postings and fixing it yourself.


The combination of Github + markdown for writing a (technical) book is exactly what https://leanpub.com/ is all about, check it out. (Or, instead of writing markdown on Github, you can upload your markdown files to Dropbox which is then synced with Leanpub). Leanpub also enables you to publish a book and ask for money while you're writing it.

I've chosen Leanpub as the publishing platform for my first book. They only ask for 10% + 50c royalties and there iz zero lock-in with them.


um... leanpub.com has been around for several years now.

and they only introduced the github integration this month.

so you can't really say that is "_exactly_ what it's about."

or even that it has yet had much of a shakeout in testing.

-bowerbird


Wow, this is the best insight into the struggles of writing a book I have read. I started a book and quit on the first real hurdle. This post really stirred up something in me - about finishing something for the first time in my life. Thanks for sharing.


This is extremely inspiring. I've been on a streak ever since I read John Resig's post and your comments about your book. I'll be writing code for my side project every day, at least 30 mins. I don't know what it is ... But I'm really freaked out of breaking the chain, it keeps me really motivated. I love it.


This book looks really cool and I've always been interested in reading more about game programming. Is there a way to grab this as a pdf instead of only-online content?


Not yet, I'm working on that now.


awesome thanks for the answer! I subscribe to your ebook mailing list, would be awesome to have a update about the pdf through that funnel!


> I subscribe to your ebook mailing list, would be awesome to have a update about the pdf through that funnel!

That's one of the main reasons the list exists. :) The day the books are ready, you'll know.


If you want, you can run some wget magic to get the whole book's html files (and used css/js files) on your hard drive .

  wget -r gameprogrammingpatterns.com


> The last game I worked on, Henry Hatsworth in the Puzzling Adventure

Ah, you're that guy! I bought HHitPA because I read a reddit post by you (presumably) about it.


Great post and insight. I'm excited to start reading your book.


Just wanted to say nice work. I was browsing GPP the other day and I found it to be a valuable reference, and not just for game programmers.

On a different note, welcome to the Pacific Northwest!


Thanks! Moving to Seattle was weird: I felt like it was the place I'd always wanted to live even though I barely even knew it existed until a few years ago.


Reading it now. Thanks for sharing. I have a couple of book projects I've been pecking away at for a couple of years. This will help.

Please consider changing your site so it can be resized (two finger zoom) when viewed on an iPad. The font is on the border of being small. I often do my reading late at night. When tired I find it easier to make pages fill the screen side-to-side in landscape mode. Thanks.


This is somewhat off-topic, but if the author is still reading these comments: in the chapter on bytecode, it seems that an obvious alternative was overlooked. Don't implement your own little language. Take one that's already there. Lua, Python, JavaScript, there are lots of them! Why not?


I think it mentions Lua and a few others. I think the chapter is equally applicable to those too. It's as much about how to implement your language as it is about how those languages were implemented.

(In particular, I learned much of what I know about bytecode VMs from Lua's implementation.)


Yes, you mentioned them. But what surprised me is that you never suggested using them, instead of implementing your own. I understand that sometimes implementing your own is the way to go, but surely sometimes it makes sense to just use Lua?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: