I moved to a new URL! Check it out!

posts tagged with: gamedev

Dev Log: Anti-clumping Made Easy

Image


Starting to get back into a bit of a groove on this game thing. One little fun thing to work on was the enemy anti-clumping code. I don't want any enemies to stack on top of each other (although it would be smart of them to do so in order to conceal their numbers.) With a short bit of code I can have enemies push each other away, similar to how babies and rocks push away from each other in Offspring Fling.
public virtual void PushAway() {
if (Hitbox != null) {
if (Overlap(X, Y, (int)Tags.Enemy)) {
var e = Overlapped as Enemy;
if (e.Mass >= Mass) {
var push = new Vector2(X - Overlapped.X, Y - Overlapped.Y);

if (push.X == 0 && push.Y == 0) {
push = new Vector2(Rand.Float(-1, 1), Rand.Float(-1, 1));
}

push.Normalize(pushAwayForce);
pushAwaySpeed += push;
}
}
}

var length = Util.Approach((float)pushAwaySpeed.Length, 0, pushAwayForce * 0.5f);

pushAwaySpeed.Normalize(length);


X += (float)pushAwaySpeed.X * 0.01f;
Y += (float)pushAwaySpeed.Y * 0.01f;
}
Pretty neat! This is actually pretty similar to the original code in the prototype many many years ago, except now it's in fancy C# instead of GML. Enemies will call PushAway() every update.

Dev Log: Some Shaders

Dev Log: Some Shaders
One of the things I miss about working in FlashPunk and working with a bunch of bitmaps and blitting to the screen is the super easy color overlay blending. FlashPunk had an Image blending mode called Tint and it could be used in place of Multiply and it is amazing for doing effects like fading an entire sprite to a specific color. The world of rendering quads and triangles I don't have such a luxury, but I do have shaders.

I've been working on the building islands animation, and here's a really fast version of it:

Image


At the end of it when the island pops out it's silhouetted with solid white. The white fades to cyan, and also fades back to the normal art at the same time. To get this effect I used a simple shader to handle a color overlay.
uniform sampler2D texture;
uniform vec4 overlayColor;

void main() {
vec4 pixcol = texture2D(texture, gl_TexCoord[0].xy);
vec4 outcol = mix(pixcol, overlayColor, overlayColor.a);
outcol.a = pixcol.a;
gl_FragColor = outcol;
}
I also use this code for enemies as well. When they get hit they turn red for a brief moment. I use code in the C# end to determine the color and intensity of the overlay and pass it along to the shader.
var overlay = Util.ScaleClamp(Combatant.Stun, 0, Combatant.StunMax, 0, 1);
var color = new Color(1, 0.2f, 0.1f, overlay);

ImageSpineAnim.Shader.SetParameter("overlayColor", color);
Soon I'll probably make some sort of system that allows me to easily add a bunch of color overlays to the shader and automatically figure out the final color for the shader to use. I'll probably also use the shader for a bunch of different effects down the road.

Dev Log: Slow and Steady

Dev Log: Slow and Steady
I've been tinkering with a lot of systems over the past couple of days. Mostly stuff involving enemies, and some other things involving building islands and structures on the islands.

At some point last week I sat down and tried to figure out path finding with moderate success. I have something working, but it's pretty dang laggy when it has to figure out a path. As far as I know I'm just doing straight up A* path finding and I copied the psuedocode from Wikipedia right into the game. I started looking into using different data structures for storing things to hopefully speed it up, but honestly I still have no idea what I'm doing and I don't know how to use some of these fancy things that people suggest (priority heaps, or something?)

I took a break from that to tinker with placing structures on islands, and trying to figure out how I want to animate the building process for building a structure on an island. This is also a tough one to solve, and I'm not sure if frame by frame stuff in Flash would be good, or if structures should be animated with skeletons similar to the enemies using Spine.

Image


