Jan062010
Seems like the last two projects I’ve done have had kind of lackluster ends. I’ve been sitting on this “mostly complete” project for a while, and while I’m still unsatisfied about certain areas (i.e. there’s no music), if I don’t push it out the door pretty soon it’ll just sit and stagnate. So, here we go: Nonogram Madness.
(If anyone cares, let me know what you think in the comments. The puzzles kinda progress in difficulty, but they haven’t been balanced at all, and some of them are pretty bad. There, you’ve been warned.)
Oct292009
The “in progress” title screen of Nonogram Madness. Yeah, I decided on a name.
Sep282009

Makin’ another game! It’s a nonogram game, inspired by Mario’s Picross (read more details about the whole genre at Game Set Watch).
Admittedly, nonograms aren’t for everyone. I enjoy them, however, because they’re simple logic puzzles that have a visual component… they’re more interesting to me than the straight-up numbers of sudoku. When I explained the concept to Chandra, she seemed interested! It’s my goal to make something that she’ll play through =]
Feb252009
Importing graphics into your Flash program is all well and good. You can create movies or animation, but the real interesting thing is taking user input and having your program react to it. The way to do that in Actionscript is to add “Event Listeners” to objects you create. Whenever an event occurs (such as a keypress, mouse movement, or whatever), your Event Listener checks to see if it’s supposed to do anything. If so, then it runs a function with code that you specify. So for example, say the user presses the “left arrow” key. Your keyboard input event handler sees this, and runs appropriate code (in this case, it might move a game character left).
One of the most basic events in Actionscript is the “enter frame” event. This triggers every time the SWF is redrawn, and basically corresponds to the SWF frame rate. In the following example, we’re going to create a new class, and add an “enter frame” event listener to it, so that whenever a new instance of that class is created, a function will run at frame rate.
package {
import flash.display.Sprite;
import flash.events.Event; // Required to add event listeners
// Set our SWF framerate, width, height, and background color
[SWF(frameRate='30', width='640', height='480', backgroundColor='0xffffff')]
public class EventListenerExample extends Sprite {
[Embed(source="ball.svg")]
public var BallGraphic:Class;
// Variables used to store movement data
private var dx:int = 5;
private var dy:int = 5;
public function EventListenerExample():void
{
// Create instance of imported graphic
var b:Sprite = new BallGraphic();
// Add to this display object
this.addChild(b);
// Attach event listener
// Listen for "ENTER_FRAME" event
// Run the "enterFrame" function
this.addEventListener(Event.ENTER_FRAME, enterFrame);
}
public function enterFrame(e:Event):void
{
// Increment position
this.x += this.dx;
this.y += this.dy;
// If object passes beyond SWF boundaries,
// reverse direction
if(this.x >= 640 - this.width || this.x <= 0)
this.dx *= -1;
if(this.y >= 480 - this.height || this.y <= 0)
this.dy *= -1;
}
}
}
Save this code in a file named ‘EventListenerExample.as’. You can see that we’ve elaborated a bit on our last example, importing and displaying an SVG graphic. However, this time we add some variables to the class that represent speed (delta-x and delta-y). We attach the event listener by calling this.addEventListener (Event.ENTER_FRAME, enterFrame);. The first argument is the type of event the listener is triggered by, and the second is the name of the function to run when the event is detected.
In the declaration of the ‘enterFrame’ function, we pass it details of the event that triggered it by putting e:Event in the arguments list. The function doesn’t actually use that information, but simply moves our graphic around, bouncing off the “walls” of the SWF. Movement is just one possible application of the ‘enter frame’ event; collision detection can also be calculated this way, among other things.