FlashPunk Tutorial: Demonstration SWF and Status Update

Like this at Facebook! Hello there! First of all, I gotta tell you that I haven’t been able to work on the code in peace for the last week or so. Stuff kept coming up, and the continuous delay of my vacation out of town has been keeping me on edge a bit.

Well anyways, this is (unfortunately) NOT the pathfinding tutorial. Actually, I’ve coded the pathfinding engine using A* and a Depth-First-Search implementation that makes the NPC able to walk around all over the place and in between maps as well. It’s just that the code-interface is still very simplistic – I’ll write a scripting engine next, that let’s the NPC class read from an XML file with all the information (when the NPC moves where, what the NPC says upon being talked to, etc).

So for those who are curious what will be coming up next and want to try it themselves – here is a link to the demo.

I’ll explain the demo now. Controls are as usual with the WASD keys, and M opens the world map, ESC closes it. There is a timer that runs a quickened day time from 0 to 24 o’clock, where one hour is 12 real seconds. It’s displayed in the upper right corner. Also, every 6 hours, the general day time is displayed. Those are: Morning, Afternoon, Evening and Night. Those red boxes indicate the collision boxes of tiles that are defined in the grid layer in the oels.

Our NPC is the lovely princess Zelda. She is in the house on the far right of the first map. At 6.30 I set her target position to 240, 192 inside the house that is in the outdoor map west of the first map. She finds her path absolutely autonomously, using A* to navigate a way to the immediate exit position of the map that she is currently in, and which follows a broader map path, that is determined using Depth-First-Search. The code is as I said still relatively raw. There is for example a “bug”, where you as Link can get stuck with Zelda in collision (how romantic…), when she enters a new map and you’re standing already there at her spawning position. I created a flag that makes her uncollidable for the first 2 squares that she walks on upon entering a map. But still, there are instances of bad luck where those two end up stuck together.

So up next is to create a scripting system for NPC AI control and for the map information (setupMaps() is plain ugly), as well as dialog trees and in-game text in general.

I realized that there are some problems with the previous tutorials. They do work, and like 98% of the code is correct. But there are some ugly parts (the map system in Tutorial 4 *shudder*). I’ve reworked that though. Also, EAST and WEST are swapped in the code for Tutorial 4. I’ve swapped it twice, so it’s a bug in a bug, which makes it correct. I’ll….leave it as an exercise for you :D.

Just kidding, I’ll take care of it.

Next up is an announcement that I’m going to publish the tutorial code on an online repository. Most likely Google Code. I just worked 13h on the code after getting up at 5.30 am. I need a hug..and a good book.

email thispdfcut and reblogBookmark on deliciousShare on Facebooktwitterdigg thisGoogle BuzzYahoo BuzzBookmark on FriendfeedAdd this anywhere

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s