FOTB Slides and Asobu Game Toolkit

Now that I’ve had a chance to settle down, catch up on some email, spend some time with the family, upload my photos, and blog about Flash on the Beach 2009, I will post my slides:

Presentation Slides

As usual, seeing a bunch of bullet points and diagrams doesn’t replace the thrill of watching me babble on for an hour, but it’s the best I can do unless John releases the video taken by that camera man who was in my face the whole time. 🙂

In there, I mentioned the game toolkit I’m working on, called Asobu, which means “to play” in Japanese. A lot of people asked me about it at the conference, and I hope I didn’t set expectations too high. I’m not trying to revolutionize the Flash gaming industry or create the next big thing that everyone uses to make games. Really all I’m trying to do is make a few reusable classes to use in my own games and make things easier for myself. But I’ll release them and if anyone else wants to use them, they’ll be free to. And hopefully a few people will say, “why the hell did you do such and such that way?” which will lead to improvements for myself and anyone else.

So what does / will Asobu consist of? First of all, it’s going to be mostly generic, architectural type stuff. There won’t be any physics engines, collision engines, 3d engines, particle systems, tile maps, isometric engines, or anything else like that. Well, a few of those things might make it in there someday, but I’m concentrating more on the things that make up the different structural parts of a game and hold them together. So far it has:

– A state machine with scenes and transitions. This is named after and loosely based on the Director class in cocos2d for iPhone. I showed some examples of this in action in the presentation, and there are some code snippets in the slides. Basically, you make each part of your game a Scene – the intro, the game itself, instructions, high score table, credits, etc. – and move between them with the Director. There are various prebuilt transitions, or you can create your own.

– A few essential UI Elements: A configurable label for displaying text, a button, and a very flexible menu system. I might extend the label to make a larger, multiline text area. In my experience, these are most of what you need to show options, settings, instructions, etc.

– A sound/music manager allowing a single point for loading/embedding sound files and playing them with various options, mute/unmute, volume, etc.

– A library/asset manager for loading/embedding and accessing external assets in one place.

– The beginnings of a level manager class for loading/embedding external level definitions. I’d also like to see if I can extend a level editor I made for a game with my Minimal Components into something generic enough to be reused on multiple projects. It would be great to have a relatively easy way to create at least a good chunk of a level editor with drag and drop of custom objects and property inspectors for them. We’ll see how that pans out.

Anyway, there is a lot of work to be done on all of this. The Director and Scenes and the UI Elements are the furthest along. Stay tuned to see more. Again, I don’t think anything here is going to amaze anyone anywhere, but what’s there already has proven helpful to me, and hopefully will be helpful to someone else too.

This entry was posted in ActionScript, Conferences, Flash. Bookmark the permalink.

7 Responses to FOTB Slides and Asobu Game Toolkit

  1. Josh Tynjala says:

    It looks like your Director class is similar to something I built for my games that I call ScreenNavigator. You can add screens as display objects or classes, transitions are created by calling function references (which allows me to swap out different tween engines based on whichever is my favorite at any moment in time), and I can use events from each screen to wire up the navigation. An event will either display a new screen by referencing a string id, or it will call a function reference to do something else. It’s very flexible, and maybe not all that pretty, but once I had it up and running, my development of game menus sped up significantly.

  2. Prankard says:

    I looked at your slideshow. It looks really really cool.
    I understand that it isn’t “groundbreaking” stuff, in fact when it works, it’ll just work. But that’s the point.

    I work for a very small design agency, and I’ve had to make a general game menu system to re-use for a lot of games. But that’s just one menu and it isn’t very flexible at all but it’s handy for making small games.

    I’m going to suggest a couple of things (even though it’s not complete yet). Maybe for version 1.5 or something.
    I’ve been using Cocos2d this weekend and making the menu’s etc was the easyest thing to whip out. So so useful. At first I thought it was limited in the terms of the menu positioning. But then I realised I could make more menus and then re-position them. Making a complex looking main menu.
    But what I feel the menu.h is missing in Cocos2d is to justify text menus left and right. Perhaps with the flash textfield this can be done quite easily? I’m not sure.

    And finally, the sound manager class. It would be useful to have stopAndFade(timer:Number) and pauseAndFade(timer:Number) aswell.

    I made a small MP3 player that loops through tracks. And it’s so much easier to go:
    var mp3:MicroMP3Player();
    mp3.addSong(new SoundTrack1());
    mp3.addSong(new SoundTrack2());
    mp3.addSong(new SoundTrack3());
    mp3.play();

    And that sound will be managed and loop infinitely through the game. Perfect for in-game music.

    package {

    import flash.display.Stage;
    import flash.media.Sound;
    import flash.media.SoundChannel;
    import flash.events.Event;
    import flash.media.SoundTransform;

    /**
    * …
    * @author James Prankard
    * http://www.prankard.com/
    */
    public class MicroMP3Player {

    private var songs:Array = new Array();
    private var playing:Boolean = false;
    public var currentTrack = 0;
    private var constantChannel:SoundChannel;
    private static var stageInstance;

    public function MicroMP3Player() {
    }

    public function addSong(song:Sound):void {
    songs.push(song);
    }

    public function play():void {
    playing = true;
    if (songs.length>0) {
    constantChannel = songs[currentTrack].play();
    constantChannel.addEventListener(Event.SOUND_COMPLETE, waitForFinish);
    }
    }

    private function waitForFinish(e:Event):void {
    if (constantChannel != null) {
    constantChannel.removeEventListener(Event.SOUND_COMPLETE, waitForFinish);
    nextTrack();
    play();
    }
    }

    public function nextTrack() {
    currentTrack++
    if (currentTrack == songs.length) {
    currentTrack = 0;
    }
    }

    public function prevTrack() {
    currentTrack–
    if (currentTrack < 0) {
    currentTrack = songs.length-1;
    }
    }

    public function playNextTrack():void {
    nextTrack();
    stop();
    play();
    }

    public function playPrevTrack():void {
    prevTrack();
    stop();
    play();
    }

    public function stop():void {
    playing = false;
    if (constantChannel != null) {
    constantChannel.stop();
    constantChannel.removeEventListener(Event.SOUND_COMPLETE, waitForFinish);
    }
    }

    public function getPlaying():Boolean {
    return playing;
    }

    public function setVolume(volume:Number):void {
    constantChannel.soundTransform = new SoundTransform(volume, 0);
    }

    }
    }

    Anyways, really looking forward to seeing and using your framework 🙂

  3. abitofcode says:

    Great presentation at FOTB this year, I’ve recently run into the ‘Game is more than a game loop’ issue. The game part was built in just under 3 days the rest of it is 3 months and counting, cocos2D is helping reduce the dev time but its still a little painful. Keeping an eye on all the retain/release business is also having the side effect that I keep falling into early optimization.
    Looking forward to next years FOTB carefully blending technology, creativity and alcohol.

  4. leerraum says:

    do you think john will release the videos? there are no videos of FOTB08 except those teaser vids. I would be quite pleased if he would release them.

  5. Richard Lord says:

    I so wanted to see your session, but others at the time were more relevant for work so I ended up missing you. Thanks for putting the slides up.

  6. Lee Probert says:

    I really wanted to sit down with you to talk about the use of the Decorator pattern as a technique to create the component based entities you spoke about. Never found a good time. The last thing you’d have wanted was someone talking shop while you’re enjoying your beer. Be good to chat about it at some point though. Really enjoyed your talk. Cameraman was a bit eager though wasn’t he?

Leave a Reply