Build an in game mini-map

TobyToby Member Posts: 478
edited November -1 in Working with GS (Mac)
The mechanics of my game are pretty much complete, just wondering if anyone has managed to build a minimap in GS.

A minimap, for clarity - a small representation of the map in the corner of the screen showing your position in relation to the larger map.

I have the map graphic on screen in the correct position with a level of transparency(Bottom LHS), how do you go about plotting the position with a red dot on the map relative to the ship XY position? Trig again, or is there a simple solution?

Comments

  • KamazarKamazar Member Posts: 287
    Constrain the position of the red dot to the position of the player in the playing field dividing it by the scale of the map. That didn't come up too clear. To clarify.

    If the mini-map is 1/4 the size of the level...

    Constrain the location of the red dot to 1/4 the location of the green dot.

    With this solution, though, you're stuck placing the mini-map in the top left (or bottom left?) corner. Just add an offset (besides the 1/4) to fix it. ... did that come out coherent at all?
  • JGary321JGary321 Member Posts: 1,246
    Suggestion?? Add it to the wiki, nice one.
  • TobyToby Member Posts: 478
    Added mini-map instructions to the Wiki, please review and make adjustments if you feel it's not clear.

    http://gamesalad.com/wiki/how_to_create_a_minimap
  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    Good Job Toby. You even followed the "format" I have for the wiki.
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    This looks really cool! Any idea how I could create a mini map that showed my character and the spawned enemy actors. Is there a way to have each enemy create a dot on the mini map?
  • TobyToby Member Posts: 478
    Just use the same process, just define game X&Y attributes for each enemy and the process is the same. You can have a dot for anything and multiple items as long as you define an XY.
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    my enemy spawner creates copies of the same enemy. I guess I am unsure as to how to make a dot appear when the enemy is spawned. Especially considering that a scrollable layered actor cannot spawn a non-scrollable actor (according to an earlier forum thread) and the map would be on a non-scrollable HUD layer.
  • TobyToby Member Posts: 478
    Maybe don't spawn anything, just keep a few dots just off the stage on a non scrolling layer. That should do the trick. Assume you have a limit on the number of spawned enemy?
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    sounds like a good plan, but how do I assign each spawned enemy to its own distinct dot on the mini map?
  • TobyToby Member Posts: 478
    Well the objects you're spawning is really just another actor with it's own set of behaviors. If you have a maximum of 5 spawning enemies you could create 5 sets of game.attributes (X & Y) with unique names Enemy1, Enemy2......... Enemy5

    Then dynamically assign each attribute 1>5 as they appear.

    You would need to work out some checking process to see what game.attributes were available as a spawned enemy actor is created. Eg: 1,2,4,5 being used, assign 3.

    The enemy would obviously have the constrain X & Y applied with the offset.

    OR you could......

    Just duplicate your enemy actor 5 times in the actor library.

    Add unique names, then apply the unique XY game.attributes.

    Apply the constrains behaviors and have your spawning actor spawn all 5 enemy actors.

    There's probably an easier way, all I can think of at the moment - perhaps Codemonkey or someone can make a suggestion?
  • JGary321JGary321 Member Posts: 1,246
    I do something similar for HP bars in my game. This is the easiest way. In the actor Constrain the units X/Y to a game.attribute. Then Spawn Actor Map Dot.

    That way when your enemy is created it constrains the X/Y & spawns the dot.

    Under the dot Constrain X/Y to your mob actor 1/4, like they say above.

    I found out that you only need 1 game.attribute to keep track of the X/Y of ALL instances of any mob. I used to create an X/Y of every mob type. But you don't need to. So even if you create multiple instances it will still constrain it to each instance.

    -JGary
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    JGary321,

    Can the spawned "Actor Map Dot" be on the HUD if the enemy is not on the HUD?
  • JGary321JGary321 Member Posts: 1,246
    Ya 'mon! I can write it up in a few hours. At work now. I "think" it will work. Basic idea is you have a scrollable mob spawner, so your mobs scroll. Have a non scrollable map dot spawner. When the mob spawns you need a message to go to the map dot spawner to spawn a dot also. Can be done using game attributes. Or keep in mind that 1 actor instance CAN directly affect another actor instance. So you could just have it change an attribute on the map dot spawner itself. This should lead you in the right direction. Should work in theory.
  • quantumsheepquantumsheep Member Posts: 8,188
    I actually made a working 'radar' for a game a few months ago - think 'Defender'.

    I was well chuffed when it worked first time as intended!

    I'll try and dig it up and share!

    QS :)

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: https://quantumsheep.itch.io

  • quantumsheepquantumsheep Member Posts: 8,188
    Ok, so this is an old post, but I'm having a problem with my radar.

    It works fine, as detailed here: http://gamesalad.com/wiki/how_tos:create_a_minimap

    The issue is that as well as showing the player dot on the radar, a second 'flashing dot' appears on the main screen.

    As far as I can tell it looks like the player dot is trying to appear at the player's X/Y coords *as well as* where I've told it to on the radar...

    Is this a glitch, perhaps???

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: https://quantumsheep.itch.io

  • JGary321JGary321 Member Posts: 1,246
    Didn't they change the way constrain's work? I thought they change Constrains (in .80 patch) so they don't work on offsets anymore. I could be wrong though.
  • quantumsheepquantumsheep Member Posts: 8,188
    Do you know how they *do* work, mate?

    Cheers,

    QS :D

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: https://quantumsheep.itch.io

Sign In or Register to comment.