How can I make a Map Editor?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
How can I make a Map Editor?
I seem to be struggling on this one, I don't know how to make a Map Editor for my game D: anyone can give me some useful tips/help so I can make this?
Code: Select all
fun = true
school = true
function isItFun()
if school then
fun = false
end
if not fun then
me:explode()
end
end
Re: How can I make a Map Editor?
You'll have to be more specific. How you implement a map editor can vary depending on the game. It would also help if we knew what exactly you're struggling with.
Re: How can I make a Map Editor?
Well, my game is a tower defense game, the things I'm having problems with is:
1. Grid map
2. Loading a tile map
3. Saving the map
1. Grid map
2. Loading a tile map
3. Saving the map
Code: Select all
fun = true
school = true
function isItFun()
if school then
fun = false
end
if not fun then
me:explode()
end
end
-
- Citizen
- Posts: 51
- Joined: Mon Apr 15, 2013 8:21 pm
- Contact:
Re: How can I make a Map Editor?
Saving and loading can be very easy, I'd recommend using something like TSerial, basically what this does is converts a table into a string, which you can then save to a .lua file, and then you can directly require that file where you need it and access the data just like any other Lua table.louie999 wrote:Well, my game is a tower defense game, the things I'm having problems with is:
1. Grid map
2. Loading a tile map
3. Saving the map
irc.freenode.org ##oodnet
http://exez.in/
http://exez.in/
Re: How can I make a Map Editor?
I'm gonna beat Robin to the punch and recommend Ser instead of TSerial
GitHub | MLib - Math and shape intersections library | Walt - Animation library | Brady - Camera library with parallax scrolling | Vim-love-docs - Help files and syntax coloring for Vim
Re: How can I make a Map Editor?
Ok I'll try TSerial and Ser and see which suits my needs better, though I have a new problem, how can I detect which "tile" the mouse is on, not the x/y but the tile, as the map editor I'm planning to make is gonna have a tilemap..
Code: Select all
fun = true
school = true
function isItFun()
if school then
fun = false
end
if not fun then
me:explode()
end
end
- DeltaF1
- Citizen
- Posts: 64
- Joined: Mon Apr 27, 2015 4:12 pm
- Location: The Bottom of the Stack
- Contact:
Re: How can I make a Map Editor?
To convert from screen x/y to map x/y coordinates, you need to divide the screen coordinates by your gridSize. For example, if your grid size is 64 pixels, then you could do thislouie999 wrote:how can I detect which "tile" the mouse is on, not the x/y but the tile, as the map editor I'm planning to make is gonna have a tilemap..
Code: Select all
gridSize = 64
x = love.mouse.getX()
y = love.mouse.getY()
tileX = math.floor(x / gridSize) --"math.floor to round decimal answers down, so 2.11462 becomes 2 etc"
tileY = math.floor(y / gridSize)
tile = map[tileX][tileY] --"or map[tileY][tileX], depending on how your map is constructed"
doSomethingWithTheTile(tile)
Re: How can I make a Map Editor?
If your fine with not making a custom editor, I recommend using Tiled http://www.mapeditor.org/. It can be overly general, but it is a very good tool that exports to lua.
If you still want to make your own editor, I have a library, Editgrid https://github.com/bakpakin/Editgrid, that was made for level editors and the like. It helps for drawing fancy grids and is compatible with a couple of camera libraries.It also will autodetect the "tile" the mouse is on.
If you still want to make your own editor, I have a library, Editgrid https://github.com/bakpakin/Editgrid, that was made for level editors and the like. It helps for drawing fancy grids and is compatible with a couple of camera libraries.It also will autodetect the "tile" the mouse is on.
((_((_CRAYOLA_((_((_> GitHub <_((_((_CRAYOLA_((_(()
Re: How can I make a Map Editor?
Thanks dudeDeltaF1 wrote:To convert from screen x/y to map x/y coordinates, you need to divide the screen coordinates by your gridSize. For example, if your grid size is 64 pixels, then you could do thislouie999 wrote:how can I detect which "tile" the mouse is on, not the x/y but the tile, as the map editor I'm planning to make is gonna have a tilemap..(unrelated. Is there something wrong with comments in the code highlighter?Code: Select all
gridSize = 64 x = love.mouse.getX() y = love.mouse.getY() tileX = math.floor(x / gridSize) --"math.floor to round decimal answers down, so 2.11462 becomes 2 etc" tileY = math.floor(y / gridSize) tile = map[tileX][tileY] --"or map[tileY][tileX], depending on how your map is constructed" doSomethingWithTheTile(tile)
@bakpakin Ok, I'll give it a try.
Code: Select all
fun = true
school = true
function isItFun()
if school then
fun = false
end
if not fun then
me:explode()
end
end
Who is online
Users browsing this forum: Google [Bot] and 214 guests