SVG in the development of games for drawing maps with moving maps

I plan to draw a “map” (cities, rivers, roads, etc.) using svg. Thus, the ALL object will be displayed in one svg image, and only visible areas of visibility will be displayed.

Question 1:

Is this a smart approach? Or would I be better off which specific objects need to be drawn?

One of the features that I want to realize is to drag the map. It is planned to work as follows: the mouse cursor is a mouse point somewhere inside the map, click the mouse button and move the mouse. Thus, some objects will go out of scope, while others will be drawn.

Question 2:

Is it better to change the coordinates of the visible object in order to shift them in accordance with the movement of the mouse? Or is it better to change the "visible area" (suppose it should be possible by processing the parameters of the svg object of the viewbox)?

Thanks a lot! Any ideas are welcome!

+4
source share
3 answers

Sounds a bit like polymaps to me. If you intend to serve a huge svg core document, it is preferable to use the tiled policies approach.

+3
source

I'm not a professional in any way and not a very good programmer, but I used to work with svg cards, and I think this is a reasonable approach, svg can store a lot of data, and if you have good rendering, you should be able to keep up . As for question 2, I would say that you change the viewport, otherwise you will find that you change the coordinates of each svg object, many people have made a pan code for the svg image, so do a quick search on Google and this should help you.

0
source

The best approach will greatly depend on how big and complex your single SVG is.

You might want to create a quick experiment with a larger and more complex sample mapping earlier than later, and adjust it for easy panning (you can try svgpan before spending time creating your own). This does not have to be a fully consistent map - you could repeat a bunch of representative forms and still get a good test case.

If your swatch map moves smoothly in the browsers you care about, you can avoid the complexity of the tile (or display parts of the whole otherwise).

If you find it sluggish and slow, @Erik Dahlstrom's Polymaps search suggestion will be the next place to search (but this is due to much more server side work, so it would be nice to avoid).

0
source

All Articles