Skip to content

Instantly share code, notes, and snippets.

@RichardMarks
Created February 1, 2011 20:52
Show Gist options
  • Save RichardMarks/806644 to your computer and use it in GitHub Desktop.
Save RichardMarks/806644 to your computer and use it in GitHub Desktop.
private function CreateMinimap():void
{
// create a buffer the same size as your game world
// fill it with nothing (0% alpha and no pixels drawn on it)
minimapDisplay = new BitmapData(WORLD_WIDTH, WORLD_HEIGHT, true, 0x00000000);
// loop over the game world exploration grid
var gh:Number = Global.exploredMap.rows;
var gw:Number = Global.exploredMap.columns;
for (var gy:Number = 0; gy < gh; gy++)
{
for (var gx:Number = 0; gx < gw; gx++)
{
// if the tile has been explored, draw it on the minimapDisplay
if (Global.exploredMap.getCell(gx, gy))
{
// draw a cyan 100% alpha pixel to show that we have explored this tile
minimapDisplay.setPixel32(gx, gy, 0xFF00FFFF);
}
}
}
}
override public function render():void
{
// draw everything else
super.render();
// draw minimapDisplay centered
FP.buffer.copyPixels(
minimapDisplay,
minimapDisplay.rect,
new Point(
int((FP.width - minimapDisplay.width) * 0.5),
int((FP.height - minimapDisplay.height) * 0.5));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment