Project FBG Day 4

Welcome to Project FBG Development Diary.

Day 4

I should finish the Game Studio Video Tutorials today because I got the XML code to work found help in forums, for anyone doing Episode 5 and it doesn’t quite work for you try this code.

Orni’s Code:

//on to load a level file made with the ogmo editor and interpet it
 private function loadLevel(xml:Class):void {

//object voodoo (search the flashpunk forums for further explanation if needed)
 var rawData:ByteArray = new xml;
 var dataString:String = rawData.readUTFBytes(rawData.length);
 var xmlData:XML = new XML(dataString);
 var dataList:XMLList;
 var dataElement:XML;

//needed since ogmo and flashpunk count tilemaps differently
 var tile_index:int;

//reads the Tiles
 dataList = xmlData.OGMOTILELAYERNAME.tile;

//reads every tile data element and does stuff
 for each (dataElement in dataList) {

//converts the coord. based tile count ogmo uses into the absolute tile count FP uses
 tile_index = int(dataElement.@ty) * TILEMAPWIDTH + int(dataElement.@tx);

//sets a tile in the tilemap according to the information of the data element
 YOURTILEMAP.setTile(int(dataElement.@x), int(dataElement.@y), tile_index);

}

//reads the level Grid
 dataList = xmlData.OGMOGRIDLAYERNAME.rect;

//reads every grid data element and does stuff
 for each (dataElement in dataList) {

//sets a grid rectandle in the grid according to the information of the data element
 YOURGRID.setRect(int(dataElement.@x) / TILESIZE, int(dataElement.@y) / TILESIZE, int(dataElement.@w) / TILESIZE, int(dataElement.@h) / TILESIZE, true);

}

}

It was such a great help, and to make collision work make a Grid (Rectangle) Layer and colour in what is solid black.

Here’s a picture of my current progress for Collision Handling, OGMO and Tilemaps.

The main topics of the tutorials were

  • Handling Collision
  • Using GIT as Revision Control
Didn’t get as much done as I spent alot of time with collision and the problem I had last night.
Now as an extra I had an idea and it worked great!
What if you want to make a secret entrance in a tile game?
All you do is put your solid tile on the sprite layer there but leave out the solid tile on the grid layer like so.
Make sure your collision is set to grid and not sprites!Only Zach’s Video way won’t work you have to use to code above with his collision code!
Tada Secret room!

For Flash Punk’s Tutorial goto

http://flashpunk.net/tutorials/

Fallen.

Advertisements

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s