Wednesday, February 29, 2012

Coming in to Port, the C# way

So the past couple of days I have been looking in to C# as a programming language. I was amazed at how similar it is to C++, and still how much easier it is to use. I decided that C# would be a better suit for the game engine that I am building right now. It will also help me get to know C# very well, and will be a great learning experience.

So for the past couple of days I have ported my Component-Context code over to C#, with great results. I C++, I had many problems with including headers from other classes. In C++, the order in which the compiler finds the declared classes allows you to use those class in defining others. This was a big problem because many of my engine classes depended on each other. I had to resort to using prototyping, which I think is ugly. In C#, this order does not matter, making cross-dependency much cleaner and easier.

However, C# is much less flexible in terms of templates (or Generics as C# calls them). This made me rethink my structure for managing the components and contexts. This restructuring was good, and made the structure much more powerful. When you attach a component onto an entity, the component itself is responsible for registering itself with the respective Context. This gives it more flexibly, while simple as well.

So far I have been very pleased with C# flexibility and power. Along with Mono, I am able to keep an openness for different platforms. I also find MonoDevelop a very well designed IDE for C#.

Monday, February 13, 2012

A Quick Update

Hey Everyone, these past couple of weeks have been a little slow in terms of development of my 2D engine. However, I have made so notable progress. This Component-Context solution is working out wonderfully. It is easily expandable, and easy to use. I have added in the ability to use text and images in my engine. Take a look:

Recently I have also been researching Behavior Trees. Expect a post on those soon...

Thursday, February 2, 2012

First Look

This week I have made good progress on my game engine. Last post I was working on the base of my component system. I have finished that up and made some other minor modifications. So far my game engine has three contexts, graphics, selector, and events. The graphics context takes care of everything drawn to the screen. The events contexts handles messages from the system to entities, and in between entities. The selector context allows me to define regions that are "selectable" to see if the user has click in a specific region.

So far this concept of Context-Component structure is going very well. It gives the flexibility, simplicity, and power that I need. Here is an example of creating an entity:


Entity* entitiy = createEntity("BOX",Transform(Vector2(0,0)) );
entity->attachComponent(new BoxSelector(150, 150));
entity->attachComponent(new SquareShape(150));

This will simply create a box in the middle of the screen 300 pixels wide, that when the user clicks on it, an event will be fired.

In order to test my game engine, I figured that it was time to make an actual game. I less than a day, I was able to make a simple Tic Tac Toe clone, called CircleSquare:


You can download the program here