Author Topic: FlxMinimap  (Read 1747 times)

BruceJillis

  • New Member
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
FlxMinimap
« on: Sun, Sep 9, 2012 »
Hey Everyone,

Inspired by the good example Gama11 gave here earlier with his awesome FlxTrail class, I would also like to give something back to the community, namely the minimap that I developed during the last bacongamejam that I participated in. I decided to showcase it by adding it to the excellent flixel tilemap feature demo. Without further ado:

<a href="https://dl.dropbox.com/u/29254286/FlxMinimap.swf" target="_blank" rel="noopener noreferrer" class="bbc_link bbc_flash_disabled new_win">https://dl.dropbox.com/u/29254286/FlxMinimap.swf</a>

Using it is as simple as adding these few lines:
Code: [Select]
   miniMap = new FlxMinimap(collisionMap, FlxG.width - 75 + 3, 3, 75, 50);
   miniMap.follow(player, 0xffff0000); // follow the player in red
   add(miniMap);
which tells the minimap to render the collisionMap FlxTilemap at x, y = (FlxG.width - 75 + 3, 3) with w, h = (75, 50) and follow the player in red. Check out the sourcecode on https://github.com/BruceJillis/FlxTilemap-Demo if you'd like to know more.

Charlie Riot

  • Highly Super
  • Member
  • **
  • Posts: 69
  • Karma: +0/-0
    • View Profile
Re: FlxMinimap
« Reply #1 on: Sat, Sep 15, 2012 »
This is great! It would obviously have to be tweaked a bit depending on a game's tilemap sizes and such, but it's an excellent framework. Good job!

paala

  • Contributor
  • ****
  • Posts: 250
  • Karma: +0/-1
    • View Profile
Re: FlxMinimap
« Reply #2 on: Wed, Sep 19, 2012 »
if the level is larger that screen size how the minimap will behave? will follow player and show a minimap of the map shown on screen or the whole map?

BruceJillis

  • New Member
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Re: FlxMinimap
« Reply #3 on: Fri, Sep 28, 2012 »
It will show the entire map area. It will scale the largest dimension (width/height) to within the minimap area and center the resulting bitmap. Like charlie riot (thanks btw!) remarks this is definitely meant as a base to build on to make your own stuff. Having said that, I suspect that if you want the minimap to scroll you will have to add quite a lot of code. In essence you will have to create a simple camera system and add scrolling code.. this could easily double the size of the class.