Hi,
I have created a library that allows you to use geoJSON file (OSM XML to be implemented soon) and draw a map based on this.
Currently, only roads/streets/sidewalks/bridges (OSM type 'highways') are supported, but implementation of others is easy and will be coming. Custom rules can be defined regarding what to draw, what colors to use and parameters passed to draw only selected region based on lat/long coordinates or zoom to be used etc.
You can use it for backgrounds or e.g. drawing a map somewhere as a part of the game - picture on a wall, map on a table etc.
I am resolving some issues with the canvas caching, once it's ready, I'll publish it to github and link it here.
Screenshot of simplified map (b&w only, basic rules defined):
osmlove library (OSM maps in your Love2D projects)
osmlove library (OSM maps in your Love2D projects)
My boat driving game demo: https://dusoft.itch.io/captain-bradley- ... itius-demo
Re: osmlove library (OSM maps in your Love2D projects)
Cool! Looking forward to seeing where this goes.
- zorg
- Party member
- Posts: 3465
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: osmlove library (OSM maps in your Love2D projects)
I'm pretty sure i could use this data to generate the actual game world based on this, if i wanted to; without height-map information, of course.
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Re: osmlove library (OSM maps in your Love2D projects)
Indeed, creating worlds based on this was my goal (creating street network for transport game) - that's basically, why I have decided to develop this.
My boat driving game demo: https://dusoft.itch.io/captain-bradley- ... itius-demo
Re: osmlove library (OSM maps in your Love2D projects)
Can it create a simple political map of a region? It would be cool to be able to select individual countries, states, provinces, etc. Could be so many possibilities
-
- Party member
- Posts: 107
- Joined: Wed Oct 15, 2014 5:00 pm
- Location: Yorkshire, England
Re: osmlove library (OSM maps in your Love2D projects)
This is incredibly cool, I had no idea I wanted this until I saw it and now I can't stop thinking about what I could make with it. Good job.
Code: Select all
if not wearTheseGlasses() then
chewing_on_trashcan = true
end
Re: osmlove library (OSM maps in your Love2D projects)
Indeed, it can draw anything based on the preset rules. However, as of now only rules for "highway" type of "ways" are supported.
See for OSM element details: https://wiki.openstreetmap.org/wiki/Elements
My boat driving game demo: https://dusoft.itch.io/captain-bradley- ... itius-demo
Re: osmlove library (OSM maps in your Love2D projects)
Enjoy early alpha (v0.1):
https://github.com/nekromoff/osmlove
https://github.com/nekromoff/osmlove
- Attachments
My boat driving game demo: https://dusoft.itch.io/captain-bradley- ... itius-demo
Re: osmlove library (OSM maps in your Love2D projects)
Please, send me your ideas on what to prioritize during development. What would you use this in your games for?
Generating worlds based on maps? If yes, is data table with existing structures (roads, rivers etc.) useful for you?
Drawing maps in-game? If yes, what further options you need for drawing?
Etc.
Any feedback welcome!
Generating worlds based on maps? If yes, is data table with existing structures (roads, rivers etc.) useful for you?
Drawing maps in-game? If yes, what further options you need for drawing?
Etc.
Any feedback welcome!
My boat driving game demo: https://dusoft.itch.io/captain-bradley- ... itius-demo
- zorg
- Party member
- Posts: 3465
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: osmlove library (OSM maps in your Love2D projects)
A questions:
The init function has a few parameters, but it's somewhat unclear what they really do.
The file is of course self-explanatory, the region limits are there, i assume, because one might download a bigger map, and may only want part of it to be used in-game at a time, for example.
The width and height will be the canvas properities, i suppose.
So, if you define the usable area in terms of the input area, and the usable area in terms of the output graphic, what does the zoom parameter do? Or rather, which other parameter(s) will it modify?
A few ideas:
- Make the library be stateless, in the sense that currently, you require the lib once, and it stores one map you load; it can't create more than one at a time. Here's an interesting read on the subject: http://kiki.to/blog/2014/04/11/rule-4-m ... s-modules/
- Since this is for Löve, i'd prioritize rewriting lua io functions into love.filesystem ones.
- _setupMap resets the active canvas to the screen at its end; you don't know what someone may have set it before calling this function, so you should either store that info in the function with the similarly named getter, and set it back to that at the end of the function, or use love.graphics.push('all'), since that also stores the active canvas, i believe (with that parameter).
- Have a separate function for setting the (coloring) rules, and not do it per-frame with osmlove.drawMap
- Also don't force the alpha+premultiplied drawmode on people; maybe mention it that it should be used.
- This one's a tiny nitpick, but maybe just have the above function be named draw? it would be shorter and more consistent with Löve's API.
- (Similarly, init -> load, though if it's not exposed, it doesn't matter.)
The init function has a few parameters, but it's somewhat unclear what they really do.
The file is of course self-explanatory, the region limits are there, i assume, because one might download a bigger map, and may only want part of it to be used in-game at a time, for example.
The width and height will be the canvas properities, i suppose.
So, if you define the usable area in terms of the input area, and the usable area in terms of the output graphic, what does the zoom parameter do? Or rather, which other parameter(s) will it modify?
A few ideas:
- Make the library be stateless, in the sense that currently, you require the lib once, and it stores one map you load; it can't create more than one at a time. Here's an interesting read on the subject: http://kiki.to/blog/2014/04/11/rule-4-m ... s-modules/
- Since this is for Löve, i'd prioritize rewriting lua io functions into love.filesystem ones.
- _setupMap resets the active canvas to the screen at its end; you don't know what someone may have set it before calling this function, so you should either store that info in the function with the similarly named getter, and set it back to that at the end of the function, or use love.graphics.push('all'), since that also stores the active canvas, i believe (with that parameter).
- Have a separate function for setting the (coloring) rules, and not do it per-frame with osmlove.drawMap
- Also don't force the alpha+premultiplied drawmode on people; maybe mention it that it should be used.
- This one's a tiny nitpick, but maybe just have the above function be named draw? it would be shorter and more consistent with Löve's API.
- (Similarly, init -> load, though if it's not exposed, it doesn't matter.)
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Who is online
Users browsing this forum: Amazon [Bot] and 4 guests