May 25, 2009

I've been experimenting with the Javascript port of processing by John Resig and it seems like it could be quite good for rapidly prototyping games on the web. One of the great things about it is that it doesn't require any plugins or proprietary technologies like Flash, relying instead on the canvas element. There are some awesome demos of it in action on the website. I made a little fork which is optimised for the task of writing object oriented game code, which you can see in action below. Try clicking on the spinning asteroids.

My fork implements a basic mainloop into which you can inject new game entities with the function addEntity(); and a bunch of convenience methods which you can implement to draw your entities, or capture events like mouse clicks. As per processingjs, you can use processing's Java style syntax, or Javascript syntax instead. Here's the source to the above example:

size(400, 225);

function Asteroid(radius, x, y) {
    // variables
    this.x = x || random(0, width);
    this.y = y || random(0, height);
    this.angle = random(0, PI);
    this.radius = radius || 40;
    // velocities
    this.angleV = random(-0.1, 0.1);
    this.xV = random(-0.5, 0.5);
    this.yV = random(-0.5, 0.5);
    // structure of this shape
    this.points = [];
    this.randomPoint = function() {
        return random(-this.radius/2, this.radius/2);
    }
    for (i=0; i<round(this.radius / 5); i++)
        this.points.push([this.radius * Math.sin(i * PI / round(this.radius / 10)) + this.randomPoint(),
            this.radius * Math.cos(i * PI / round(this.radius / 10)) + this.randomPoint()]);
    this.poly = [];

    this.collisionPoly = function() {
        return this.poly;
    }

    this.mouseDown = function() {
        if (this.radius > 25) {
            addEntity(new Asteroid(this.radius / 3 * 2, this.x + this.randomPoint(), this.y + this.randomPoint()));
            addEntity(new Asteroid(this.radius / 3 * 2, this.x + this.randomPoint(), this.y + this.randomPoint()));
        }
        delEntity(this);
    }

    this.update = function() {
        // update all our state variables
        this.angle += this.angleV;
        this.x = (this.x + this.xV + width) % width;
        this.y = (this.y + this.yV + height) % height;
        // update our shape definition
        for (n=0; n<this.points.length; n++) {
            this.poly[n] = [this.points[n][0] * cos(this.angle) - this.points[n][1] * sin(this.angle) + this.x,
                this.points[n][0] * sin(this.angle) + this.points[n][1] * cos(this.angle) + this.y];
        }
    }

    this.draw = function() {
        stroke(255);
        noFill();
        beginShape();
        for (n=0; n<this.poly.length; n++) {
            vertex(this.poly[n][0], this.poly[n][1]);
        }
        endShape(CLOSE);
    }
}

addEntity(new Asteroid());
addEntity(new Asteroid());
addEntity(new Asteroid());
addEntity(new Asteroid());
addEntity(new Asteroid());

I you want to check out all of the code, including my modified version of processingjs, I've put my bzr repository online and you can get it like this:

bzr co http://mccormick.cx/dev/gameprocjs/

Or you can click here to download a zipfile of the source.

The main thing to be aware of is that any object added with addentity() should have an update() method, which will get called once per game loop to update your object's state, and a draw() method where you should put the code to draw your object. Other useful methods which you can implement include mouseDown() and mouseUp(), both of which require that you provide a method called collisionPoly() which returns a list of points that define a collision polygon for your game entity. Later I hope to add my Javascript recursive dimensional clustering implementation which will make it really simple to detect in-game collisions and will also require a method called getBoundingBox() which will make the collision detection and mouse-click-detection much more efficient.

Anyway, if you're interested in using this I'd love to hear from you!

May 17, 2009

GameJam0509

This screenshot is as far as I got during the latest GameJam, which has been running in my home town, Perth. I joined remotely from here in London, but unfortunately I just didn't manage to squeeze in the time to make the game I was hoping to. I did manage to advance the MinimalistPlatformer codebase quite a bit further than it was towards the larger platformer game I have cooking away in the back of my mind though, so that's quite positive. Hopefully I'll get some more time to continue this work, and maybe even produce some binaries of my GameJam entry at some point.

April 20, 2009

Wow, huge news. There is finally, after all these years, an awesome free and open source audio playing library for the Nintendo DS and GBA. Hooray! This is big news for me as Looper Advance has been built against the non-Free Krawall library for years now and it's always irked me, quite appart from making the GPL license on Looper Advance invalid, and probably illegal.

