Recent Posts
Archives

Posts Tagged ‘GameDevelopment’

PostHeaderIcon [OxidizeConf2024] A Journey to Fullstack Mobile Game Development in Rust

From C# to Rust: A Transformative Journey

The mobile gaming industry, long dominated by Unity and C#, is witnessing a shift toward open-source technologies that promise enhanced performance and developer experience. Stefan Dilly, founder of RustUnit, shared his five-year journey of adopting Rust for mobile game development at OxidizeConf2024. Stefan, a seasoned developer and maintainer of the open-source GitUI, traced his progression from integrating Rust libraries in a Go backend and C# frontend to building fullstack Rust mobile games, culminating in the launch of Zoolitaire, a testament to Rust’s growing viability in gaming.

Initially, Stefan’s team at GameRiser in 2019 used Rust for AI calculations within a Go backend, interfacing with a Unity-based C# frontend via a cumbersome C FFI and JSON serialization. This approach, while functional, was verbose and slow, hampered by Go’s garbage collector and Unity’s long iteration times. The challenges prompted a pivot to a Rust-based backend in late 2019, leveraging the stabilization of async/await. Despite early hurdles, such as a buggy MongoDB driver, this transition yielded a more robust server for games like Wheelie Royale, a multiplayer motorcycle racing game.

Advancing Frontend Integration

The next phase of Stefan’s journey focused on improving frontend integration. By replacing JSON with Protocol Buffers (protobuf), his team streamlined communication between Rust and Unity, reducing memory overhead and improving performance. This allowed shared code between backend and frontend, enhancing maintainability. However, Unity’s limitations, such as slow reload times, spurred Stefan to explore fullstack Rust solutions. The advent of the Bevy game engine, known for its Entity Component System (ECS) and WebGPU rendering, marked a turning point, enabling native Rust game development without Unity’s constraints.

Stefan showcased Zoolitaire, a mobile game built entirely in Rust using Bevy, featuring deterministic game logic shared between client and server. This ensures fairness by validating gameplay on the server, a critical feature for competitive games. The open-source Bevy plugins developed by RustUnit, supporting iOS-specific features like in-app purchases and notifications, further demonstrate Rust’s potential to deliver a complete gaming ecosystem. These plugins, available on GitHub, empower developers to create feature-rich mobile games with minimal dependencies.

The Future of Rust in Gaming

Looking ahead, Stefan envisions Rust playing a significant role in game development, particularly as companies seek alternatives to Unity’s licensing model. The Bevy engine’s rapid growth and community support make it a strong contender, though challenges remain, such as limited console support and the learning curve for Rust’s borrow checker. Stefan’s experience onboarding junior developers suggests that Rust’s reputation for complexity is overstated, as its safety features and clear error messages facilitate learning, especially for those without preconceived coding habits.

The launch of a new racing game at OxidizeConf2024, playable via a browser, underscores Rust’s readiness for mobile gaming. Stefan’s call to action—inviting attendees to beat his high score—reflects the community-driven spirit of Rust development. By open-sourcing critical components and fostering collaboration through platforms like Discord, Stefan is paving the way for Rust to challenge established game engines, offering developers a performant, safe, and open-source alternative.

Links:

PostHeaderIcon [DevoxxBE2024] Let’s Use IntelliJ as a Game Engine, Just Because We Can by Alexander Chatzizacharias

At Devoxx Belgium 2024, Alexander Chatzizacharias delivered a, lighthearted yet insightful talk on the whimsical idea of using IntelliJ IDEA as a game engine. As a Java enthusiast and self-proclaimed gamer, Alexander explored the absurdity and fun of leveraging IntelliJ’s plugin platform to create games within a codebase. His session, filled with humor and technical creativity, demonstrated how curiosity-driven projects can spark innovation while entertaining developers. From rendering Pong to battling mutable state in a Space Invaders-inspired game, Alexander’s talk was a testament to the joy of experimentation.

The Origin Story: Productivity Through Play

