At day you have to wrangle with legacy code, fix bugs, struggle with APIs, deploy services and integrate things. Yet you wish you could create worlds, animate dragons, break laws of physics and design artificial intelligence. You can.
AI Reading Assistant
Whole-book reading guide from stratified index samples; jump to passages in the text
Tip the Site
Support this siteYour recognition and a small knowledge-service contribution help keep this technical work open source.Scan the WeChat Pay or Alipay code below. Logged-in and guest visitors can both tip.
WeChat Pay
Alipay
Open WeChat or Alipay and scan. No login required.
AI guide
# Developing Games With Ruby: For Those Who Write Code for Living
## 【One-Line Pitch】
A practical, project-based guide that shows working programmers how to build a complete 2D tank game in Ruby using the Gosu library, proving that game development is accessible even with a "slow" dynamic language. Perfect for developers who want a creative weekend project that exercises real software engineering skills.
## 【Book Arc】
- **Opening (~0%–10%)**: Makes the case for Ruby game development, acknowledging that C++ or Unity are "better" choices but arguing that Ruby's elegance and productivity matter more for small 2D games. Sets up the toolchain and walks through first Gosu programs—hello world, keyboard movement, and sprite animation.
- **Early (~10%–23%)**: Covers core Gosu mechanics: the update/draw loop, event handling, sound and music, tile-based maps (both hand-crafted Tiled maps and procedurally generated Perlin noise maps), and the crucial distinction between world coordinates, viewport coordinates, and screen coordinates.
- **Early-to-Middle (~23%–39%)**: Introduces proper game architecture with the State pattern for menu/play states, a Camera system for scrolling and zooming, and the first game entities—Map, Tank, Bullet, and Explosion. The tank prototype becomes playable with 8-directional movement and shooting mechanics.
- **Middle (~39%–48%)**: Shifts to performance engineering. Profiling reveals bottlenecks in camera view-checking and window caption updates. Introduces optimization techniques: short-circuiting expensive checks, frame skipping for slow update rates, and adaptive cursor display when framerate drops.
- **Late (~48%–end)**: Refactors the monolithic prototype using the Component pattern, decoupling concerns like rendering, physics, and input. Adds enemy AI with finite state machines, collision detection with bounding boxes, health/damage systems, and gameplay polish (radar, respawning, sound panning, camera look-ahead).
## 【Key Takeaways】
- **Ruby is a legitimate game development choice for small 2D games** (Early): The author openly admits a friend said "there's little reason to develop a desktop game with Ruby"—and agrees—but argues that for simple 2D games, programmer happiness and productivity outweigh raw performance. This sets realistic expectations from the start.
- **The update/draw separation is the heart of Gosu games** (Early): `update` should only advance object state, while `draw` should be as lightweight as possible. The order of these calls is unpredictable, so time (via `Gosu.milliseconds`) is the only reliable reference. This rule prevents common frame-rate bugs.
- **Coordinate systems matter even in 2D** (Early): The book clearly distinguishes world coordinates (the game map), viewport coordinates (what the camera sees), and screen coordinates (the display). Implementing a "camera man" that follows action and zooms requires basic math but pays off in game feel.
- **Procedural generation is achievable with Perlin noise** (Early): Rather than hand-crafting every map, the book shows how to use the Perlin noise algorithm to generate natural-looking terrain with water, sand, and grass tiles. Applying cubic contrast sharpens the result—without it, maps look like "a boring golf course."
- **Profile before optimizing** (Middle): Initial profiling shows `Camera#viewport` and `Camera#can_view?` as top CPU burners. The author tests hypotheses by short-circuiting methods, discovering that checking visibility was slower than just drawing off-screen. Even the window caption update consumes 1/3 of CPU cycles—low-hanging fruit worth picking.
- **Frame skipping prevents unrealistic slow-motion at low FPS** (Middle): When framerates drop, animations like explosions appear frame-by-frame and seem too slow. The solution is to advance animation frames based on elapsed time rather than per-render, so effects stay consistent regardless of performance.
- **Component pattern keeps game objects maintainable** (Late): The monolithic Tank and Explosion classes violate single responsibility—they load graphics, handle rendering, animation, and sound. Splitting into components with a shared `GameObject` base class makes each piece testable and reusable, a lesson that transfers directly to day-job code.
## 【Reading Tips】
- **Skim the opening rationale** (~0–3%): The "Why Ruby?" discussion is motivational but not technical. If you're already convinced, jump to the first code example.
- **Deep-read the coordinate system chapter** (~23%): This is the conceptual foundation for everything that follows. Understanding world/viewport/screen coordinates will save you hours of debugging later.
- **Study the profiling section carefully** (~39–48%): The author demonstrates a real optimization workflow—measure, hypothesize, test, verify. This is the most transferable skill for your day job, even if you never write another game.
- **Don't skip the refactoring chapter** (~48%+): The Component pattern refactor shows how to restructure working-but-messy code into something maintainable. This mirrors real-world legacy code scenarios.
- **Expect some rough edges**: The book is honest about its scope—this is a prototype, not a polished commercial game. The Tiled map JSON excerpts are dense; skim them and focus on the Ruby logic.
## 【Coverage Limits】
This guide covers the book's progression from first Gosu programs through performance optimization and architectural refactoring. The excerpts do not cover the final AI implementation details, collision detection specifics, or the complete gameplay polish chapters in depth.
##
Page 7
elop a desktop game with Ruby”, and he was absolutely right. Perhaps this is the reason why there are no books about it. All the casual game action happens i...
around, and each bullet will eventually cause an Explosion. Having all that taken care of, PlayState should look pretty simple: 03-prototype/states/play_stat...
let ourselves leave this low hanging fruit remain unpicked. We will update the caption once per second, it should remove the bottleneck: class PlayState < Ga...
. Visual representation of quadtree Implementing A Quadtree There are some implementations of quadtree available for Ruby - rquad, rubyquadtree and rubyquad,...
Support this siteYour recognition and a small knowledge-service contribution help keep this technical work open source.
Scan the WeChat Pay or Alipay code below. Logged-in and guest visitors can both tip.
WeChat PayAlipay
Open WeChat or Alipay and scan. No login required.
Add Tag
Enter tag name (max 50 characters)
Share E-Book
Developing Games With Ruby For those who write code for living (Tomas Varaneckas)(Z-Library)
Scan QR code with your phone to access
Copy the link or scan the QR code to access this e-book on your phone
Share to WeChat Moments
Developing Games With Ruby For those who write code for living (Tomas Varaneckas)(Z-Library)
Scan the QR code with WeChat to open this book
Tap the ··· menu in the top-right corner
Choose Share to Moments
You are already in WeChat. Tap ··· in the top-right corner and choose Share to Moments.
Share E-Book via Email
Please enter email address
Donation Statistics
¥.00
Total Donations
0
Donation Count
Developing Games With Ruby For those who write code for living (Tomas Varaneckas)(Z-Library)
Find Your Favorite Books
Only registered users can comment after logging in. Comments need to be reviewed by administrators before being displayed
Loading comments...
Reply to Comment
Edit Comment