Apr 4, 2012 - 7 Days of ActionScript - Day One

I’ve been mucking about with JavaScript to integrate it into my engine recently, and it’s been fun to mess with it at such a low level, and see the challanges that browser developers have to face in implementing the HTML5 spec. That said, I haven’t done a great deal of pure JavaScript yet, so that’s something I’m going to have to do at some point - yet another thing to add to the list!
But what about the other popular language that derived from ECMAScript? Can I look at that instead and bolster on another language to my tool box?

The next seven days, I’ve set myself the challenge of doing something in ActionScript 3.0 ( well, six days now, as I spent the night looking about for various things, which I’ll be describing below. )
There are reasons for this - both ActionScript and JavaScript are derived from ECMAScript, so should have a lot of common fundamentals, and both languages are very much used on the web. Learning more languages is always a good thing since as a Programmer, I will always try to use the right tool for the job and who knows when ActionScript will come in useful! Seeing how dominant it has been on the web, there’s always a possibilty of using it as the general shift to web-based apps continues. That, and being the madman I am, I always enjoy a good challange!
The seven day deadline is also to ensure I actually finish something for a change, knowing how bad I am for doing that with my outside work projects!

I also have a special restriction - which is what I spent last night researching - in that I exclusively use Linux.

Back in first year University, one of my coursework projects was to create a game in ActionScript with Flash MX 2004. The resulting mess can be seen here: Santa’s Elves. Of course, I got to use the University computers to do this, and Flash is a rather expensive Windows/Mac only program anyway - so what can I do on Linux?
I can use whatever text editor I like, and I can use Adobe’s Flex SDK ( which’ll soon be Apache Flex, as it’s currently in the incubator project ) to compile it into a Flash application. Luckily, Flash on Linux has been reasonably decent for a while now, so I shouldn’t have any problems viewing whatever I create.

So, what will I be up to the next seven days?
Well, I have to get the toolchain setup, and do some quick tests to ensure things work.
I then need to do some more advanced tests with graphics and sounds, and see how I can compile all of this into the Flash application; followed by reading files, writing files, etc.. the standard things you do when learning a new language. Then I can actually start on something.
I effectively have a few hours per day to work on this after I finish my usual work, and while two little whirlwinds calm down, get fed, and go to bed - so I reckon I’ll have about 24 hours in total to work on it. Seeing as I’ve managed to write games for LudumDare in 48 hours from near enough scratch, this should be doable!

I’ll be posting each day with what I’ve got done, as a nice little breadcrumb trail should I end up doing ActionScript on Linux again - hence the tagging on The Quest.

Mar 24, 2012 - GLESGAE Script Modules

The past couple of months, I’ve been fiddling with JavaScript and writing a module for it within GLESGAE.
The way I’m doing this is so that the scripting modules are effectively separate libraries, so for example, there’s GLESGAEJS for the JavaScript portion, and GLESGAELua for the Lua portion.
Nothing in the main library will be dependent upon it, and if you want to use GLESGAEJS, you’ll need to pull in GLESGAE as well.

In terms of the JavaScript bindings, I’ve also been providing some support for some HTML5 elements, such as Canvas and Audio. The idea being that it can be used to power web applications as a native application, creating a hybrid application that can access both JavaScript and C++, or bridge to whatever other language you feel like ( some JavaScript/Lua mash-up, perhaps? )
I’ve not done any WebGL support as yet, but this should be relatively trivial, and also be a very nice fit considering the engine’s designed for GLES support from the outset!

I’m still planning on getting Lua support done as well. Lua’s still my favourite scripting language for it’s small footprint and easy extendibility, and as long as I stick to the framework I’ve laid out, I should be able to fiddle with other scripting languages too.

I had been aiming to get the engine ready for the next Ludum Dare, but with various commitments this year, it looks like I’ll be missing both the April and August competitions. So, hopefully by October, I’ll definitely be ready to tackle something this time!

This is looking like it’ll be a good year though - so here’s hoping I can find more time for random projects :)

Jan 31, 2012 - GLESGAE and Scripting

It’s been a while since I had time to look at GLESGAE, but I had some time last night to do so.

