logo

drewdevault.com

[mirror] blog and personal website of Drew DeVault git clone https://hacktivis.me/git/mirror/drewdevault.com.git

Open-sourcing-video-games.md (14276B)


  1. ---
  2. title: The complete guide for open sourcing video games
  3. date: 2021-03-23
  4. ---
  5. Video games are an interesting class of software. Unlike most software, they are
  6. a creative endeavour, rather than a practical utility. Where most software
  7. calls for new features to address practical needs of their users, video games
  8. call for new features to serve the creative vision of their makers. Similarly,
  9. matters like refactoring and paying down tech debt are often heavily
  10. de-prioritized in favor of shipping something ASAP. Many of the collaborative
  11. benefits of open source are less applicable to video games. It is perhaps for
  12. these reasons that there are very few commercial open source games.
  13. However, there are some examples of such games, and they have had a great deal
  14. of influence on gaming. Id is famous for this, having released the source code
  15. for several versions of DOOM. The Quake engine was also released under the GPL,
  16. and went on to be highly influential, serving as the basis for dozens of games,
  17. including time-honored favorites such as the Half Life series. Large swaths of
  18. the gaming canon were made possible thanks to the generous contributions of open
  19. source game publishers.
  20. Publishing open source games is also a matter of historical preservation.
  21. Proprietary games tend to atrophy. Long after their heyday, with suitable
  22. platforms scarce and physical copies difficult to obtain, many games die a slow
  23. and quiet death, forgotten to the annals of time. Some games have overcome this
  24. by releasing their source code, making it easier for fans to port the game to
  25. new platforms and keep it alive.
  26. What will your game's legacy be? Will it be forgotten entirely, unable to run on
  27. contemporary platforms? Will it be source-available, occasionally useful to the
  28. devoted player, but with little reach beyond? Perhaps it goes the way of DOOM,
  29. living forever in ports to hundreds of devices and operating systems. Maybe it
  30. goes the way of Quake, its soul forever a part of the beloved classics of the
  31. future. If you keep the source code closed, the only conclusion is the first:
  32. enjoyed once, now forgotten.
  33. With this in mind, how do you go about securing your game's legacy?
  34. ## Source available: the bare minimum
  35. The bare minimum is to make your game "source available". Be aware that this is
  36. not the same thing as making it open source! Some of your famous peers in this
  37. category include Alien 3, Civilization IV and V, Crysis, Deus Ex, Prince of
  38. Persia, Unreal Tournament, and VVVVVV.
  39. This approach makes your source code available to view and perhaps to compile
  40. and run, but prohibits derivative works. This is definitely better than leaving
  41. it closed source: it provides helpful resources for modders, speedrunners, and
  42. other fans; and devoted players may be able to use it as the basis for getting
  43. the game running on future platforms, albeit alone and unable to share their
  44. work.
  45. If you choose a minimal enforcement approach, then some players might ultimately
  46. share their work, but you're leaving them on tenuous legal grounds. I would
  47. recommend this if you're very protective of your IP, but know that you're
  48. limiting the potential second life of your game if you take this approach.
  49. ## Copyleft with proprietary assets
  50. The next step up is to make your game open source using a *copyleft* license,
  51. but refraining from extending the license to the assets — anyone who wants
  52. to get the source code working would either need to buy the game from you and
  53. extract the assets, or supply their own community-made assets. This is a popular
  54. approach among open source games, and gives you most of the benefits and few of
  55. the drawbacks. You'll join the ranks of our DOOM and Quake examples, as well as
  56. Amnesia: the Dark Descent, System Shock, Duke Nukem 3D, and Wolfenstein 3D.
  57. Games like this enjoy a long life as their software is more easily ported to new
  58. platforms and shared with other users. DOOM runs on phones, digital cameras,
  59. ATMs, even toasters! Its legacy is secure without any ongoing commitment from
  60. the original developers. This also allows derivatives works — new games
  61. based on your code — though it may turn some developers away. Using a
  62. copyleft license like the [GPL](https://www.gnu.org/licenses/gpl-3.0.en.html)
  63. requires derivative works to *also* be made open source. The community generally
  64. has no problem with this, but it may affect the willingness of future developers
  65. to incorporate your work into their own commercial games. I personally think
  66. that the proliferation of open source software that's implied in the use of a
  67. copyleft license is a positive thing — but you may want to use another
  68. approach.
  69. ## Permissive license, proprietary assets
  70. If you want to allow your source code to find its way into as many future games
  71. as possible, a permissive open source license like [MIT][0] is the way to go.
  72. [Flotilla](https://github.com/blendogames/flotilla) is an example of a game
  73. which went with this approach. It allows developers to incorporate your source
  74. code into their own games with little restriction, either by creating a direct
  75. derivative, or by taking little samples of your code and incorporating it into
  76. their own project. This comes with no obligation to release their own changes or
  77. works in a similar fashion: they can just take it, with very few strings
  78. attached. Such an approach makes it very easy to incorporate into new commercial
  79. games.
  80. [0]: https://opensource.org/licenses/MIT
  81. This is the most selfless way to release your code. I would recommend this if
  82. you don't care about what happens to your code later, and you just want to make
  83. it open source and move on. Though this will definitely enable the largest
  84. number of future projects to make use of your work, the copyleft approach is
  85. better for ensuring that the largest possible number of future games are *also*
  86. open source.
  87. ## Open assets
  88. If you're feeling especially generous, you could release the assets, too. Good
  89. licenses for this includes the [Creative Commons](https://creativecommons.org/)
  90. licenses. All of them permit free redistribution of your assets, so future
  91. players won't have to buy your game to get them. This could be important if the
  92. distribution platform you used is defunct, or if you're not around to buy it
  93. from — consider this well before deciding that you'd rather keep your
  94. share of the dwindling asset sales as your game ages.
  95. Using Creative Commons also allows you to tune the degree to which your assets
  96. may be re-used. You can choose different CC licenses to control the
  97. commercialization of your assets and use in derivative works. To allow free
  98. redistribution and nothing else, the CC-NC-ND license (noncommercial, no
  99. derivatives) will do the trick. The CC-BY-SA license is the copyleft of creative
  100. commons: it will allow free redistribution, commercialization, and derivative
  101. works, *if* the derivatives are also shared with the same rights. The permissive
  102. approach is CC-0, which is equivalent to releasing your assets into the public
  103. domain.
  104. Permitting derivatives and re-commercialization of your assets can save a lot of
  105. time for new game developers, especially indie devs with a small budget. It's
  106. also cool for making derivative *games*, similar to modding, where creative
  107. players can remix your assets to make a new game or expansion pack.
  108. ## What if I don't completely own my game?
  109. You can't give away the rights to anything you don't own. If you rely on
  110. proprietary libraries, or a third-party level editor, or you don't own the
  111. rights to the music or sprites, you cannot make them open source.
  112. In this situation, I recommend open sourcing everything that you're able to.
  113. This might mean that you open source an ultimately broken game — it simply
  114. might not work, or not even compile, without these resources. This is
  115. unfortunate, but by releasing everything you can, you leave your community in a
  116. good position to fill in the gaps themselves, perhaps by refactoring your code
  117. to work around them, or by replacing the proprietary bits with free
  118. alternatives. This also allows the parts of your game which are open to be
  119. reused in future games.
  120. ## But cheaters could use it!
  121. This is true. And it's worth noting that if your game has a mandatory online
  122. component based on your own servers, then making it open source doesn't make
  123. nearly as much sense, especially if you ultimately decide to shut those servers
  124. off.
  125. There is a trade-off to be made here. In truth, it's very difficult to prevent
  126. cheating in your game. If you've made a popular competitive multiplayer game,
  127. you and I both know that there are still cheaters using it despite your best
  128. efforts. Keeping it proprietary is not going to stave off cheaters. Social
  129. solutions are better — like a system to report cheaters, or to let friends
  130. play on private servers.
  131. Making your game open source might help less skilled script kiddie figure out
  132. how to cheat more easily in your game. I can't decide for you if the trade-off
  133. is worth it for your game, but I can tell you that the benefits of making it
  134. open are vast, and the efficacy of keeping it closed to prevent cheating is
  135. questionable.
  136. ## But my code is embarrassing!
  137. So is everyone else's. 🙂 We all know that games are running up against tight
  138. deadlines and clean code is not going to be the #1 priority. I assure you that
  139. your community will be too busy having fun to judge you for the quality of your
  140. code. The idea that it just needs to be "cleaned up" first is the death of many
  141. projects which would otherwise have been made open source. If you feel this way,
  142. you will probably never be satisfied, and thus you'll never open it. I assure
  143. you: your game is ready to make open source, no matter what state it's in!
  144. Bonus: Ethan Lee tipped me off to some truly awful code which was left in
  145. VVVVVV, which you can freely browse on the [2.2 tag][vvvvvv 2.2]. It's not
  146. great, but you probably didn't know that — you only remember VVVVVV as a
  147. critically acclaimed game. Game developers are working under tight constraints
  148. and no one is judging them for that — we just want to have fun!
  149. [vvvvvv 2.2]: https://github.com/TerryCavanagh/vvvvvv/tree/2.2
  150. ## So what do I need to do?
  151. Let's lay out the specific steps. You need to answer the following questions
  152. first:
  153. - Do I actually own the entire game? What parts am I allowed to open source?
  154. - Will I make the code source-available, copyleft, or permissively licensed?
  155. - And the assets? Proprietary? Creative Commons? If the latter, which version?
  156. If you're not sure what's best, I would recommend using the GPL for your code,
  157. and CC-BY-SA for the assets. This allows for derivative works, so long as
  158. they're also made open with a similar license. This enables the community to
  159. build on your work, porting it to new platforms, building a thriving modding
  160. community, and freely sharing your assets, ensuring an enduring legacy for your
  161. game. If you'd like to decide the details for yourself, review the comments
  162. above once again and pick out the licenses you'd like to use for each before
  163. moving on.
  164. If you need help with any of these steps, or have any questions, please [send me
  165. an email](mailto:sir@cmpwn.com), and I will help you to the best of my ability.
  166. **Publishing the source code**
  167. Prepare an archive of your source code, and add the license file. If you went
  168. with the source-available approach, simply write "Copyright ©
  169. <*you*> <*current year*>. All rights reserved." into a text file
  170. named LICENSE. If you chose something else, copy the license text into a
  171. LICENSE file.
  172. If you want this over with quickly, just stick the code and license into a zip
  173. file or a tarball and drop it on your website. A better approach, if you have
  174. the patience, would be to publish it as a git repository. If you already use
  175. version control, you may want to consider carefully if you want to publish your
  176. full version control history — the answer might be "yes", but if you're
  177. unsure, the answer is probably "no". Just make a copy of the code, delete the
  178. .git directory, and import it into a new repository if you need to.
  179. Double check that you aren't checking in any artifacts — assets,
  180. executables, libraries, etc — and then push it to the hosting service of
  181. your choice. GitHub is a popular choice, but I would selfishly recommend
  182. [sourcehut](https://sourcehut.org) as well. If you have time, write a little
  183. README file which gives an introduction to the project as well.
  184. **Publishing the assets**
  185. If you choose to leave the assets proprietary, then there are no further steps.
  186. Players can figure out how to extract the assets from their purchased game.
  187. If you choose to make them open, prepare an archive of your assets. Include a
  188. copy of the license you choose — e.g. which Creative Commons license you
  189. used — and drop it into a zip file or a tarball or something similar.
  190. Stick this on your website, and if you're feeling generous, prepare some
  191. instructions for how to incorporate the asset bundle into the game once a player
  192. compiles your code.
  193. **Tell the world!**
  194. Let everyone know that you've made your game open source! Write a little blog
  195. post, link to the source and assets, and enjoy a little bit more of the
  196. limelight while the press and the community thanks you for your contribution.
  197. One final request on this note: if you choose the source-available approach,
  198. please refer to it as such in your public statements. Source available is *not*
  199. the same thing as "open source", and the distinction is important.
  200. And now it's my turn to thank you: I'm so happy that you've released your game
  201. as an open source project! The community is much richer for your contribution to
  202. it, and I hope that your game will live on for many years to come, both in self
  203. through ports and mods, and in spirit through its contributions to future games.
  204. You've done a wonderful thing. Thank you!
  205. If you found this guide helpful in publishing your game, please [email
  206. me](mailto:sir@cmpwn.com) so I can play it!
  207. ---
  208. List of FOSS games inspired by this guide:
  209. - [Castaway](https://www.usebox.net/jjm/blog/castaway-source-code/)
  210. - [The Return of Traxtor](https://www.usebox.net/jjm/blog/the-return-of-traxtor-cpc-source-code/)
  211. - Yours?