15th Sep 2008
After working my butt-off on my latest game I decided it was time to redirect some love and attention to PixelBlitz. So this weekend I finished off a new class I had planned out a while ago. Introducing… BlitzMouse! This pairs up with BlitzKeyboard to complete the input set, and is a feature rich (and very fast) mouse handling system.
Here’s a very simple demo of it in action:
[swfobj src=”http://sandbox.photonstorm.com/blitzMouseTest2.swf” width=”550″ height=”400″]
Press the cursor keys to limit custom mouse pointer movement.
So what can this bad boy do? The aim (as with all things PixelBlitz) is to make working with the mouse in your games easier. Here’s a quick overview of the core features:
Accurate mouse tracking
Keep an eye on that rodent! Easily check if it has left the stage, or re-entered again. Doesn’t use any CPU time processing events that require the mouse if it’s not over the stage!
Button / Click handling
Detect when the mouse button is down, or up.. or being held down. Find out how long it took the user to make that last mouse click (the speed from down to up again). Find out how many clicks the user has made since you last checked. Writing those god-awful “Ninja Finger” style games has never been so simple 😉
Want to know if the mouse is moving up? Just check isMovingUp! You can poll all 4 directions easily and quickly. Want to know how far in pixels the mouse has travelled on the X axis? Call distanceX() – want to know how fast it moved? Call speedX!
To know which angle the mouse is at call angle(), and you can have the result back in degrees or radians. Use the optional “lowerAccuracy” parameter and it uses a much faster calculation, but sacrifice a little accuracy in the process (great for a quick arcade game, not-so for a physics simulation).
You can set the point of the angle calculation (it defaults to the centre of your stage), which allows you to track the angle from anywhere to the mouse. You can even get the angle from any display object to the mouse using angleToObject() (with all the same parameters that angle() supports). This means if you want 3 things all pointing right at the mouse then it’s no problem! (see the demo above) Want to know the distance from any display object to the mouse? Call distanceToObject() and it’ll tell you.
Custom Mouse Pointers
Use changePointer() and you can set the mouse pointer to any display object – with custom X/Y offset support incase the pointer needs aligning differently to the standard top left. As the mouse moves, the display object is updated. If the mouse leaves the stage the display object is made invisible, so you don’t get that “cursor stuck on the edge” problem 🙂
Want to limit the movement of the custom pointer? No problem! You can limit it in all four directions (up/down/left/right) with optional snapBack support on both axis. For example if you were making a Pong game (please… don’t) by just calling limitMovement(true, true, false, false) you will lock the bat into only moving up and down with left/right movements ignored.
Want to limit the mouse to a specific area of the stage? Call limit(new Rectangle(x,y,w,h)) – if the mouse goes outside of this zone it will be hidden from view. You can see this in the example above as it hides when it leaves the light grey box. This limit also effects custom pointers. Of course when the mouse leaves the stage there is nothing you can do about that – but we have to work within the limits of Flash here 🙂
So there we have it – BlitzMouse! Hopefully more useful than you thought when you first read the title, aye? 🙂 I plan to add more features, such as custom events/function calls on mouse actions, the ability to attach as many display objects as you like to it (so they all update at once) and custom zones, so you can have as many “mouse zones” as you want. The code is uploaded to Google, so enjoy 🙂
12th Sep 2008
Well it was quite a hard slog, but in the end I finished my Flash remake of the Atari ST classic game Abombinaball. I am extremely happy with the end results. It’s polished until you can see your face in it, and has gone down really well in the final round of beta testing.
Here are a couple of screenies:
Read my full development post-mortem here. The game is currently in the bidding process on FlashGameLicense.com (3 bids and counting!) so once this has finished I’ll of course release it for everyone to play 🙂
5th Sep 2008
Today The Game Creators released the first alpha of Social Arcade onto Facebook. I’ve been testing this one for a while, and it’s especially note-worthy for this blog because a) it’s written entirely in AS3 and b) it could flourish into something really big.
The concept behind it was to create a “drag and drop” game maker, but all built into Facebook. So the games you make you can share with your friends, who in turn can go in and play your game – and if they like what they see, they can edit your game, create their own version, and share that with their friends too. And thus, it spreads.
Only one game-type is supported right now (a scrolling platform genre) but I’ve seen the shoot-em-up core in action, and I know full-well that they’re going to be really expanding this system in the coming months. The ultimate goal being that you can create pretty much any type of arcade game.
It’s only an alpha release but the guts of it are there. While the interface could do with some serious TLC and usability testing, the core concept is sound. Once more game types and behaviours are available (especially the ability to import your own assets, or even better create sprites by directly taking a photo from your Facebook gallery) then this could explode.
Here’s a screen shot of a game I built (click it for a high res version). If you want to add the application for yourself then here’s the linkage: http://apps.new.facebook.com/socialarcade/
4th Sep 2008
All I can say is “phew!” – it was quite some work, and I actually finished this game over a month ago, but Cartoon Network have just released it onto their web site 🙂 Way of the Chook is a side-scrolling beat-em-up, in the same vein as Kung-fu Master.
I created a new Games page where you can read all about the development process, obstacles I ran into, see lots of screen shots and of course find a link to play the game!
Woohoo 🙂 Here’s a screenie to whet your appetite….
4th Sep 2008
Tonight I created and finished BlitzFont. BlitzFont is a bitmap font handling class. Most Flash games use True Type fonts for their text, or “bitmap True Type fonts”, where the font was specially designed to be used at a small resolution. This is all well and good, but what if you want to design a custom font? Something with some graphical flair that can’t be achieved via True Type. Enter BlitzFont 🙂
BlitzFont allows you to use pass in any bitmap from your library, tell it how the font characters are arranged, and then it grabs it all for you. Once grabbed you can ask it for text back again, and it’ll return bitmapData for ever more!
If this sounds a bit strange, take a look at this font here:
In this example the characters have between drawn in a grid and they are 32×32 pixels in size. Using them in your game requires just one call:
font.init(new tbjFontBD(0, 0), 32, 32, BlitzFont.SET10 + ” 1234567890,.:’-<>!”, 9, 2, 2, 1, 1);
All this does is give the name of the bitmap in your Flash library, the width and height of each character, the characters and the order in which they appear (SET10 is a built-in character sequence that you can extend), the 9 value is the number of characters per row, 2 + 2 is the distance (x and y) between each character and finally 1,1 are x/y offsets to start grabbing from.
Phew sounds quite a lot, but if you’ve got a well arranged font with no spaces, no offset and a standard ASCII ordering, then you only need to use 5 parameters!
Once you’ve initiated the font that’s it – you can use it. BlitzFont has 3 methods for this:
getLine is ideal if you only need to get back 1 lines worth of text.
getMultiLine can be given as much text as you want (that will fit onto a bitmap) and supports carriage-returns.
getCharacter simply returns 1 character.
Each of the functions above all return bitmapData objects. You have alignment support, so you can left align, right align or center each line perfectly. You can also control the x/y spacing between characters!
var bd:BitmapData = font.getMultiLine(“welcome to thenpixelblitznblitzfont demo”, 1, 16, BlitzFont.ALIGN_CENTER);
The class does all the dirty work for you, like removing un-supported characters from your input string, making sure it deals with spaces efficiently, and wrapping text on carriage returns.
But wait, there’s more! You can also create scrolling text messages with 1 line of code 🙂
defineScroller(width:uint, speed:uint, text:String, autoUpperCase:Boolean = true, wrap:Boolean = true, spacing:uint = 0):BitmapData
Ok I know, scrollers are old-hat now.. but sometimes in a game you want a little scrolling message, or status update or something, and with this you can easily create it 🙂 You just define the scroll settings, and then call updateScroller() every loop. You can even set custom events to fire if a certain character scrolls on! and the scroller will fire events on text complete and text wrap too.
Here’s a demo of this in action (refresh this blog entry if you didn’t get to see it from the start!)
[swfobj src=”http://sandbox.photonstorm.com/fontDemo.swf” width=”550″ height=”400″]
All about Photon Storm and our
HTML5 game development services
Filter our Content
- Cool Links
- Flash Game Dev Tips
- Game Development
- Geek Shopping
- In the Media
- Phaser 3