I’m surprised that it’s still relatively clean, and in a working state! But I did seem to split it and spew it across all manner of source control systems - two public SVNs, a public git, a private SVN and a private git - so finding the current version was fun. Though from what I was up to last time with the rewriting of the graphics system, it looks like I broke shader support - but then for what I’m about to do, I’m not going to be needing that for a while yet anyway, so that can be fixed in due course.

One of the things I’m particularly partial to is that of offloading as much as I can get away with to a scripting language. This generally allows quicker iteration of ideas, and anything that slows down can (generally) be easily translated to a native function if need be - you’d just need to overload the function call!

For the most part, my language of choice has been Lua.
It’s fast, it’s small, it’s very easy to embed and extend, and I’ve been fiddling with it for years now.
I do like me a bit of Lua.
Lua was going to be my first choice of implementing a scripting language into GLESGAE… however, with the rise of HTML5 and JavaScript, I’m having a slight change of heart.

The past few months, I’ve been looking over HTML5 and JavaScript. Having quick fiddles here and there, and playing with things like Impact, WebGL and Canvas directly. While it’s been relatively painless on my development environment of choice - Linux and Chromium - it’s not quite been as easy to get things running on other browsers without oddness, and especially on mobiles as generally they lag well behind their desktop counterparts, and are a much more constrained platform to work with.
Luckily, there are several projects providing technology to help bridge this gap - such as Appcelerator, and AppMobi’s various projects, to name a few. These work by binding JavaScript to their engine-like system, and parsing it directly without the overhead of a full browser, as well as providing a bunch of extra overloads and libraries for various things to make your web app feel and act like a native app.
This is nice and all, but they also throw in everything and the kitchen sink ( the test apps for both companies are actually labelled as such too! ) whereas for doing something like games, you don’t generally need as much, or would at least like to get rid of as much cruft that’s not being used as you possibly can.

So, I’ve been thinking that the first scripting language that GLESGAE will be supporting is JavaScript.
However, this brings about it’s own dilemmas… supporting JavaScript isn’t exactly an easy endeavour as it’s more of a specification of ECMAScript than of a nice compact module or library you can just throw into your code, like Lua. As such, I’ve been looking at JavaScriptCore ( and the entirety of WebKit in general ) and Google’s V8 to use in such a manner.

V8 looks really nice and clean, and provides a C++ API - which as I’m using C++ in GLESGAE anyway, is a nice little boost.. though wrapping around C isn’t exactly problematic anyway. I had examples compiling and running in a little under an hour, and felt experienced enough to take on the task of adapting a system-like interface for easily extending classes, managing contexts, etc…
There is a slight hiccup though.. I haven’t really found much of a way of getting it running on iOS nicely, and while GLESGAE doesn’t actually support iOS at all just now, it will do in the near future.

JavaScriptCore, on the other hand, does run on iOS…; it’s also already embedded in the OS to begin with as it’s part of WebKit - which powers Safari. It exposes a C API to deal with binding, and while there’s certainly more tutorials and examples on using it, it just doesn’t feel as clean as V8 does. That said, it’s still straight-forward enough to use.

While I really do like V8, and would much prefer to use that.. it seems that without it supporting iOS at the moment, my hands are a bit tied ( I’d love to be pointed to some help on actually getting it compiling and working on iOS without resorting to jailbreaking the device! ) So it’s JavaScriptCore for me.

This will all be added to what is now going to be the main and only supported repository of GLESGAE; The github project. I may still maintain a personal one for random fiddlings, but the public engine itself shall be opensource under the LGPL v2.1 with the terms effectively summarised as:

  • You can either link via a shared object ( e.g. GLESGAE.dll ) or you can statically link.
  • If you statically link, you must either provide the object or source code to your application along with any libraries and custom tools not available with a standard platform development kit that use this code, or simply provide a written offer, valid for three years, to provide these materials upon request to anyone with a legal copy of your application.
  • If you link via shared object, just note which version (GIT Revision/Tag or Binary Release Version) you have used. The offer of a private license is still open as well, should the LGPL not be to your liking.

Anyway, with that out of the way, and now knowing what I’m up to again, expect JavaScriptCore bindings in GLESGAE at some point!
What? where you expecting an actual date for me to miss? :)