It’s been ages since i’ve update the blog and for good reason. Between the contract work and the 3 other projects I am working on things have been crazy here. The good news is that I am finally been able to take a semi vacation to Canada.
As it stands, i’ve have to shut down work on Wendy’s Weddings. Putting it on hold until I can find another artist. Me and my friend Jason though have started an iPad/tablet game called WarMongrel. Mechs and Big Guns. How can we go go wrong?
You can find more information on our facebook page: http://www.facebook.com/augmentwars
Right now we have a most of the Game Design done and we are building a gameplay prototype.
Now i’m not a Web developer by any stretch of the imagination, having worked mostly with PHP and doing stuff against the database. The last time I touched HTML proper it didn’t have style sheets and was simply a mark up language. I am strictly going to go about rating how ready HTML5 is by a game developers perspective. The other criteria is that is should be free (or free as beer at least).
With those conditions, the only engine which seem both actively developed and well…free was RenderEngine. It’s active and the sole author Brett Fattori knows what he’s doing. Unfortunately I wish the browser developers knew what they were doing. Chrome is currently the fastest HTML5 browser, FireFox is a good second. The new ‘fast rollout’ of browser tech is making it hard to pin down a target for HTML5. V2 of RenderEngine (which is still in development) works best with Chrome and breaks on Firefox 4.
So you development environment would be:
- FireFox with Fire-Bug (until you find a feature which breaks) then…
- You need to know some JQUERY to get anywhere. It was a bit confusing until did some JQUERY stuff then it was fairly easy.
With that said, HTML5 won’t be on my direct development pipeline for a while. Might spend some time on weekends playing with it but that its. You can follow my development of a HTML5 RPG editor(Adventure) @ http://www.bigbadrobots.com/adventure/adventure/editor/
It currently doesn’t do much but sit there..the tile engine running in the background (pretty sea;P)
This post is a follow up to my first one which gives you some concepts on working with networking. In this post, I will cover getting an a client/server connection going which is the first thing you have to do in building a multiplayer game. Your first point of reference is to make sure you are familiar with the Unity3D Network class which provide most the functionality you need to manage an initial network session.
I would like to cover some Unity3D specific topics on how networking is handled. Unity uses a Network View Component that is attached to every game object who’s state you want to synchronize with. It also allows you to send messages directly to those objects because each one is issued a network ID. The following picture should make things clearer:
Let’s also cover the ‘responsibilities’ in networking between the Client and Server.
- The Server’s primary responsibility is managing the network session and propagating/validating state changes to connecting clients. It is also responsible for control of non-player game objects(i.e. enemies) by creating them when needed, running the AI routines which tell them to move. There are 2 modes that the server can operate under, authoritative and non. Authoritative servers have more work because they have to validate state changes from the client rather than merely passing it along to other clients. This is usually a slower way to operate as each move, action needs to be checked. If found to be invalid then the client that sent this original state changes need to be ‘brought in line’ with the way the server is thinking. A non-authoritative server on the other hand is more of a delivery person who simply relies information over to connected clients
- The Client is responsible for the view of the world a player sees and for receiving input and forwarding it over to the server. In a non-authoritative mode, the client can also process game logic (i.e. decrease health, move the player, move other objects) and these are sent to the server to be relayed to the other clients.
The first step in getting a network session up and running is initialize a server, which should be done when a level in the game loads up. This is done using the method on the Network class called “IntializeServer“. The first parameter is the number of connections to take. The second the listening port for the server, which is used by the clients to determine which application to connect on the server (as a server may be running multiple network applications). The last parameter if Network Address Translation should be used or not. All these except for the number of connections should be eventually made user configurable when you are writing your game.
Once the server is running, clients can connect using the Network.Connect method. The most important parameters for now is the ip address of the server and the remote port(which was the listening port specified earlier when the server was initialized).
That’s pretty much all there is for setting up a session. Be sure to check the Network class for more information on how to handle disconnects and network failures.
Although an component system is the basis for most modern game engines and considered as the better(if not the best) way to put together a game. One of the biggest drawbacks is that when you create an architecture that is modular and loosely coupled, you introduce performance overheads.
On PC and other higher end devices, the tradeoff is smaller in exchange for elegancy of design and implementation. On the iPhone, especially older ones you have to to be care about how to implement things. The most common discussion on most game dev sites on the iphone is to watch your draw calls. On older 3G devices, 20-30 is a bandied around number…well that obviously and how many polys you are using plus if your code is running native or script…where is all this leading too….Ah yes the component system I was building on top of Cocos2D.
Here are some of potential performance overheads I ran into while implement it:
- One of design limitation you have to work on cocos2d uses a SpriteBatchNode to allow ‘sprites’ using the same texture to be drawn in a single draw. In a component system, everything is based around composition which means there is a lightweight ‘entity’ class with ‘components’ attached to it. So 1 entity = 1 draw call at the very minimum. With the older 3G devices, you are restricted to 25-30 draw calls (as a rule of thumb that is float on the Internet).
- Sharing of properties between components. While I have allowed the position property to be stored on the entity itself, other functionality specific properties aren’t. In order to do so you will have to either incur a dictionary look up (i.e. component foo = entity.lookupComponentByName(Bar)). Or you could directly link it up be assigning it to a pointer. Doing that however breaks a design principle of trying to make components loosely coupled for modularity
- Inter component communications. Besides directly looking up a component, a better way to talk to between components is to use ‘events’. For my component system, I built a addEventListerner,dispatchEventListener system similar to what Flash has. Like all events though everything is unidirectional and has a limited data payload of a single object.
In conclusion, I think for most of the newer games going with component system makes sense because once you get started you will be amazed at how everything clicks into place. If you are writing some more performance intensive, you will find components losing some of its appeal.
Components are being used in most modern game engines. My favorite (because of it makes sense to me is the PushButton Game Framework). I like the design behind it. So when faced with developing a game using Cocos2D, I tried figuring out how to approach it architecturally.
Cocos2D is a fairly mature framework and you might as why put something on top of that. I had the choice between choosing a Model View Controller Architecture and a Component (Composition Approach). I chose Components easily. I’ve only been working with the framework for a few days but I have already got that “wow” that makes more sense now feeling.
For example, here is some code to add a entity with a sprite renderer:
_entity = [[BBREntity node] retain]; BBRImageRenderComponent *renderComponent = [BBRImageRenderComponent node]; [renderComponent loadImageFromFile:@"test_image.png"]; [_entity addComponent:renderComponent name:@"Render"]; _entity.position = ccp(100,100); [self addChild:_entity];
And then here is how you add a touch component to it to make it do something when you click on it:
_entity = [[BBREntity node] retain]; _entity.name = @"Entity 1"; BBRImageRenderComponent *renderComponent = [BBRImageRenderComponent node]; [renderComponent loadImageFromFile:@"test_image.png"]; [_entity addComponent:renderComponent name:@"Render"]; BBRTouchEntityComponent *touch = [BBRTouchEntityComponent node]; [_entity addComponent:touch name:@"touch"]; _entity.position = ccp(100,100); [self addChild:_entity];
Simple huh. Each entity is added to the layer and that added to the scene. You can see the similarities to the PushButton Game Framework ;P
I have also implemented a way to add/remove/dispatch events inside of components plus a hash lookup system to manage entities.
Next on my list is to implement some audio components then I can start using it to build my game. Unfortunately no physics components yet because the game I am working on doesn’t need it.
This is my first posting after migrating from Lunarpages to Dreamhost. I have actually moved a while back but haven’t been able to get round to setting up the blog properly.
I’ve been busy working on our first iPhone game. It’s a little stuck right now and needs a good swift kick in the pants to get done. Our target is to have it out by Christmas. I’ve also been puttering around with developing a cross-mobile game engine currently called xPhone. Setting up the project and getting it on two targets (iPhone and Windows Mobile) is a lot of work.
I’ve also need to finish up our my technical workshop on Game Engines/Game Programming that I am teaching later this month.