Nonogram Madness is effectively done

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.)

3 comments · Written by Nathan at 8:13 pm · Tags , ,


Armada

So I finally decided to be “done” with this little shooting game I’ve been working on for a while. It’s called “Armada.” The goal is to destroy 1,000 enemies. Whenever you kill one, another one jumps on the screen to take its place. However, the more enemies you kill, the faster your ship moves and shoots. Check it out on Kongregate.

One thing I’ve learned about myself during its development is that I can get really bogged down working on more than one thing at a time. My personal programming time is so limited that having two active projects slows things down considerably. Plus, if a project takes too long, I lose motivation pretty quickly. When waking up early in the morning, one has to be excited about what one is doing (an aside: tips for waking up early).

No comments · Written by Nathan at 11:51 am · Tags , , ,


wonderfl

This isn’t exactly news, but I created an account on the Japanese social network/code sharing site Wonderfl. It’s kind of cool… you can use the site to automatically compile Actionscript 3 code, then save it for other people to check out. If you see some code you like, or that sparks a new idea, you can “fork” it — copy it and save your own version. I was kind of surprised… I added two small demos on Monday, and by Wednesday some other users had already modified my demos. There’s a lot of random crap, but you can also learn some cool techniques by browsing through the user-submitted code. If you have any interest in Actionscript, you should check it out.

No comments · Written by Nathan at 1:28 pm · Tags , , , ,


Animation in Actionscript 3

I think one of the main disadvantages of using the Flex compiler to create Flash programs is that animation is a bit more difficult to create (although, to tell the truth, I’ve never used the Flash IDE enough to be able to compare them). I think for most simple games, you can get away with not animating any of your characters. But once you get into creating games that have more detailed characters, you pretty much need to add some sort of animation. We can do that pretty easily by loading multiple images into a DisplayObjectContainer (such as a Sprite) and then showing/hiding each image in turn. Take a look at the following example:

package {
  import flash.display.Sprite;
  import flash.events.Event;
  import flash.utils.getTimer;	// for getTimer()

  // Set SWF FPS, etc.
  [SWF(frameRate='30', width='200', height='200', backgroundColor='0xffffff')]

  public class AnimationExample extends Sprite {

    // For frame rate info
    public var ticks:Number = 0;
    public var framesPerSecond:Number;
    public var frameTimer:Number = 0;
    public var currentAnimationFrame:int = 0;

    // For animation
    [Embed(source="run-1.svg")]
    public var animationFrame1:Class;
    [Embed(source="run-2.svg")]
    public var animationFrame2:Class;
    [Embed(source="run-3.svg")]
    public var animationFrame3:Class;

    public var character:Sprite;

    public function AnimationExample():void {

      // Create new sprite for animation frames
      character = new Sprite();

      // Add frames, hide all but the first one
      character.addChild(new animationFrame1());
      character.addChild(new animationFrame2());
      character.addChild(new animationFrame3());
      character.getChildAt(1).visible = false;
      character.getChildAt(2).visible = false;

      this.addChild(character);

      // This will call the animation function
      this.addEventListener(Event.ENTER_FRAME, enterFrame);
    }

    public function enterFrame(e:Event = null):void {
      // getTimer() provides # of ms since Flash Player started
      var currentTicks:Number = getTimer();

      // Figure out how many seconds each frame is displaying for
      var secondsPerFrame:Number = (currentTicks - ticks) / 1000;

      // For the heck of it, you can also determine FPS
      framesPerSecond = 1 / secondsPerFrame;

      // Set this var for the next iteration
      ticks = currentTicks;

      // Increment the timer
      frameTimer += secondsPerFrame;

      // Compare the frameTimer value against the number of seconds you want each frame to display
      if(frameTimer > 0.5) {
        // Reset the frame timer
        frameTimer = 0;

        // Hide the first frame
        this.character.getChildAt(0).visible = false;

        // Move the last frame up to be first
        this.character.setChildIndex(this.character.getChildAt(2), 0);

        // Show the new first frame
        this.character.getChildAt(0).visible = true;
      }
    }
  }
}

Download the code, .swf, and (bad) graphics.

In addition to the setChildIndex() function that swaps the depth of each animation frame, there’s also some code that obtains the current frame rate, which helps set the speed of the animation. In some games, the motion of all the characters can be limited by a number derived by the frame rate, which helps ensure that the game runs the same speed on different computers. This isn’t totally necessary in Flash, however, since it’s possible to limit frame rate by using [SWF(frameRate='XX')] at the beginning of your Actionscript package.

No comments · Written by Nathan at 12:21 pm · Tags , ,


Compiling Papervision3D projects
using mxmlc

There’s a new competition going on at TIGsource called the “Cockpit Compo,” wherein the design constraint is using a cockpit (or similar HUD). I doubt that I will have time to actually make an entry, but since I’m using Actionscript/Flash as my language/platform of choice now-a-days, I’m trying to look into a 3D library for Actionscript. Papervision3D seems like a favorite, so my next step is to find some tutorials and give ‘em a shot. First, though, we have to figure out how to actually compile projects with Papervision.

1. Obtain the (free) Flex SDK, and put it somewhere in your system path. I wrote a post about setting up your Actionscript development environment; check it out if you haven’t done this already.
2. Download the Papervision3D compiled library (.swc) or source (.as). It doesn’t really matter which one, as I will explain how to use ‘em both.
3a. If you got the .swc, put it in the same directory as your project files and rename it to ‘papervision3d.swc’. When you compile, add the flag -include-libraries papervision3d.swc. That’s it!
3b. If you got the .as source, extract it and put the ‘/org’ directory in the same directory as your project files. Compile as normal, you don’t need to feed mxmlc any extra flags.

To test out the process, get the “Simple HelloWorld Example for Papervision3D 2.0″ .zip that’s on the Papervision3D downloads page. Drop in the .swc or the /org directory (depending on what you downloaded), then compile using the instructions above. I got the .swc, put it in a subdirectory called ‘/libs’ within the /src, and compiled with mxmlc Main.as -include-libraries libs/papervision3d.swc. If everything goes the way it should, a .swf will be produced that displays a crazily-textured spinning sphere.

1 comment · Written by Nathan at 2:39 pm · Tags , , ,


Older Posts →