22. November 2010 22:13
Work in progress for a new game: Planetos, based on the classic Crazy Comets. [More]
2. March 2010 22:45
For most of my games, I have created a level editor. I usually create a Silverlight page, at the top I edit the levels and at the bottom I embed the game to test the level. This way it’s very easy to test your game for bugs, and to test whether a level is actually playable. How a level editor works, depends on the game you are creating. For “Mineral”, I created a different level editor than I did for “Avios”. The Avios editor clearly is much more complex than the Mineral editor. However, some things are basically the same. I’m creating a new game, let’s take the reader along the path. The game I’m creating is called “Slengo”, highly inspired by the game “Pengo”. So the basics of a level is clear, it is a two-dimensional grid, like Mineral, and everything happens in there.
After creating a solution and a Silverlight application (Slengo.App), with ASP.Net Web Application Project (Slengo.Web), we can add our own things. Highly inspired by the SOA-model programming, I usually split things up top-down. The Silverlight application itself does not contain much code, everything is done in the Silverlight libraries.
The way of creating a level editor, is the same way I did for my first game “Tilez”. The editor is a Silverlight page, which reads all levels from the webserver when started. If I press the button “save” in the editor, I want to save the level I am currently editing. When I close the application and start it tomorrow, I want to see all levels I’ve saved before. Those are my basic requirements.
The image shows the basic setup. In the project “Slengo.Visuals”, I will put all my sprites, all my basic visual things. Currently the project has one usercontrol, “IceCubeBlue”. This control displays an IceCube, which is a level building block. Note the name of this usercontrol, I will create a “IceCubeRed” in future, or another item if I want to. An icecube acts like a wall, and where there is no icecube, there is a path for player and enemies to walk.
The project “Slengo.Web” has a webservice called “Levels.svc”. You create this by selecting the project, Add new item and under the Silverlight templates, you’ll find the Silverlight-enabled WCF service. Currently this service is empty.
Next is to focus on your level data-model. The data-model is created on the server, not in the Silverlight application! There are two reasons for this:
First, if you want to store level data, you need to serialize the level data, for example to XML. Silverlight does not have full capabilities to serialize or deserialze data, but your server does. If you are serializing the data on your server, the data-model needs to be known on the server anyhow.
Second, if you want to send level data from your Silverlight application to the server via Soap (to your WCF service), then you are limited to the data-types supported by Soap. If you do not know all the types which are and which are not supported by Soap - like me - then you will discover your own errors very quickly if you do something wrong. A good example of a data-type which is not supported by Soap is the two-dimensional array.
The good thing is, that if you create the level data-model on your server, this model will be available in your Silverlight application later.