A presentation on opportunities of Ruby in the Game Development industry, including building games in Ruby, building game engines with Ruby, and using Ruby as a Scripting Languages for non-ruby Game Engines. Presented at RubyConf 2012.
UnrealRb Problems • Poor Performance • Interfacing Bugs with UDK • Still bound by UnrealScript structure • Devolved into primitive DSL Saturday, November 3, 12
Anatomy of a Game with Gosu • Create subclass of Gosu::Window • Create ONE instance of this subclass • Subclass implements 3 Methods Saturday, November 3, 12
Game State Manager • Contains Game Logic • Contains UI Elements • Contains Events / Input Handler • Relays Information to Game Loop Saturday, November 3, 12
Resource Manager Game State Manager Primary Game Loop Game State Game Logic Rendering Input Handling Game State Game Logic Rendering Input Handling Game State Game Logic Rendering Input Handling Saturday, November 3, 12
Gamebox Structure • Gosu::Window becomes a Stage • Entities are represented as Actor objects • Game States are represented as Scenes • StageManager coordinates Scenes • Stagehands micromanage for Stage Manager Saturday, November 3, 12
Game Libraries • Great starting point for Developers • Boilerplate is quickly due to complexity • Requires not overly performant Saturday, November 3, 12
Building Ruby Games with Engines Game Libraries are Game Engines with minimal component implementation Game Engines allow game developers to focus on game-specific logic, not low-level internals Saturday, November 3, 12
Breakout Tech • GameContainer vs Game • Input Handler is part of GameContainer • Direct Access to Renderer Object • Direct Access to GameContainer • Implicit Window context for Images More Exposure to Engine Internals Saturday, November 3, 12
Building Game Engines with Ruby • Full-featured Game Component Library • Handles non-game-specific work • Provides hooks for game code What is a Game Engine? Saturday, November 3, 12
Components of a Game Engine Engine Setup Game Loop Game States Input Handler Resource Manager Rendering Physics Networking Sound System Scripting System Entities Hardware Saturday, November 3, 12
Concurrency Certain components need to be non-blocking. Without a proper concurrency system, bad things like the networking blocking the renderer, or the renderer blocking input handling will occur. Saturday, November 3, 12
Cross-Platform Support with Ruby • Great Linux/OSX support • Mediocre Windows Support • Lots of gotchas spread across core/stdlib • JRuby/JVM helps mitigate these issues Saturday, November 3, 12
Memory Management MRI 1.9 GC is not well optimized for long-running processes and rapid object creation/deletion JRuby has great tools for performance tuning the runtime and GC Saturday, November 3, 12
Ruby as a Scripting Language Using Ruby as the high-level scripting language provides the benefits of Ruby while allowing other languages to handle the lower-level mechanics. Saturday, November 3, 12
Benefits • DSL Creation • Ruby Features • Easy for Game Modders • Code Obfuscation no longer a concern • Logic Mixins, Game State Injections, etc Saturday, November 3, 12
mruby • Lightweight Footprint (~500K) • Alternative to Lua • Embeddable Implementation • Subset of Ruby Implementation • Easily bridged to C/C++ • No assumption of an OS Saturday, November 3, 12