Skip to content

Commit

Permalink
Modernize:
Browse files Browse the repository at this point in the history
- Change font links to https since browsers disable mixed security now.
- Migrate build script to Python 3.
- Update to jQuery 3.6.0.
  • Loading branch information
munificent committed Jun 10, 2021
1 parent 54ac84a commit 2de5020
Show file tree
Hide file tree
Showing 37 changed files with 1,305 additions and 2,090 deletions.
2 changes: 1 addition & 1 deletion asset/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ blockquote {
code {
color: hsl(200, 20%, 40%);
font: normal 15px $mono;
white-space: nowrap;
white-space: pre;
}

a code {
Expand Down
6 changes: 3 additions & 3 deletions asset/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
the viewport. -->
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<link rel="stylesheet" type="text/css" href="style.css" />
<link href="http://fonts.googleapis.com/css?family=Merriweather:400,400italic,700,700italic|Source+Code+Pro|Source+Sans+Pro:200,300,400,600,400italic,600italic|Rock+Salt" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Merriweather:400,400italic,700,700italic|Source+Code+Pro|Source+Sans+Pro:200,300,400,600,400italic,600italic|Rock+Salt" rel="stylesheet" type="text/css">
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
Expand All @@ -19,7 +19,7 @@
ga('create', 'UA-42804721-1', 'gameprogrammingpatterns.com');
ga('send', 'pageview');
</script>
<script src="jquery-1.10.1.min.js"></script>
<script src="jquery-3.6.0.min.js"></script>
<script src="script.js"></script>
</head>
<body id="top">
Expand All @@ -40,6 +40,6 @@ <h1 class="book"><a href="/">Game Programming Patterns</a>{{section_header}}</h1
</nav>
</div>
</div>
<footer>&copy; 2009-2015 Robert Nystrom</footer>
<footer>&copy; 2009-2021 Robert Nystrom</footer>
</body>
</html>
2 changes: 1 addition & 1 deletion build
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/bin/bash
python script/format.py $@
python3 script/format.py $@
10 changes: 3 additions & 7 deletions html/acknowledgements.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
the viewport. -->
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<link rel="stylesheet" type="text/css" href="style.css" />
<link href="http://fonts.googleapis.com/css?family=Merriweather:400,400italic,700,700italic|Source+Code+Pro|Source+Sans+Pro:200,300,400,600,400italic,600italic|Rock+Salt" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Merriweather:400,400italic,700,700italic|Source+Code+Pro|Source+Sans+Pro:200,300,400,600,400italic,600italic|Rock+Salt" rel="stylesheet" type="text/css">
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
Expand All @@ -19,7 +19,7 @@
ga('create', 'UA-42804721-1', 'gameprogrammingpatterns.com');
ga('send', 'pageview');
</script>
<script src="jquery-1.10.1.min.js"></script>
<script src="jquery-3.6.0.min.js"></script>
<script src="script.js"></script>
</head>
<body id="top">
Expand Down Expand Up @@ -49,23 +49,19 @@ <h1 class="book"><a href="/">Game Programming Patterns</a></h1>
up the incentive of a writing schedule, but with readers patting my back when I
finished each chapter, I had more than enough motivation.</p>
<aside name="editor">

<p>What I didn&#8217;t lose was a copy editor. Lauren Briese showed up just when I
needed her and did a wonderful job.</p>
</aside>

<p>They call this &#8220;self publishing&#8221;, but &#8220;crowd publishing&#8221; is closer to the mark.
Writing can be lonely work, but I was never alone. Even when I put the book on a
shelf for two years, the encouragement continued. Without the dozens of people
who didn&#8217;t let me forget that they were waiting for more chapters, I never would
have picked it back up and finished.</p>
<aside name="colm">

<p>Special thanks go to Colm Sloan who pored over every single chapter in the book
<em>twice</em> and gave me mountains of fantastic feedback, all out of the goodness of
his own heart. I owe you a beer or twenty.</p>
</aside>

<p>To everyone who emailed or commented, upvoted or favorited, tweeted or
retweeted, anyone who reached out to me, or told a friend about the book, or
sent me a bug report: my heart is filled with gratitude for you. Completing this
Expand All @@ -78,6 +74,6 @@ <h1 class="book"><a href="/">Game Programming Patterns</a></h1>
</nav>
</div>
</div>
<footer>&copy; 2009-2014 Robert Nystrom</footer>
<footer>&copy; 2009-2021 Robert Nystrom</footer>
</body>
</html>
34 changes: 3 additions & 31 deletions html/architecture-performance-and-games.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
the viewport. -->
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<link rel="stylesheet" type="text/css" href="style.css" />
<link href="http://fonts.googleapis.com/css?family=Merriweather:400,400italic,700,700italic|Source+Code+Pro|Source+Sans+Pro:200,300,400,600,400italic,600italic|Rock+Salt" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Merriweather:400,400italic,700,700italic|Source+Code+Pro|Source+Sans+Pro:200,300,400,600,400italic,600italic|Rock+Salt" rel="stylesheet" type="text/css">
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
Expand All @@ -19,7 +19,7 @@
ga('create', 'UA-42804721-1', 'gameprogrammingpatterns.com');
ga('send', 'pageview');
</script>
<script src="jquery-1.10.1.min.js"></script>
<script src="jquery-3.6.0.min.js"></script>
<script src="script.js"></script>
</head>
<body id="top">
Expand All @@ -39,21 +39,17 @@ <h1 class="book"><a href="/">Game Programming Patterns</a><span class="section">
about how terrible (or awesome) design patterns and software architecture are,
it will give you some ammo to use.</p>
<aside name="ammo">

<p>Note that I didn&#8217;t presume which side you&#8217;re taking in that fight. Like any arms
dealer, I have wares for sale to all combatants.</p>
</aside>

<h2><a href="#what-is-software-architecture" name="what-is-software-architecture">What is Software Architecture?</a></h2>
<p><span name="won't">If</span> you read this book cover to cover, you won&#8217;t come
away knowing the linear algebra behind 3D graphics or the calculus behind game
physics. It won&#8217;t show you how to alpha-beta prune your AI&#8217;s search tree or
simulate a room&#8217;s reverberation in your audio playback.</p>
<aside name="won't">

<p>Wow, this paragraph would make a terrible ad for the book.</p>
</aside>

<p>Instead, this book is about the code <em>between</em> all of that. It&#8217;s less about
writing code
than it is about <em>organizing</em> it. Every program has <em>some</em> organization, even if
Expand All @@ -65,10 +61,8 @@ <h2><a href="#what-is-software-architecture" name="what-is-software-architecture
<span name="suffered">bad</span>, the best you could hope to do for them is take
them out back and put them out of their misery.</p>
<aside name="suffered">

<p>Let&#8217;s admit it, most of us are <em>responsible</em> for a few of those.</p>
</aside>

<p>A lucky few have had the opposite experience, a chance to work with beautifully
designed code. The kind of codebase that feels like a perfectly appointed luxury
hotel festooned with concierges waiting eagerly on your every whim. What&#8217;s the
Expand All @@ -93,10 +87,8 @@ <h3><a href="#how-do-you-make-a-change" name="how-do-you-make-a-change">How do y
you need to <span name="ocr">load</span> all of the relevant pieces of it into
your primate brain.</p>
<aside name="ocr">

<p>It&#8217;s weird to think that this is literally an OCR process.</p>
</aside>

<p>We tend to gloss over this step, but it&#8217;s often the most time-consuming part of
programming. If you think paging some data from disk into RAM is slow, try
paging it into a simian cerebrum over a pair of optical nerves.</p>
Expand All @@ -109,14 +101,12 @@ <h3><a href="#how-do-you-make-a-change" name="how-do-you-make-a-change">How do y
<span name="tests">tests</span> and send it off for code review, you often have
some cleanup to do.</p>
<aside name="tests">

<p>Did I say &#8220;tests&#8221;? Oh, yes, I did. It&#8217;s hard to write unit tests for some game
code, but a large fraction of the codebase is perfectly testable.</p>
<p>I won&#8217;t get on a soapbox here, but I&#8217;ll ask you to consider doing more automated
testing if you aren&#8217;t already. Don&#8217;t you have better things to do than manually
validate stuff over and over again?</p>
</aside>

<p>You jammed a bit more code into your game, but you don&#8217;t want the next person to
come along to trip over the wrinkles you left throughout the source. Unless the
change is minor, there&#8217;s usually a bit of reorganization to do to make your new
Expand All @@ -127,11 +117,9 @@ <h3><a href="#how-do-you-make-a-change" name="how-do-you-make-a-change">How do y
<p><span name="life-cycle"></span></p>
<p><img src="images/architecture-cycle.png" alt="Get problem &rarr; Learn code &rarr; Code solution &rarr; Clean up &rarr; and back around to the beginning." /></p>
<aside name="life-cycle">

<p>The fact that there is no escape from that loop is a little alarming now that I
think about it.</p>
</aside>

<h3><a href="#how-can-decoupling-help" name="how-can-decoupling-help">How can decoupling help?</a></h3>
<p>While it isn&#8217;t obvious, I think much of software architecture is about that
learning phase. Loading code into neurons is so painfully slow that it pays to
Expand Down Expand Up @@ -165,15 +153,13 @@ <h2><a href="#at-what-cost" name="at-what-cost">At What Cost?</a></h2>
well and <em>keep</em> it organized throughout the thousands of little changes that
make up a development cycle.</p>
<aside name="maintain">

<p>The second half of this&#8202;&mdash;&#8202;maintaining your design&#8202;&mdash;&#8202;deserves special
attention. I&#8217;ve seen many programs start out beautifully and then die a death of a
thousand cuts as programmers add &#8220;just one tiny little hack&#8221; over and over
again.</p>
<p>Like gardening, it&#8217;s not enough to put in new plants. You must also weed and
prune.</p>
</aside>

<p>You have to think about which parts of the program should be decoupled and
introduce abstractions at those points. Likewise, you have to determine where
extensibility should be engineered in so future changes are easier to make.</p>
Expand All @@ -190,12 +176,10 @@ <h2><a href="#at-what-cost" name="at-what-cost">At What Cost?</a></h2>
modularity doesn&#8217;t end up being helpful, it quickly becomes actively harmful.
After all, it is more code you have to deal with.</p>
<aside name="yagni">

<p>Some folks coined the term &#8220;YAGNI&#8221;&#8202;&mdash;&#8202;<a href="http://en.wikipedia.org/wiki/You_aren't_gonna_need_it">You aren&#8217;t gonna need
it</a>&#8202;&mdash;&#8202;as a mantra to use
to fight this urge to speculate about what your future self may want.</p>
</aside>

<p>When people get overzealous about this, you get a codebase whose architecture
has spiraled out of control. You&#8217;ve got interfaces and abstractions everywhere.
Plug-in systems, abstract base classes, virtual methods galore, and all sorts of
Expand All @@ -217,7 +201,6 @@ <h2><a href="#performance-and-speed" name="performance-and-speed">Performance an
dispatch, interfaces, pointers, messages, and <span name="templates">other
mechanisms</span> that all have at least some runtime cost.</p>
<aside name="templates">

<p>One interesting counter-example is templates in C++. Template metaprogramming
can sometimes give you the abstraction of interfaces without any penalty at
runtime.</p>
Expand All @@ -230,7 +213,6 @@ <h2><a href="#performance-and-speed" name="performance-and-speed">Performance an
decision of which class to call at <em>compile time</em> when the template is
instantiated.</p>
</aside>

<p>There&#8217;s a reason for this. A lot of software architecture is about making your
program more flexible. It&#8217;s about making it take less effort to change it. That
means encoding fewer assumptions in the program. You use interfaces so that your
Expand Down Expand Up @@ -300,12 +282,10 @@ <h2><a href="#the-good-in-bad-code" name="the-good-in-bad-code">The Good in Bad
there&#8217;s a <em>chance</em> you&#8217;ll end up having to keep it around, you may have to
defensively write it well.</p>
<aside name="throwaway">

<p>One trick to ensuring your prototype code isn&#8217;t obliged to become real code is
to write it in a language different from the one your game uses. That way, you have to
rewrite it before it can end up in your actual game.</p>
</aside>

<h2><a href="#striking-a-balance" name="striking-a-balance">Striking a Balance</a></h2>
<p>We have a few forces in play:</p>
<ol>
Expand All @@ -315,12 +295,10 @@ <h2><a href="#striking-a-balance" name="striking-a-balance">Striking a Balance</
<li>We want to get today&#8217;s features done quickly.</li>
</ol>
<aside name="speed">

<p>I think it&#8217;s interesting that these are all about some kind of speed: our
long-term development speed, the game&#8217;s execution speed, and our short-term
development speed.</p>
</aside>

<p>These goals are at least partially in opposition. Good architecture improves
productivity over the long term, but maintaining it means every change requires
a little more effort to keep things clean.</p>
Expand All @@ -342,12 +320,10 @@ <h2><a href="#striking-a-balance" name="striking-a-balance">Striking a Balance</
that. A field you can master in a week is ultimately boring. You don&#8217;t hear of
someone&#8217;s distinguished career in <span name="ditch">ditch digging</span>.</p>
<aside name="ditch">

<p>Maybe you do; I didn&#8217;t research that analogy. For all I know, there could be avid
ditch digging hobbyists, ditch digging conventions, and a whole subculture
around it. Who am I to judge?</p>
</aside>

<p>To me, this has much in common with games themselves. A game like chess
can never be mastered because all of the pieces are so perfectly balanced
against one another. This means you can spend your life exploring the vast space
Expand All @@ -369,7 +345,6 @@ <h2><a href="#simplicity" name="simplicity">Simplicity</a></h2>
code, but a good solution isn&#8217;t an accretion of code, it&#8217;s a <em>distillation</em> of
it.</p>
<aside name="simple">

<p>Blaise Pascal famously ended a letter with, &#8220;I would have written a shorter
letter, but I did not have the time.&#8221;</p>
<p>Another choice quote comes from Antoine de Saint-Exupery: &#8220;Perfection is
Expand All @@ -378,7 +353,6 @@ <h2><a href="#simplicity" name="simplicity">Simplicity</a></h2>
<p>Closer to home, I&#8217;ll note that every time I revise a chapter in this book, it
gets shorter. Some chapters are tightened by 20% by the time they&#8217;re done.</p>
</aside>

<p>We&#8217;re rarely presented with an elegant problem. Instead, it&#8217;s a pile of use
cases. You want the X to do Y when Z, but W when A, and so on. In other words, a
long list of different example behaviors.</p>
Expand Down Expand Up @@ -411,11 +385,9 @@ <h2><a href="#get-on-with-it,-already" name="get-on-with-it,-already">Get On Wit
</li>
</ul>
<aside name="think">

<p>Trust me, two months before shipping is <em>not</em> when you want to start worrying
about that nagging little &#8220;game only runs at 1 FPS&#8221; problem.</p>
</aside>

<ul>
<li>
<p>Move quickly to explore your game&#8217;s design space, but don&#8217;t go so fast that
Expand All @@ -438,6 +410,6 @@ <h2><a href="#get-on-with-it,-already" name="get-on-with-it,-already">Get On Wit
</nav>
</div>
</div>
<footer>&copy; 2009-2014 Robert Nystrom</footer>
<footer>&copy; 2009-2021 Robert Nystrom</footer>
</body>
</html>
6 changes: 3 additions & 3 deletions html/behavioral-patterns.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
the viewport. -->
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<link rel="stylesheet" type="text/css" href="style.css" />
<link href="http://fonts.googleapis.com/css?family=Merriweather:400,400italic,700,700italic|Source+Code+Pro|Source+Sans+Pro:200,300,400,600,400italic,600italic|Rock+Salt" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Merriweather:400,400italic,700,700italic|Source+Code+Pro|Source+Sans+Pro:200,300,400,600,400italic,600italic|Rock+Salt" rel="stylesheet" type="text/css">
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
Expand All @@ -19,7 +19,7 @@
ga('create', 'UA-42804721-1', 'gameprogrammingpatterns.com');
ga('send', 'pageview');
</script>
<script src="jquery-1.10.1.min.js"></script>
<script src="jquery-3.6.0.min.js"></script>
<script src="script.js"></script>
</head>
<body id="top">
Expand Down Expand Up @@ -60,6 +60,6 @@ <h2><a href="#the-patterns" name="the-patterns">The Patterns</a></h2>
</nav>
</div>
</div>
<footer>&copy; 2009-2014 Robert Nystrom</footer>
<footer>&copy; 2009-2021 Robert Nystrom</footer>
</body>
</html>
Loading

0 comments on commit 2de5020

Please sign in to comment.