Introducing the Game Scientific Framework

October 2, 2008

I’ve been interested in hobby game development for quite some time but I’ve never got much traction on it. It’s hard to form a team of hobbyists online, and doing it yourself is a daunting task what with graphics, sound, music, AI, etc.

For now I’m going to content myself with working on a game framework rather than an actual game.

The Game Scientific Framework (GSF) is a component based framework for games written in ActionScript 3.0. Component (or Entity) frameworks allow for a lot of flexibility and extensibility. My plan is to write all the core components needed for the most basic 2D games, with some more advanced components for platform games (my favorite kind!).

A component based game consists of a collection of entities to which components are added. Examples of components might be: AnimatedSprite, BoxCollision, AStarPathfinding, KeyboardControlled etc. The player, enemies, triggers, terrain, items etc. are all entities. By using a common library of components to build up your entities, you make it easy to create new entities, and to involve a designer in your process who doesn’t know anything about programming.

As I write this, I’m working on making the framework writable in MXML, the markup language that Flex uses, but that may not stick ;-). Here’s what it looks like so far:


<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
     xmlns:core="com.gx.core.*"
     xmlns:comp="com.gx.components.*"
     xmlns:phys="com.gx.components.motor2.*">
     <core:Game >
          <core:Scene>
               <core:layers>
                    <comp:BitmapLayer id="surfaces" />
                    <comp:BitmapLayer id="actors" />
                    <comp:PhysicsLayer id="physics" />
               </core:layers>
               <core:entities>
                    <comp:StaticSprite id="alucard" layer="{actors}"
                         bitmap="@Embed(source='/assets/player.png')"
                         clip="{new Rectangle(10,15,23,47)}"
                         position="{new Point(100,10)}">
                         <phys:BoxCollisionMotor2 autoSize="true" />
                    </comp:StaticSprite>
                    <comp:TileMap id="platform"
                         bitmap="@Embed(source='/assets/tilemap.png')"
                         tileWidth="16" tileHeight="16"
                         position="{new Point(100,167)}">
                         <comp:tiles>
                              [
                                   [new Point(1,8), new Point(4,7), new Point(5,7), new Point(4,7), new Point(5,7), new Point(4,7), new Point(5,7), new Point(4,7), new Point(5,7), new Point(4,7), new Point(5,7), new Point(12,8)],
                                   [new Point(1,9), new Point(4,7), new Point(5,7), new Point(4,7), new Point(5,7), new Point(4,7), new Point(5,7), new Point(4,7), new Point(5,7), new Point(4,7), new Point(5,7), new Point(12,9)],
                                   [new Point(1,9), new Point(4,7), new Point(5,7), new Point(4,7), new Point(5,7), new Point(4,7), new Point(5,7), new Point(4,7), new Point(5,7), new Point(4,7), new Point(5,7), new Point(12,9)],
                                   [new Point(1,11), new Point(1,11), new Point(1,11), new Point(1,11), new Point(1,11), new Point(1,11), new Point(1,11), new Point(1,11), new Point(1,11), new Point(1,11), new Point(1,11), new Point(1,11), ]
                              ];
                         </comp:tiles>
                         <phys:BoxCollisionMotor2 autoSize="true" />
                    </comp:TileMap>
               </core:entities>
          </core:Scene>
     </core:Game>
</mx:Application>

This creates a very simple scene with a static(non-animated) sprite and a platform. The static sprite falls toward the platform and stops when it hits the platform.

So far I’m using motor2 for physics and collisions. I’m looking at the TorqueX APIs a lot as well, since that is a very well done component framework.

For more info on component or entity frameworks see this excellent post: Evolve Your Hierarchy.

I’ll be opening up a google code project for this framework soon, so stay tuned!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: