Re-Doing a Boss (Part 2)

Aaaand we’re back — with our big ol’ sprite sheet, ready to be turned into a boss!

The boss separated into a sprite sheet.
The boss separated into a sprite sheet.

But let’s rewind for a second first. Before I designed the boss’s visuals or made up the sprite sheet, I filled a page or two with brainstorming about all the ways the boss could attack. Here’s that:

You can click on it for the full image if you want to see all my dumb notes.

Knowing how the boss attacks helps me design the visuals, but it also helps me design the boss in code. Once I know what the boss’s attacks are, I can look for common elements between them and find the most simple, logical way to code them.

When it’s time to code game elements, I start with what I call an ‘Entity’ — the most basic form of object in Bleed 2. It’s got a few simple properties like a width, a height, a weight, and so on.

Some examples of Entities.

Every object in Bleed 2 — whether it’s a bullet or the player or a boss or WHATEVER — is built using an Entity as its base. In this case, the Segment Slider is actually composed of several types of Entities:

-Segment Slider: The actual boss in code. It manages all the other Entities, runs the boss’s AI, and draws the background of the Segment Slider. You can’t interact with it directly but you can hurt it by damaging the Weak Point.
-Segment: Represents a single segment belonging to the Slider. It can perform very basic commands, like sliding across the boss arena, or executing a reflectable attack.
-Gun Segment: A more specific kind of segment, used for the top and bottom segments on the Slider. It’s the same as a Segment but has a cannon that can be rotated and fired.
-Weak Point: The Slider’s weak point. It mostly exists to take damage for the Slider.

As I mentioned before, all Entities have a width and height, which describes the size of their hitboxes. Most of the objects here are rectangular so setting them up is easy, but sometimes it’s more complicated. For example, the Segments have a small additional hitbox on their end-points.

When you set an Entity’s width or height, it automatically calculates a circle that encompasses that Entity’s hitbox. Among other things, that circle is used to detect parries — the circle being much more useful than a box in most cases. The Segment’s long shape results in a large circle that’s unfit for detecting parries, so the smaller hitbox is placed there to help out.

Then I start coding the objects. I start small — I like to get them visually in-place and drawing correctly first (seems like a good starting point, right?) Then I work my way up — coding the Weak Point to pass damage back to the Slider, coding the simple commands of the Segments, testing them out constantly as I go.

Testing the simple behaviours of the Segments.

Once that’s all working, I use the various elements I’ve got as building blocks to create the Segment Slider’s attack patterns. It’s basically describing each behaviour, almost like a step-by-step list of instructions or a recipe! Like, literally: Pick three random segments. Make the segments glow for 600 milliseconds to warn the player. Tell the segments to fire out. Wait until the segments have returned. Choose a new attack. Etc.

Bosses in Bleed 2 typically perform an idle behaviour and then follow up with one of several attacks, but the Segment Slider is a little more complicated. Previously it had no idle state — it just performed attack after attack (‘attack’ in this case meaning ‘move from one side of the arena to the other in some fashion’.)

I’ve changed it to have two different classes of behaviour now. All the previous methods of moving across the screen are categorized as ‘moves’. I’ve added new attack behaviours and labeled them as ‘attacks’. The Slider randomly selects one of the ‘move’ behaviours and then follows it up with an ‘attack’ behaviour.

Further, all the ‘moves’ begin and end the same way, so I’ve separated the beginning and ending of a ‘move’ into their own behaviours, too. That makes it a lot easier on me if I want to change how the ‘moves’ work in the future, since instead of changing the beginning and ending of three ‘move’ behaviours and trying to keep them consistent, I’ll just change them the once.

As for the attacks themselves, the Segment Slider is a lot more threatening now. It can sweep the arena with gunfire:

It performs powerful reflectable attacks:

It can even fire while performing a move, in a few different ways!

It’s a little much, though… I’ll save those combo behaviours for the highest difficulties if I use them.

Some fun facts:

Every boss knows the size of the boss arena it’s fighting in, and I try to code everything in terms of percentages of the boss arena when applicable. Like, instead of “lunge forward 500 units” I say “lunge forward until you’re 40% of the way into the boss arena”. Obviously the Segment Slider only works in an arena of a specific size, but it allows most bosses to be fought in arenas of any size, which will help make things like Challenge mode and Endless mode easier to code (if implemented.)

Every boss also maintains a list of the attacks it’s used in the past. The list helps detect if it’s overusing one attack so it can keep the fight varied.

That’s about all I can think to write, and I’m sure you’ve read quite enough by this point! Hope you enjoyed it and had a good Valentine’s Day!