Starting on my next game…

December 20th, 2014 by Josh

Long story short: it’s something of a spiritual successor to Super Orbulite World, a game I released in 2009, shown here:

It’ll be a cross-platform (PC, Vita, PlayStation TV) 2D platformer with RPG elements. The game mechanics will be similar to Super Orbulite World. I’m starting with that basic concept, building on top of it with new features, and trying to address issues players had with SOW (such as the high difficulty curve). In the end, I think it’ll be a pretty fun game. Going to try to keep it fairly small in scope, so as to have a fairly quick development cycle.

Posted in game progress

Just released my first PS Vita game!

November 4th, 2014 by Josh

Just under two weeks ago, I came across the PlayStation Mobile SDK via a post I saw on reddit.  I downloaded it, tried it out, and ended up porting an upgraded version of Super Blackout over to Vita.

I’m pretty excited, as this is my first release on a PlayStation console. :)

For you Vita owners, you can find Super Blackout by going to the PlayStation Mobile section of the PSN store.

Posted in game releases

Super Blackout now available on PC– for free!

August 20th, 2014 by Josh

Almost one year ago, I released Super Blackout, my first Android game.

Now, I’m releasing a PC port.  The full version can be downloaded here, for free:  SuperBlackout.jar

Enjoy. :)

Posted in game releases

New program released: Text2Wallpaper

November 28th, 2013 by Josh

I’ve written a new program, available for download here: Text2Wallpaper v0.02. edit: Updated to version 0.02 to fix a quick bug.

Here’s a screenshot:

Text2Wallpaper screenshot

The goal of this program is to help learners of foreign languages, by giving them a way to quickly generate wallpapers based on small vocabulary lists.  In other words, when you’re learning a few new words in a foreign language, you can start up Text2Wallpaper to quickly type those words in and generate a wallpaper that displays those words.  This is a convenient way of putting a few words in a highly-visible area, helping you remember them more easily.

It’s pretty simple right now, but I’m hoping to add more features later, including Anki deck integration.

Posted in Uncategorized

New game released: Super Blackout

August 26th, 2013 by Josh

I just released my first Android game, Super Blackout, available for free here:

It’s a puzzle game with 90 levels, a random level generator, and a level editor.

There’s also a paid version available for $1.99, which removes ads and gives you the ability to change the graphics theme.

Super Blackout

Posted in game releases

Switched to new host; lost all but a few blog posts

March 22nd, 2012 by Josh

The old webhost I was using suddenly decided to terminate its services, and it seems something went wrong in backing up my blog’s database, so here we are to start anew.

I’ve managed to retrieve some of the old posts’ texts via Yahoo’s cache of the blog, so I’ll re-post a few of the more important ones. Other than that, it’s time for a fresh start of blogging.

Posted in Uncategorized

Tutorial: Continuations in Mozilla Rhino (a JavaScript interpreter for Java)

December 26th, 2011 by Josh

I normally post only about my own game development projects, but this is going to be an exception. This is going to be a tutorial on how to use “continuations” (pausing and resuming scripts) in Mozilla Rhino. It took me days to get this to work, because I wasn’t able to find a complete example.

I’ll also be showing, through this example, how to automatically bind all the functions of a given Java class into JavaScript. Thus, any function you write in that class (example: ScriptFunctions.pause()) will be usable as a global function in JavaScript (example: you can call the function from JavaScript simply as pause(). There’s no need to call it as ScriptFunctions.pause()). This is extremely convenient.

Note: My example will be assuming that you will be placing all of your JavaScript code into functions and calling them as you need them (as opposed to having the script do something useful as soon as it’s loaded). For example, imagine that you’re developing an RPG (role-playing game), and your JavaScript file represents an NPC (non-playable character): you can define a JavaScript function “onSpeak()” that will be called when the player speaks to that NPC.

You will need to download and install Rhino from the Mozilla Rhino website, because although Rhino is built into the Java Development Kit (JDK)’s ScriptingEngine, the version of Rhino built-in is outdated and doesn’t support continuations (at this time of writing). So, download the source code from the site, and import it into your project. You should have an org.mozilla.javascript package in your project now that you can import.

Here’s the code to initialize Rhino, load the JavaScript script from a file myscript.js, and bind all the functions in a ScriptFunctions Java class as global functions in JavaScript:

        // init Rhino (JavaScript scripting engine)
        Context cx = Context.enter();
        cx.setOptimizationLevel(-1); // use interpreter mode (necessary for continuations)
        scope = cx.initStandardObjects();

        // load the .js file
    	InputStream is = this.getClass().getResourceAsStream("myscript.js");
    	Reader reader = new InputStreamReader(is);
        cx.evaluateReader(Game.scope, reader, "myscript.js", 1, null);

	// bind all the functions in the class into JavaScript as global functions
	scope.put("scriptfunctions", scope, new ScriptFunctions());
	cx.evaluateString(scope, " for(var fn in scriptfunctions) { if(typeof scriptfunctions[fn] === 'function') {this[fn] = (function() {var method = scriptfunctions[fn];return function() {return method.apply(scriptfunctions,arguments);};})();}};", "function transferrer", 1, null);

Contents of myscript.js:

function myJSFunction()
	// your code to execute before the pause goes here
	pause(); // this is bound to a Java function that does the dirty work of pausing the script/storing the continuation
	// your code to execute after the pause goes here


Contents of (you can define more functions to do whatever you want, but the pause() function is for continuations):

import org.mozilla.javascript.*;

public class ScriptFunctions
	public void pause()
        Context cx = Context.enter();
        try {
            ContinuationPending pending = cx.captureContinuation();
            throw pending;
        } finally {

Now, finally, we get to the fun stuff. This Java code will show you how to call your JavaScript function from within your Java code, catch any continuations (“pauses”), and then resume the script execution:

	Function f = (Function)(scope.get("myJSFunction", scope));
		cx.callFunctionWithContinuations(f, scope, new Object[1]);
	catch (ContinuationPending pending)
		System.out.println("The script was paused!");
		System.out.println("Resuming the script...";
		int saved = (Integer)pending.getApplicationState();
		cx.resumeContinuation(pending.getContinuation(), scope, saved);

Of course, in regards to that last chunk of code, there’s not much point in resuming the script as soon as you pause it — I’m doing that for the sake of keeping the example simple. In a real scenario, what you would normally want to do upon catching the ContinuationPending is store the ContinuationPending’s information, and later use that information to resume the script at your leisure.

Useful links for extra reading:

Mozilla’s tutorial on Rhino continuations

Another full example of Rhino continuations (doesn’t load the script from a file, and doesn’t automatically bind a class of functions)

Rhino group on Google Groups (helpful people are here who can answer your questions)

Rhino tag on Stack Overflow (to see if anyone on Stack Overflow has posted a question that can be useful to you)

Posted in Programming tutorials