Prototyping a beam energy weapon

At some point over this summer, I decided that having one type of projectile weapon was plenty, and to forego a missile, ice missile, super poison missile, and so on. Instead, I have been slowly coming up with a solid idea for a beam weapon to collect, rather than a boring missile. Unlike the missile, this weapon travels instantaneously, stays on as long as you hold the button down, does great damage, and can go through multiple enemies if they’re in a line. Here’s my first attempt at prototyping it:

Feels pretty good, so far! My feeling is that, because of its high damage and instantaneous nature, you’re going to want to use this thing all the time. However! Every frame it’s active it uses energy, which is somewhat limited. To start, you’re only going to have a few seconds’ worth of energy, which you will have to ration in short bursts for it to be effective. Players will need to explore the game world to find more power packs to extend the time they can fire it continuously.

Further upgrades will enable you to widen the beam to make it a more concentrated burst of power. I want to eventually implement shadowing, where the landscape cuts off parts of the beam, but that’s a little ambitious for today.

Also eventually, I would love to implement this effect using a post-processing shader, but that is trickier than what I’m doing now. The best way I found of simply achieving this effect is to have a small image that you stretch into the length of the beam. If the beam image varied much along its length this would look wonky, but for my solid bar of white it’s just fine.

Vector2 displayPosition = ConvertUnits.ToDisplayUnits(_start);
Vector2 origin = new Vector2(0, ImageHeight / 2);
float unitLegth = ConvertUnits.ToSimUnits(ImageWidth);
float lengthRatio = (_end - _start).Length() / unitLegth;

spriteBatch.Draw(_image, displayPosition, null, Color.White,
    GetSpriteRotation(_direction), origin, new Vector2(lengthRatio, 1.0f),
    SpriteEffects.None, 1.0f);

Probably the most interesting thing about this new weapon, from a design perspective, is that there are lots of potential lock-and-key dynamics it could be used for. For example: a door that needs a continuous beam of energy for a certain time period before opening. Or blocks that slowly burn through when hit with the beam. Or a sensor that closes itself up when it hears gunfire. I’m sure I’ll come up with many more ideas before I’m done.

Leave a Reply

Your email address will not be published. Required fields are marked *