This is The Mechanic, where Alex Wiltshire invites developers to discuss the inner workings of their games. This time, Enter the Gungeon [official site].

Enter the Gungeon’s conception was an idle conversation about what shape a game called Enter the Gungeon would take. And here’s what it led to:

1. It’s a dungeon-crawler in which you shoot guns.

2. You’re entering the Gungeon to find a gun so powerful it can kill the past.

3. Every enemy is a bullet.

4. The enemy bullets shoot bullets.

Great gouts of bullets. Bullets which radiate and fan out like flowers across the screen. Because if you’re going to make a game about guns, it kind of makes sense that it would feature:

THE MECHANIC: Bullet hell

Not that traditional shmup-style bullet hell is necessarily a logical fit for a dungeon-crawler. The inspiration came from a source the many shmup fans will bristle at: Ikaruga. Ikaruga isn’t a purebred bullet hell game, but lead developer Dave Crooks loved its core mechanic of switching colours, which gives your ship immunity to bullets of the same colour. It seemed to chime with his other love for Dark Souls, particularly its dodge roll and the frames of invincibility it grants (a love so deep he named his studio after it). So Gungeon became a game in which you dance through dense patterns of bullets.

Incorporating bullet hell patterns in a 2D action dungeon-crawler wasn’t simple. The first prototype took a straightforward and perhaps obvious approach, with enemies constantly pointing a gun at the player, and its muzzle was the spawn point of its bullets. The game then had control over the number of bullets, their angle and frequency, and random delays between the patterns. But while it might sound like all you need to create bullet hell, it didn’t nearly provide the variety and interest of patterns Crooks and his team at Dodge Roll wanted.

“I was playing all these bullet hell games and watching videos and I was thinking there had to be a system in there,” Crooks tells me. “People have pioneered this stuff so we should follow in their footsteps.” Turns out there was a system, and people had indeed pioneered it: namely, Kenta Cho, legendary doujin shmup maker behind Noiz2sa, Gunroar and Tumiki Fighters. He’d made an open source bullet scripting system called BulletML, which gave control over the spawning of bullets.

Crooks and his team began to incorporate BulletML into their game, but soon found even that wasn’t enough. It couldn’t encompass the growing range of enemies and items Dodge Roll was coming up with and simply wasn’t designed for the fundamental difference between the open scrolling field of a standard shmup and the freely explorable 2D space of a dungeon crawler.

For example, they’d designed a boss called the Kill Pillars, which rises and then slams down, creating spokes of bullets that spin around the centre of its impact and rings of bullets that radiate out from it, causing you to have to dodge roll through them. None of the bullets have what Crooks calls singular velocity – they’re all on different arcs and moving at different speeds – and he says that the game also has to wipe some of them off the screen in certain cases to prevent the player getting stuck in a sea of bullets they can’t avoid.

“What that meant is that the bullets have to be smart,” he says. “They don’t just have to know where they are and should be going, they need to know where the player is in the room, where the other bullets are, and to be able to have complex movement that’s not just based on speed and acceleration, but also game rules.” Gameplay programmer Dave Rubel was having to spend so long extending BulletML to fit Gungeon’s weird shape that he began making his own version, RubelML. And as it came together, the team finally started to be able to achieve what they wanted with bullets.

The challenge wasn’t purely about making nice patterns. Much more subtle control was necessary for designs like the Lore Gunjurer, which sets down a book and out from it emerges one of three bullets: a warrior, rogue and mage. The rogue appears suddenly behind you and strikes very fast so you have to roll away. There’s also the Revolvenant, which has a special attack which involves it reaching its arms around the player in a circle and slowly contracts them until, at just the right moment, the player dodges it. The problem with both these enemies was that they’re so demanding on player attention they simply aren’t fun if there are other enemies to deal with at the same time. RubelML enabled them to only use these attacks when there are no other enemies around.

The patterns themselves emerged in various ways. Some were initially visually designed to make the player go, as Crooks says, “‘Oh shit! This is a real moment!’ This boss feels weighty, feels like a Metal Gear boss, you know? Then we tightened it and tightened it so it had that balance of pressure and fun, and make sure it’s not cheeseable.” Other patterns were about filling in holes, adding specific kinds of pressure to encourage the player to move more or perform certain actions. Still others emerged from the enemy character design and what seems like it’d naturally do, or just the wish to be ridiculous, such as Ammoconda, the snake boss which fires bullet patterns that play Snake with themselves.

The next challenge was presenting the bullets to players. From the first prototype to release, they’ve doubled in size twice and been made so bright you can’t miss them. From playing, you might have a memory of them being red, but as Crooks says, “They’re really 90% white and a very dark red halos and a second ring of darker red, almost black, around that, which is pretty much invisible because the bullets move so fast.” Dungeon floors are almost uniformly very dark so they show up (a level set in heaven was scrapped because bullets simply didn’t read well enough against it). Then two layers of lighting are applied to them, one of them Unity’s own and the other entirely custom, adding a stylistic contrast to the rest of the visual design on top of everything else.

Like any bullet hell game, the actual collision box for bullets is smaller than their visual size, but it follows an important rule Crooks imposed on the game, which was for it to feature “minimal bullshit”. Every impact must be explicit and feel fair. (Incidentally, other rules were: “Everything must animate, everything must have a reaction and everything must have a face”.)

The solution to collisions of minimal bullshit was being pixel perfect, and even here, Dodge Roll faced creative questions. As a modern game built in Unity, it runs at your screen’s resolution. But as a pixel game, what you see adheres to a much coarser scale, and the game uses each as appropriate. “We call it macro pixels and micro pixels. Micro is a screen pixel, while a macro pixel is a block of colour. All our collision system is pixel-perfect and tuned so it feels like an arcade game, so it feels like bullets absolutely connect, and nothing overlaps anything unless we say it’s OK.” The player’s collider is a macro pixel inside its art, and the bullet’s is two macro pixels inside its art. So when you’re hit it should look like three pixels are overlapping, a clear and evident indicator.

Then came the tuning of encounters, and combinations of enemies often introduced unforeseen interactions. “We were encountering this problem where we were designing enemies with cool patterns which would fill the room with bullets,” says Crooks. “But if you kill the enemy right away the danger is zero, and if you put two in the room it’s completely impossible.” The solution to designing around this, which informed all Gungeon’s encounter design, was to have an easier enemy that the player would see first, presenting a distraction which would allow the harder one to spool up its attack.

Similarly, enemies will stagger the timing of their attacks to prevent, in Crooks’ words, “That perfect fuck-you moment where you dodge the first one but as you come out of it you get clipped in the back.” The approach suited boss attack patterns, too: when an attack felt unfair or just wrong, it was rarely a case of cutting it, instead it was about ensuring attack B didn’t come directly after attack A, so its bullets had a chance to exit the screen.

Still, it was Crooks’ aim to make Gungeon a hard game, one that’s pitched just above what he personally feels is comfortable, but he says that there’s a point where the mechanics break down with the speed and sheer overwhelmingness. “I like to use the world pressure, that put pressure on the player without it feeling like you’re overwhelmed or totally held down and punched in the face. Lots of thought into making everything readable and feel fair and if you do get hit, it looks like it and you understand why. I feel we’ve done a good job of that, maybe even a very good job. Obviously, there are fans who will say that there are definitely still some bits of bullshit left in the game, but we tried our best to minimise that shit. We really really care about it.”