I moved to a new URL! Check it out!

Dev Log: Jam Game Stuff

Dev Log: Jam Game Stuff
I've been doing pretty bad on blog posts this month so far, but I've been getting a lot of cool stuff done lately. I've been mostly focusing on my game jam game from a few weeks ago. I want to get that into a good playable state and do some testing at a local indie gathering and hopefully push it out to the public after that. This is another game that I'm making using my 2d .net framework Otter.

During the game jam I started to use the idea of components a lot more. The entity component system is the new hotness in video game programming as it seems many developers are starting to favor it over the old school hierarchy tree of classes. Here's a pretty good write up explaining how it works.

Image


So far all of my games depend very heavily on the whole class hierarchy tree. Like I would have a base Entity, and then maybe a game specific Actor which extends Entity. Then I would have a MovingObject which extends Actor, and then a PlatformerObject which extends MovingObject. Finally the player would be a class (like the momma from Offspring Fling) that extends PlatformerObject. It seemed like a good idea at the time!

Now with this jam game I'm working on I'm trying to use components as much as possible. It may be a little overkill, but I'm using this as a learning opportunity.

Image

For example here's what the Heart component looks like. I use the Heart for everything that can be involved in combat in some way, like anything that can take damage and all that stuff.

There's also something as simple as the RenderAllColliders component, which is handy for just slapping into an Entity if I want to see all of it's colliders during runtime. It will only render colliders on its parent Entity if the game is running in debug mode which is pretty neat.

So what does an Entity look like with all this component stuff? Here's a quick snippet from my main player class:
AddComponent(new CameraTarget());

// Add the movement and pass the axis from the controller.
var movement = new MovementTopdown(7, 0.3f);
movement.AxisMovement = c.Movement;

// Add the weapon, and pass it the shoot button from the controller.
var weapon = AddComponent(new AngelWeapon());
weapon.Button = c.Shoot;

var special = AddComponent(new Components.SpecialAttacks.Shotgun());
special.Button = c.Special;

AddComponent(movement);
AddComponent(new ClampInsideScene());
AddComponent(new SpriteEffects());
AddComponent(new RenderAllColliders());
AddComponent(new PushAway(2, Tag.Angel, Tag.Orb));

Later if I need to I can use GetComponent to retrieve any of those components if I need to change anything on them.

So far I'm really liking this approach, and it seems like it's the way things are heading in the video game programming world as far as I can see. I'm a little concerned with the performance of using a lot of components with GetComponent() running all the time, but it's probably not going to have that much of an effect.

Comments

Toth
Toth
Yeah, I'm still getting used to Components, trying to separate some small behaviors from hierarchy and putting then as components.

Last thing I did was a component that sorter the layer of the Entity, and other that automaticaly flips the graphic and controls facing and stuff.

I think this's a smart way of doing things, since I don't need to refactor parent classes to change little things and it's easy to reuse the code in other places.
Posted November 25th 2014 9:45 AM
Anonymous
Anonymous
I think a bit of the last sentence got deleted...
Posted November 25th 2014 4:47 PM
Kyle
Kyle
So it did! haha
Posted November 25th 2014 8:11 PM
Anonymous
Anonymous
Component based systems have been around for a very, very long time, several console generations old. I wouldn't call them the new hotness, I would say they have become more mainstream given the rise of the inexpensive engines (Unity, Unreal, etc.) that make use of components. That being said, it's definitely a great way to reuse code and get out of the OOP inheritance nightmare.
Posted December 3rd 2014 8:37 PM
Kyle
Kyle
Yeah, that's true. I think of them as the new hotness because I feel as if they are being pushed more as the thing to learn instead of learning the whole OOP inheritance thing (which is all I ever learned about when I was taking programming classes in school.)
Posted December 5th 2014 3:18 PM
new comment!

Post your comment!

Name
Email
Comment