Back in the world of enemies I've started experimenting with behavior trees for how they should interact with the world. It seems like a good way to do things, but part of me feels like it's over-engineering. Setting up a whole series of classes for the system to run the behaviors, and then every simple little task then has to be a behavior command... I kind of like systems like this, but I wonder if it will be worth it in the end working on a system that takes a lot of up-front work to get running.

It's definitely a very different way of doing things outside of the game jam environment. I've made a lot of cool stuff in game jams, but it's all been on top of really odd code that doesn't leave a lot of room for expansion. I'm trying not to design or code myself into a corner when it comes to working on this new game, so things are going a little slower than they did for Offspring Fling, but it's also probably due to the fact that I'm in pretty unfamiliar territory. Working on something that's not a platformer can be pretty tough!

Dev Log: Workin' Away

Dev Log: Workin' Away
I've been pretty heads down on my game project for the past couple of days. I've managed to fix a few bugs in Otter as well, but I'm putting a hold on any official updates due to issues with the Spine license that I'm pretty sad about.

The Spine license only allows people with a full copy of Spine to download and use the official Spine runtimes. I didn't know this at the time when I created a simple Spine graphic type for Otter. The situation I'm in now is trying to figure out how to easily provide that Spine graphic type for people using Otter, but also separate it from Otter so that I can distribute it only to people that have the Spine license... argh.

In the wild world of my new game, I've been just working on some art related tasks. I've been jumping all over the place and working on totally different things on each day, but that ends up working out because it keeps things fresh and interesting.

That's all for now! Things are going to be pretty hectic for me in the next 2 or 3 weeks, as GDC is fast approaching and I'm also going to be traveling a little bit before then. If you're going to GDC, we should hang out and get sushi!

Dev Log: More Explosions

Image


Been having a lot of fun with my workflow of animating in Flash, exporting to a SWF, and then using ShoeBox to convert to a sprite sheet. There are some hiccups in the pipeline still, but hopefully I can get them ironed out before I get any deeper in the art department.

I should really be working on the actual game part of this game, and probably all the systems that are going to be needed to be intertwined, but at this point I'm having way too much fun with particles. I've been bound by the word of Flash and ActionScript 3 for so long. Having 30 particles on the screen in Offspring Fling was a nightmare for performance, but now in the land of SFML, C#, and Otter, I can spawn hundreds of particles and the game doesn't hitch at all -- not even in debug mode!

Dev Log: Explosions

Image


Been working on getting some particle effects going lately. At first I was trying out a workflow of animating in Graphics Gale since it's so easy to use for animating pixel art. The entire process was animating in Graphics Gale, upscaling in Image Resizer using an HQ 4x filter, then downscaling it and cleaning it up in Photoshop. Although this yielded some pretty decent results, the actual pipeline of getting it into the game from Graphics Gale was becoming a huge pain. Here's a sprite from this process:

Image


I did give Flash a try before this, and all I could find was this tutorial on how to export to a sprite sheet. I had a lot of issues with this process. First the entire SWF document couldn't be exported, only a symbol. Second is the fact that you pretty much have no control over the pixel size of a symbol, and therefore the size of the export. Thirdly the export to sprite sheet just didn't have enough options for my needs. This is why I passed on Flash initially.

Then I discovered that you can just export an entire swf has a .png sequence. Hooray! I can export a bunch of images of an animation, and since I can define the size of the swf, I can define the size of the png exports. Now all I need to do is somehow turn it into a sprite sheet.

That's where Shoebox comes in. This program is an Adobe AIR application that is sort of a swiss army knife for 2d game development. One of the features that I'm using in my current process is the frame sheet builder.

At first I was using the frame sheet builder with a sequence of png files, but then I discovered you can just use an exported swf file instead. So after all of that, my current pipeline for animating frame by frame stuff is Flash, export to SWF, use Shoebox to convert it into a sprite sheet, and then import it into the game. It's not a terrible workflow at all, but sometimes using Flash is a little infuriating.