Alexander’s journey began with a reaction to Unity 3D’s controversial per-install pricing model in 2023, prompting him to explore alternative game engines. Inspired by a prior Devoxx talk on productivity through fun, he decided to transform IntelliJ IDEA, a powerful IDE, into a game engine using its plugin platform. Built with Kotlin and Java Swing, his approach avoided external frameworks like JavaFX or Chromium Embedded Framework to maintain authenticity. The goal was to render games within IntelliJ’s existing window, interact with code, and maximize performance, all while embracing the chaos of a developer’s curiosity. Alexander’s mantra—“productivity is messing around and having fun”—set the tone for a session that balanced technical depth with playfulness.

Pong: Proving the Concept

The first milestone was recreating Pong, the 1972 game that launched the video game industry, within IntelliJ. Using intentions (Alt+Enter context menus), Alexander rendered paddles and a ball over a code editor, leveraging Java Swing for graphics and a custom Kotlin Vector2 class inspired by Unity 3D for position and direction calculations. Collision detection was implemented by iterating through code lines, wrapping each character in a rectangle, and checking for overlaps—faking physics with simple direction reversals. This “fake it till you make it” approach ensured a functional game without complex physics, proving that IntelliJ could handle basic game logic and rendering. The demo, complete with a multiplayer jest, highlighted the feasibility of embedding games in an IDE.

State Invaders: Battling Mutable Variables

Next, Alexander tackled a backend developer’s “cardinal sin”: mutable state. He created State Invaders, a Space Invaders-inspired game where players eliminate mutable variables (var keywords) from the codebase. Using IntelliJ’s PSI (Program Structure Interface), the plugin scans for mutable fields, rendering them as enemy sprites. Players shoot these “invaders,” removing the variables from the code, humorously reducing the “chance of production crashing” from 100% to 80%. A nostalgic cutscene referencing the internet meme “All your base are belong to us” added flair. The game demonstrated how plugins can interact with code structure, offering a playful way to enforce coding best practices while maintaining a functional codebase.

Packag-Man: Navigating Dependency Mazes

Addressing another developer pain point—over-reliance on packages—Alexander built Packag-Man, a Pac-Man variant. The game generates a maze from Gradle or Maven dependency names, with each letter forming a cell. Ghosts represent past dependency mistakes, and consuming them removes the corresponding package from the build file. Sound effects, including a looped clip of a presenter saying “Java,” enhanced the experience. IntelliJ’s abstractions for dependency parsing ensured compatibility with both Gradle and Maven, showcasing the platform’s flexibility. The game’s random ghost placement added challenge, reflecting the unpredictable nature of dependency management, while reinforcing the theme of cleaning up technical debt through play.

Sonic the Test Dog and Code Hero: Unit Tests and Copy-Paste Challenges

Alexander continued with Sonic the Test Dog, a Sonic-inspired game addressing inadequate unit testing. Players navigate a vertical codebase to collect unit tests (represented as coins), with a boss battle against “Velocity Nick” in a Person.java file. Removing coins deletes tests, humorously highlighting testing pitfalls. Finally, Code Hero, inspired by Guitar Hero and OSU, tackles copy-pasting from Stack Overflow. Players type pasted code letter-by-letter to a rhythm, using open-source beat maps for timing. A live demo with an audience member showcased the game’s difficulty, proving developers must “earn” their code. These games underscored IntelliJ’s potential for creative, code-integrated interactions.

Lessons and Future Hopes

Alexander concluded with reflections on IntelliJ’s plugin platform limitations, including poor documentation, lack of MP3 and PNG support, and cumbersome APIs for color and write actions. He urged JetBrains to improve these for better game development support, humorously suggesting GIF support for explosions. Emphasizing coding as a “superpower,” he encouraged developers to experiment without fear of “bad ideas,” as the dopamine hit of a working prototype is unmatched. A final demo hinted at running Doom in IntelliJ, leaving the audience to ponder its feasibility. Alexander’s talk, blending technical ingenuity with fun, inspired attendees to explore unconventional uses of their tools.

Links: