TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Thirteen Years of Bad Game Code

399 pointsby et1337about 8 years ago

25 comments

hinkleyabout 8 years ago
I tell all the junior Devs: if you aren't horrified by something you wrote a year ago, you aren't learning fast enough. 20 years in and I still find things I wrote 8 months ago that I would not do again.
评论 #14002651 未加载
评论 #14003100 未加载
评论 #14002959 未加载
评论 #14002780 未加载
评论 #14002109 未加载
评论 #14003439 未加载
评论 #14004689 未加载
评论 #14006643 未加载
评论 #14003122 未加载
评论 #14010953 未加载
评论 #14004921 未加载
评论 #14001752 未加载
评论 #14003546 未加载
geokonabout 8 years ago
He basically admits that several of the &quot;improvements&quot; boils down to ripping out patterns that decouple code instead of finding alternate solutions. They&#x27;re kinda quick and dirty, not agile, and could make refactoring a nightmare. I mean, he&#x27;s not necessarily wrong, but hindsight is 20&#x2F;20 and once you&#x27;re done you can look back and cherry-pick and say &quot;ahh, well obviously these things would always need to be coupled! I shouldn&#x27;t have done the gymnastics to decouple them!&quot; .. but that&#x27;s a dangerous mindset to start solving the problem with.<p>The whole topic of global state is very interesting and one I approach cautiously. I&#x27;d love to hear what more experienced programmers have to saw. When I go with global state I usually rely on someone else&#x27;s judgement and use a framework. Like OpenGL and the graphics pipeline has global state.. and I&#x27;m okay with that. I use Cinder&#x2F;Arduino, those things have some global states and for good reasons as well.<p>But you really try your best to find a stateless solution - and here is feels like he isn&#x27;t really trying
评论 #14001866 未加载
评论 #14001824 未加载
评论 #14001933 未加载
评论 #14002472 未加载
评论 #14002438 未加载
mirekrusinabout 8 years ago
I wish people would blog more like this.<p>Majority of blogging is focused on how to use something or describe some final idea&#x2F;conclusion. They are not bad per se but reading about failed ideas, dead ends etc. - the journey itself that lead to the final shape&#x2F;conclusion is very valuable.
kpilabout 8 years ago
I think I overused every single pattern, method, or framework I happened to learn until maybe after 15 years of coding.<p>Probably still do to some extent.<p>Nice read, and something to reflect upon for all young &quot;fundamentalist&quot;. It takes some experience to learn when to bend the rules...
评论 #14001724 未加载
评论 #14001796 未加载
评论 #14006706 未加载
Jimmyabout 8 years ago
Meh. If your code works, then it&#x27;s good.<p>Of course I don&#x27;t literally mean that; you can write code in a way that makes it easier to debug, extend, etc. But too many developers get wrapped up in engineering the perfect system and forget that they&#x27;re supposed to be, you know, writing a program. I think this is why a lot of hobbyist projects run out of steam.
评论 #14007151 未加载
评论 #14003565 未加载
评论 #14003919 未加载
评论 #14004157 未加载
评论 #14003037 未加载
评论 #14003485 未加载
z3t4about 8 years ago
I might be biased as I agree 100% on the takeaway, but this is amazing! Not only did he use best practice, but most importantly he made his own conclusions, and learned new things, instead of just accepting things how they where.<p>When I started coding, I though you could only have one letter variables, like a, b, c, x, y, z. I did not question this, but one day I ran out of variables ...<p>Edit:<p>I looked at some of his other posts and saw an altitude bed on an old photo, witch concludes he probably is&#x2F;was an athlete. I think it&#x27;s common among athletes to have the mindset that they want to keep improving their skill level. This can be a good trait as a developer, but they are hard to manage, as such persons will quickly outperform their colleges and get bored. They work best with other people like themselves, or with old experienced developers. Make sure you protect him so that he do not burn out himself or his team. While these &quot;10X&quot; developers can work very hard, they are just humans.
评论 #14002840 未加载
评论 #14004209 未加载
janwillembabout 8 years ago
&gt; I was thirteen<p>No need to be harsh on yourself if you created games like this on that age!
评论 #14001439 未加载
hopfogabout 8 years ago
I&#x27;ve been running a browser-based MMORPG for a couple of years and when I started out I was a total novice in Node.js. I didn&#x27;t even know how modules worked so the back end was just one big file. Needless to say, the code is a complete mess and the refactoring has made it even worse since I&#x27;ve started to implement some patterns just to regret it.<p>I&#x27;m thinking of making the whole game open source but I&#x27;m so ashamed of the codebase that I don&#x27;t want anyone to see it. It&#x27;s a dilemma since I think the game has potential as an open source project. It&#x27;s inspired by Ultima Online, Minecraft and Reign of Kings but with a lot of constraints making it easy to implement new features. It also has quite a few dedicated players.
评论 #14002017 未加载
评论 #14002008 未加载
OskarSabout 8 years ago
&gt; There are many, many more embarrassing mistakes to discuss. I discovered another &quot;creative&quot; method to avoid globals. For some time I was obsessed with closures. I designed an &quot;entity&quot; &quot;component&quot; &quot;system&quot; that was anything but. I tried to multithread a voxel engine by sprinkling locks everywhere.<p>Dear God, I feel like I&#x27;m having my game dev life read back to me...
ianlevesqueabout 8 years ago
Made me wish I had more of my old code to cringe at, but honestly I cringe after just a few weeks removed from a project.
partycoderabout 8 years ago
For booleans prefer prefixes such as: has, can, is. e.g: hasEnemies.
评论 #14001723 未加载
TeMPOraLabout 8 years ago
I have a very similar history (though a lot worse games). I still have the backups of my first OpenGL programs and game code from ~16 years ago, I might put up a similar article at some point. The difference is that the author&#x27;s game seem to improve visually over the years; mine actually regressed from 3D to 2D world (since the latter is easier to manage) ;).<p>Some random comments follow.<p>&gt; <i>Still, I loved data binding so much that I built the entire game on top of it. I broke down objects into components and bound their properties together. Things quickly got out of hand.</i><p>Boy, you have to see JavaFX. And I inherited a codebase at work written by a cow-orker who was absolutely in love with bindings at that moment...<p>Also the big blob of code reminded me why good macros in a language (not C-like macros) are a blessing ;).<p>&gt; <i>Separate behavior and state.</i><p>Yeah, learned that same lesson too. I prefer to think in systems operating on data as opposed to a web of objects calling each other. One of the reason is that the web of objects is very implicit; you soon have no idea who actually refers to who anymore.<p>&gt; <i>If I start typing self. in an IDE, these functions will not show up next to each other in the autocomplete menu.</i><p>That&#x27;s a good and <i>practical</i> point, though I feel dirty about renaming functions for solely that reason. I wonder if this isn&#x27;t time to experiment with some &quot;first-class editor semantics&quot;. Here, ability to explicitly mark functions as grouped together solely for the purpose of IDE displaying them like that in autocomplete and outline view. In my evening Lisping, I&#x27;d love to have more control over indentation for macros I write.<p>&gt; <i>global variables are Bad™</i><p>Yeah, that&#x27;s almost like &quot;goto considered harmful&quot;, and about as much correct as a soundbite (i.e. not very). Unfortunately, everyone keeps writing how global variables are evil, and what I&#x27;d love to read is some treatment on how to use global variables correctly. For the situations where - like often in games - you absolutely, positively <i>need</i> a lot of globally accessible data.<p>&gt; <i>Group interdependent code together into cohesive systems to minimize these invisible dependencies. A good way to enforce this is to throw everything related to a system onto its own thread, and force the rest of the code to communicate with it via messaging.</i><p>That&#x27;s a... very self-conscious approach. Odysseus-tied-to-a-mast style.
评论 #14004113 未加载
miragesabout 8 years ago
Well one day I didn&#x27;t foudn anything better to solve my sync issue with queries to the server than putting a Thread.Sleep(int) the variable name for it was<p><pre><code> private int DO_NOT_TOUCH_THIS_IF_YOU_DONT_KNOW_WHAT_YOU_ARE_DOING_Timeout = 7000; </code></pre> The code actually made it and is still in production
pranceabout 8 years ago
&gt; Unfortunately, Sun decided that almost all Java errors must be recoverable, which results in lazy error handling like the above.<p>Not quite: Java insists that all (checked) Exceptions be handled or passed up explicitly. One can argue that this design decision is bad, as has been done extensively elsewhere.<p>However, in the particular example given, I&#x27;d argue that it would have made much more sense to display a user-understandable error message to the user (e.g. &quot;Required gun resource file is missing, please re-download the game here: (...)&quot;), and then just System.exit() if it&#x27;s non-recoverable. Maybe print a stacktrace if the game was started in debug mode.
DropbearRobabout 8 years ago
I really enjoyed this read. I still look at code I write every year and cringe.<p>Everything becomes influenced by the flavour of the week.<p>Don&#x27;t be so hard on yourself, We all suck in hindsight, but its all about recognising it an constant improvement.
Sir_Cmpwnabout 8 years ago
One mistake you&#x27;re still making: cross platform. I&#x27;d love to try out Lemma on Linux :)
falsedanabout 8 years ago
&gt; <i>Unregistered HyperCam 2</i><p>This is legit af
评论 #14002141 未加载
kuerbelabout 8 years ago
As a 2nd semester cs student, that was pretty helpful. I have to design a battleship game in Java and have no idea what I&#x27;m doing actually. I&#x27;m just staring at the cursor and don&#x27;t even know where to start, and it&#x27;s comforting to know that other people struggled as well
评论 #14002227 未加载
评论 #14007306 未加载
pnathanabout 8 years ago
Haha, this is great! Memories. All those terrible lines of code I wrote when younger led up to less terrible later. I too got on some of the cargo cults until the harsh reality of the projects showed me why not. :)<p>This year marks 20 years since opening up QBasic as a 13 y&#x2F;o.
kelvin0about 8 years ago
The only way to not make any mistakes, is to do nothing. As Nike says: Just Do It!
ybluabout 8 years ago
This `for` loop looks particularly curious to me:<p><pre><code> for (int i = this.bindings.Count - 1; i &gt;= 0; i = Math.Min(this.bindings.Count - 1, i - 1)) </code></pre> Why isn&#x27;t the last expression a normal i--?
评论 #14009393 未加载
jlebrechabout 8 years ago
I want to start writing something that would have been on the original atari to begin with, just have to look like that style. and keep moving up a generation in terms of gameplay.
评论 #14005172 未加载
davidbiehlabout 8 years ago
i would love to read a follow up that dove into the PHP dark ages. i was doing PHP around that time as well.
JCDenton2052about 8 years ago
I think we have all been guilty of negatively-named booleans at some point or other.
eigenbomabout 8 years ago
A good retrospective. I&#x27;m always inspired by Evan&#x27;s passion and ability.