Wednesday, December 4, 2013

game markup language experiment - Part 1

Going off my last post, where I described a theoretical game markup language, mixed with JavaScript and a type of CSS, I've decided to go ahead and perform a theoretical experiment.

You can follow my progress here: https://github.com/longjoel/gml-experiment

For a project base, I am using C# and .NET to primarily develop this in. Because this is going to involve a lot of dynamic language processing, and XML processing, it just makes sense to use this instead of C or C++.

Processing the DOM: 

* This is easy enough to do, because C# handily supports XML Serialization and deserialization.

Handling the Javascript: 

I am trying to decide between several projects at the moment for the JS implementation. 

* IronJS - based on ecma script 3, looks stable but no longer maintained.

* V8.NET - actively maintained, based on google's V8 javascript engine, should be robust and fast.

* Clearscript - looks ridiculously easy to get started with, can use chakra or v8 JS engines, actively developed


Handling the CSS:

CSS parsing will be a custom solution.

Display layer:

There are quite a few options available. There is DirectX with SlimDX. There is OpenGL via OpenTK. SDL 2.0 bindings exist as well, and that's all before we begin to look at MonoGame, XNA, or using Webkit. A decision on this does not have to be made right away. For now we can just use GDI + and a debug console.

Physics API:

Physics is another piece which will come further down the pipe. But will probably just use farseer for the time being. 



So the first step will be to gather all the necessary dependencies together in a folder of DLLs.

Part 2 will be designing the kernel.

Monday, December 2, 2013

Crazy thought of the day.

So I've been playing with a lot of JavaScript lately. Perhaps even too much. But sometimes, thinking too hard can lead to some interesting ideas.

JavaScript is designed primarily to manipulate the DOM of an HTML web page. JavaScript + HTML + CSS is a great combination.

* HTML describes the layout of the document.

* CSS defines the attributes of the elements in the HTML document

* JavaScript can be used to manipulate both the document layout and the elements themselves.


So why can't we treat games the same way that we treat HTML documents?

What if instead of describing elements of a web page, we were instead describing the play-field of a game?

HTML -> gamedoc:

<gamedoc>
<head>
<script source='level1.js'></script>
<script source='enemies.js'></script>
</head>
<level>
<entity class='spawn'  x = '0.0' y = '1.1'/>
<entity class='enemy' />
<brush>
____ <bpoint x = '0' y = '1'/>
____ <bpoint x = '0' y = '1'/>
____ <bpoint x = '0' y = '1'/>
</brush>
</level>
</gamedoc>

CSS -> GSS:

brush{
____ texture:url(img/background.png);
____ visability:visible;
}

JavaScript:

$(gamedoc).onready( function () {

____ $('entity').think( function(t){
____ ____ $(this).x = $(this).x + $(this).vx * t;
____ });

});

So, I'm not super clever, but I think that if I were working on a game engine, I would rather have something declarative like this to work on, instead of something like Unity3d. But maybe i'm just weird like that.