Our first flashpunk game and why time constraints are incredibly useful


(Jay Faulkner) #1

Hey all!

We’ve just finished our first game and it’s up for download on the Play Store (with a trailer).

There’s also a reddit post with more information on the development of the game (we did the vast majority of it in two weeks) which also has links to a desktop download.

I’m really impressed with how easy flashpunk is to work with. It’s weird coming from university where they teach you strict encapsulation, scary java design patterns etc. and then you come to making a game and you realise just how liberating hammering something out really is!


Maps made with OGMO
(Willard Torres) #2

I attempted to do the automatic tilemap changing before, but it never went anywhere. Does it have to do with checking the adjacent tiles? Like a really long if statement?

Also, good job on the game :smiley: Just asking, how did you handle the multiple screen resolutions? Or did you let the stage handle it?


(Jay Faulkner) #3

We handled the resolutions on initialisation (we set a default based on Screen.mainScreen.bounds.height and allowed users to override it in settings but that requires the application be restarted). We then have three resolutions for every graphic asset in the game which sounds like a pain but most of it we automated with photoshop actions :smile:

As for the tiles, that’s a little hairy. I wish I still had the function we wrote to determine which block goes where but we condensed it down to a lookup table a long time ago (it’s something we worked on for the highlight outline of blocks in this old xna game years ago) but that doesn’t stop you using our implementation!

Basically we count the blocks around the tile and use a little binary math to generate a unique value for every possible outcome.

So for every tile we do this:

var x: int;
var y: int;
var tileBitmask: int = 0;
		
// Iterate over a 3x3 matrix of tiles around placed tile
var i: int = 0;
for (y = -1; y < 2; y++) {	
    for (x = -1; x < 2; x++) {
				
	    // Skip placed tile
	    if (x == 0 && y == 0 ) {
	        continue;
	    }
				
	    // If tile there, add relevant bit
	    if (grid.getTile(xPos + x, yPos + y)) {
		    tileBitmask += (1 << i);
	    }
	    i++; 
      }
}

// see link below for this lookup table (it's 256 lines long!)
return bitmaskToIndex[tileBitmask];

and that should give us a value between 0 and 255 (8 surrounding blocks, 8 bits) which we can lookup in this giant bitmask index (that’s the bit I wish we could remember! I just know it spanned several pages of gibberish notes!) which should correspond to a tile ID. Your tiles will have to be in the same order as the one linked in the reddit post - I can go in to more detail about that when I get home if you’d like (I’m at work at the mo)

Hope that’s helpful :slight_smile:


(Nate ) #4

Downloaded this to check out how this FlashPunk game ran on my phone, resource wise. And on my Samsung Galaxy S3, the game loads I see two logos, then the second one fades out, music starts, but the screen doesn’t load anything. It is just a black screen with music.

Is this a pilot error? Or is it not functioning properly on my device?


(Ultima2876) #5

Just to follow up on that, that bug has been fixed now if you wanted to try it to check out performance. It turned out to be something weird to do with scaling code!


(Sparrow) #6

Wow impressive, I like the graphics and music. It gives off a nice feel. Will download this on my tablet when I get back home. Also nice humour. :smiley:

Can’t wait to see how Flashpunk runs on my Tablet.


(Ultima2876) #7

Bear in mind that in terms of performance etc, this game is using Stage3DPunk rather than vanilla FlashPunk.