The blog post details the author's successful porting of both Terraria and Celeste to WebAssembly using a custom C# runtime built upon Mono. This allows both games to run directly within a web browser without plugins or installation. The author highlights the challenges encountered, particularly with handling graphics and input, and explains the solutions implemented, such as utilizing SDL2 and Emscripten. While performance isn't yet perfect, particularly with Terraria's more complex world generation, both games are demonstrably playable in the browser, showcasing the potential of WebAssembly for running demanding applications.
This blog post by Velzie chronicles their ambitious project of porting two popular indie games, Terraria and Celeste, to WebAssembly (Wasm) using the Emscripten compiler. The ultimate goal is to enable these games to run natively in a web browser without requiring plugins or external software. The post focuses primarily on the challenges and successes experienced while porting Celeste, highlighting the complexities involved in adapting a game designed for a desktop environment to the constraints and capabilities of the web.
Velzie begins by outlining their motivation, driven by a desire to experiment with Wasm and explore the potential of web-based gaming. They then detail the technical hurdles they faced. One major obstacle was managing the game's file system, which required emulation within the browser environment. This involved creating a virtual file system within Wasm that could mimic the game's original file access patterns. Another significant challenge was handling the game's audio output, which required careful integration with the browser's audio APIs. Velzie explains how they tackled this by utilizing the SDL2 library and leveraging its audio capabilities within the Wasm context.
The post further elaborates on the performance considerations of running a computationally intensive game like Celeste within a browser. Velzie discusses the optimization techniques employed to improve performance, including memory management strategies and code optimizations specific to the Wasm compilation process. They describe the iterative process of identifying performance bottlenecks and implementing targeted solutions to ensure smooth gameplay.
The author also delves into the nuances of handling user input, requiring mapping keyboard and mouse events to the game's input system within the Wasm environment. They explain how they achieved this mapping using Emscripten’s input handling functionalities, enabling players to control the game seamlessly within the browser.
Throughout the post, Velzie shares code snippets and technical insights into the porting process. While acknowledging that the project is still a work in progress, the demonstrable results showcase the feasibility and potential of running complex games like Celeste within a web browser using WebAssembly. The post concludes with reflections on the lessons learned and future directions for the project, hinting at the possibility of expanding the Wasm port to encompass other games as well. It emphasizes the exciting potential of Wasm as a powerful technology for bringing demanding applications, particularly games, to the web platform.
Summary of Comments ( 38 )
https://news.ycombinator.com/item?id=44101175
HN users discussed the technical challenges and successes of porting games to WebAssembly. Several commenters praised the developer's work, particularly the performance achieved with Celeste, noting it felt native. Some discussed the complexities of handling game inputs, audio, and file system access within the browser environment. A few users expressed interest in the potential of WASM for game development, seeing it as a viable platform for distributing and playing games without installations. Others shared their experiences with similar projects and offered suggestions for optimization. The legality of distributing ROMs online was also briefly touched upon.
The Hacker News post discussing the porting of Terraria and Celeste to WebAssembly generated several interesting comments. Many users praised the technical achievement, particularly the performance of the Celeste port. One user, "velzie" (presumably the author of the original blog post), clarified some details about the project, such as the use of Emscripten and the fact that the ports weren't fully completed but rather tech demos. They also mentioned the challenges they faced, like audio latency and the lack of proper gamepad support in the browser.
Several comments focused on the performance aspects. Some users expressed surprise at how well these complex games ran in a browser environment. Others discussed the potential of WebAssembly for gaming, with some arguing that it could eventually rival native performance. There was some debate about the overhead of garbage collection and the limitations of the browser's sandbox environment.
A recurring theme was the potential legal implications of these ports, specifically regarding copyright infringement. Users discussed the complexities of distributing copyrighted game assets and the potential responses from game developers.
Some users shared their own experiences with WebAssembly, mentioning other games or applications that had been successfully ported. They also discussed the tools and techniques used for WebAssembly development, including Emscripten and various JavaScript frameworks.
One commenter pointed out the irony of running computationally intensive games in a browser tab alongside other tabs, potentially impacting overall system performance. Another user suggested potential improvements to the project, such as implementing virtual gamepad controls.
Several commenters requested information about the porting process and expressed interest in learning more about WebAssembly development. They inquired about specific technical details, such as the handling of game assets and the implementation of input controls. The author, "velzie," provided some helpful responses to these questions, sharing insights into their development process and the challenges they faced.