Page 1 of 2
Minimap
Posted: Wed May 30, 2012 6:15 pm
by Petunien
Hi,
I wonder how to make a minimap, just of curiosity.
In my theorie, all we have to do is to "capture" the objects on the screen, scale them and draw them again in a little rectangle in the lower left corner or so.
Or how would that go?
Re: Minimap
Posted: Wed May 30, 2012 6:21 pm
by Robin
You could do that, but isn't a mini map usually more symbolic than that? For example, drawing a little blue square instead of a fully drawn guy?
I think you're better off drawing your mini map separately.
Re: Minimap
Posted: Wed May 30, 2012 6:30 pm
by Petunien
Oh, yes, I forgot.
You're right, of course.
But how would go my method? I'm interested in it.
Re: Minimap
Posted: Wed May 30, 2012 6:38 pm
by Roland_Yonaba
Robin wrote:You could do that, but isn't a mini map usually more symbolic than that? For example, drawing a little blue square instead of a fully drawn guy?
I think you're better off drawing your mini map separately.
Lol, obviously.
@Petunien:
I remember the old days, while I was working on a
RTS.
I paused the project, since I was missing spare time. I might eventually be back on it.
Take a look
inside the last attachment, there is a fully working example of minimap (look inside
Scripts/map.lua file).
Hope that will help.
Re: Minimap
Posted: Wed May 30, 2012 6:44 pm
by coffee
Petunien wrote:Oh, yes, I forgot.
You're right, of course.
But how would go my method? I'm interested in it.
There are several ways to do it.
If mini-map is really only resize of "realmap" you should use same code as used in big map of course.
If as Robin suggest you replace graphic tile for other more geometric thing you could do another separate piece of code.
I personally would prefer use same piece of code and make an internal switch to display whatever I wanted with for example map:draw("normal") or even only map:draw() and map:draw("mini").
Re: Minimap
Posted: Wed May 30, 2012 6:53 pm
by Roland_Yonaba
coffee wrote:Petunien wrote:Oh, yes, I forgot.
I personally would prefer use same piece of code and make an internal switch to display whatever I wanted with for example map:draw("normal") or even only map:draw() and map:draw("mini").
Good point. Thumbs up!
Re: Minimap
Posted: Thu May 31, 2012 2:09 am
by ljdp
coffee wrote:
There are several ways to do it.
If mini-map is really only resize of "realmap" you should use same code as used in big map of course.
If as Robin suggest you replace graphic tile for other more geometric thing you could do another separate piece of code.
I personally would prefer use same piece of code and make an internal switch to display whatever I wanted with for example map:draw("normal") or even only map:draw() and map:draw("mini").
I'd be wary of this approach. Yes you could use love.graphics.translate and love.graphics.scale to redraw the map, but you're drawing everything twice which could be slow unless you have some checks in place to see if in object is outside of the minimap's view rectangle.
I would prefer having two classes for each renderable object, say TankRenderer and TankMinimapRenderer then you would have MapRenderer and MinimapRenderer
Code: Select all
mapRenderer:render()
minimapRenderer:render()
Then your code becomes easier if you want to change your minimap rendering logic later on.
Re: Minimap
Posted: Thu May 31, 2012 7:15 am
by bartbes
If you really do a full-detail minimap, you're probably best off drawing to a canvas, then scaling that down for the minimap.
Re: Minimap
Posted: Thu May 31, 2012 9:44 am
by Lafolie
bartbes wrote:If you really do a full-detail minimap, you're probably best off drawing to a canvas, then scaling that down for the minimap.
Oppositely, if you are making something with less fidelity you can just read the map data and display it using smaller graphics and then scale the movements any 'markers' such as unit positions for display on the map. Kind of like rendering parts of the game a second time, but much smaller.
Re: Minimap
Posted: Thu May 31, 2012 3:26 pm
by Petunien
Hello hello again,
thank you all for the answers, very useful!
@Roland_Yonaba
I'll have a look on it. Thank you. Why do you not update your game to 0.8.0, so it's playable?
Much work?
Regarding the minimap.
I made one in the scale 1:5.
Ok, basically you can place 20px rectangles and they will be drawn also in the minimap in the lower left corner.
My question: Is there a better way (more "efficient", smaller, future-proof...) to do that, what I did in the attached *.love?
Thank you again.