Hopefully I'll get a chance to update Looper Advance soon and then I can release it properly as 100% Free Software.

MaxMod appears to be pretty comprehensive in that its API provides for mod-playing, sample-playing, and direct access to streaming buffers. This basically means you can write apps which mix and match all three types of audio playback.

maxmod

April 4, 2009

Moose and I are in Barcelona for a couple of weeks while I get properly up to speed on the RjDj iPhone code which I haven't really been involved enough with so far, concentrating mainly as I have on the server side of things. We are really digging Barcelona and its lovely relaxed atmosphere, great food, and amazing buildings everywhere. We have even tried to pick up a little local vocabulary. Today we plan on taking a day trip up to Montserrat by cable car.

The social and server side features I've been working on for the last 5 months for Reality Jockey Ltd. along with the rest of the team, are finally online, co-incident with an update of the main app and the albums being made free for a limited time. This is in huge part due to Andie, who really kept us all focussed and moving constantly towards this target. Live site, at last! Feels great.

This is pretty exciting for me as it's the first time a project that I've been a part of has made it onto the Boing Boing network. Offworld post, yay!

In addition to that, RjDj chose to feature a couple of my scenes, which I worked on in my spare time outside company hours: CanOfBeats, and GhostWave, which has propelled them to into the 'most popular' position on the website. They never would have been finished in time if it was't for Frank and Florian's hard work at the last minute, fixing all my horrible bugs and adding nifty features.

My excitement is only tempered by the fact that I wrote a large amount of the server side code, so if it collapses in a heap under the weight of the ogling internet it's probably my fault. It seems to be holding up alright so far though, with most of the heavy content in Amazon's S3 cloud, and liberal use of FastCGI and LightHTTPd. The backend is mostly written in Django + Python if you'd like to know. Python is a king amongst programming languages and it means that I go to work each day looking forward to writing code instead of dreading null pointers, buffer overflows, lack of type flexibility, arcane syntax, and all of the other horrid issues which plague other popular programming languages.

The other huge piece of amazing tech that I should mention and which makes up probably the bulk of the client side code is the free and Open Source (BSD license) Pure Data DSP patching language by Miller S. Puckette. Whilst not a wonderful general purpose programming language, it does one thing and does it superbly. All of the RjDj scenes are actually just Pd patches with a fancy image or two and some custom externals running.

Good times!

March 24, 2009

I shouldn't call this a game design, because really it's just a random assortment of ideas thrown together in my head, and a mockup of the aesthetic I have in mind. The x's and o's in the background would move in parallax with relation to the ships and rocks.

Asteroids TNG Mockup

If I had time to make a game right now, this would be it. Basically it looks and plays a bit like Asteroids, but the rocks don't fly around crushing you - they hang still in space, and you shoot the coloured ones to get minerals from them. It's multiplayer and set in a persistent universe, so I guess that makes it an MMO. You can fly up to other people and talk to them, trade items with them, etc.

I remember the intense excitement of the first time I played a MUD, back in the mid 90s. It wasn't the game element of it that excited me - it was the exploration and social elements. I guess I am a fan of virtual worlds more than games in that respect. I'm not that interested in grinding.

Asteroids TNG would be a bit like Diabolo, but in space and with vector graphics. That is to say, there are some asteroids that you can land on, and when you do, the game turns into a Roguelike with one short 'dungeon' per asteroid, and simple vector graphics instead of ASCII graphics. All of the monsters would be futuristic alien sounding monsters, and instead of wands and scrolls you would find rayguns, data nodes, and nanotech stems, and instead of armour you would find field generators and shielding, etc. You get to keep the inventory of things you find in the asteroid 'dungeons', and you can trade these items with other people. Later there would be space stations where you could dock to meet up with people.

The whole thing would be procedurally generated using Perlin noise to generate an infinite asteroid map, and Rogue-like logic to generate the asteroid dungeons. Lately I have been reading and obsessing over the source code of Donny Russell's AGB Rogue, which is a conversion of the original BSD Rogue for the Gameboy Advance, and probably my all-time favorite Rogue. It goes with me everywhere on my Nintendo DS. The code is incredibly unclean, but it's fun to look at the probability tables and dungeon generating functions to get an insight into how they balance the game.

The music would be chippy as hell.

Won't someone give me a wad of cash to make this social roguelike space MMO? I swear I will port it to Nintendo DS, iPhone, web, Xbox360, widgets, gadgets, screenlets, Windows, MacOS, Linux, and the Wii, and make you millions of dollars.