Automated tile map creation?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
ntpspe
Prole
Posts: 31
Joined: Sun Aug 07, 2011 6:19 pm

Automated tile map creation?

Post by ntpspe »

Hey everyone, it's me again :emo:
So, I've managed to successfully make the random map generator, which makes variables ma[1-21]-mt[1-21] so I've got a 21w 20h map.

That's all presented on screen using love.draw, which is all fine - That's automated and the least of my worries. My worry is this:

Code: Select all

   map={
   { ma[1], ma[2], ma[3], ma[4], ma[5], ma[6], ma[7], ma[8], ma[9], ma[10], ma[11], ma[12], ma[13], ma[14], ma[15], ma[16], ma[17], ma[18], ma[19], ma[20], ma[21]}, 
   { mb[1], mb[2], mb[3], mb[4], mb[5], mb[6], mb[7], mb[8], mb[9], mb[10], mb[11], mb[12], mb[13], mb[14], mb[15], mb[16], mb[17], mb[18], mb[19], mb[20], mb[21]},
   { mc[1], mc[2], mc[3], mc[4], mc[5], mc[6], mc[7], mc[8], mc[9], mc[10], mc[11], mc[12], mc[13], mc[14], mc[15], mc[16], mc[17], mc[18], mc[19], mc[20], mc[21]},
   { md[1], md[2], md[3], md[4], md[5], md[6], md[7], md[8], md[9], md[10], md[11], md[12], md[13], md[14], md[15], md[16], md[17], md[18], md[19], md[20], md[21]},
   { me[1], me[2], me[3], me[4], me[5], me[6], me[7], me[8], me[9], me[10], me[11], me[12], me[13], me[14], me[15], me[16], me[17], me[18], me[19], me[20], me[21]},
   { mf[1], mf[2], mf[3], mf[4], mf[5], mf[6], mf[7], mf[8], mf[9], mf[10], mf[11], mf[12], mf[13], mf[14], mf[15], mf[16], mf[17], mf[18], mf[19], mf[20], mf[21]},
   { mg[1], mg[2], mg[3], mg[4], mg[5], mg[6], mg[7], mg[8], mg[9], mg[10], mg[11], mg[12], mg[13], mg[14], mg[15], mf[16], mg[17], mg[18], mg[19], mg[20], mg[21]},
   { mh[1], mg[2], mh[3], mh[4], mh[5], mh[6], mh[7], mh[8], mh[9], mh[10], mh[11], mh[12], mh[13], mh[14], mh[15], mh[16], mh[17], mh[18], mh[19], mh[20], mh[21]},
   { mi[1], mi[2], mi[3], mi[4], mi[5], mi[6], mi[7], mi[8], mi[9], mi[10], mi[11], mi[12], mi[13], mi[14], mi[15], mi[16], mi[17], mi[18], mi[19], mi[20], mi[21]},
   { mj[1], mj[2], mj[3], mj[4], mj[5], mj[6], mj[7], mj[8], mj[9], mj[10], mj[11], mj[12], mj[13], mj[14], mj[15], mj[16], mj[17], mj[18], mj[19], mj[20], mj[21]},
   { mk[1], mk[2], mk[3], mk[4], mk[5], mk[6], mk[7], mk[8], mk[9], mk[10], mk[11], mk[12], mk[13], mk[14], mk[15], mk[16], mk[17], mk[18], mk[19], mk[20], mk[21]},
   { ml[1], ml[2], ml[3], ml[4], ml[5], ml[6], ml[7], ml[8], ml[9], ml[10], ml[11], ml[12], ml[13], ml[14], ml[15], ml[16], ml[17], ml[18], ml[19], ml[20], ml[21]},
   { mm[1], mm[2], mm[3], mm[4], mm[5], mm[6], mm[7], mm[8], mm[9], mm[10], mm[11], mm[12], mm[13], mm[14], mm[15], mm[16], mm[17], mm[18], mm[19], mm[20], mm[21]},
   { mn[1], mn[2], mn[3], mn[4], mn[5], mn[6], mn[7], mn[8], mn[9], mn[10], mn[11], mn[12], mn[13], mn[14], mn[15], mn[16], mn[17], mn[18], mn[19], mn[20], mn[21]},
   { mo[1], mo[2], mo[3], mo[4], mo[5], mo[6], mo[7], mo[8], mo[9], mo[10], mo[11], mo[12], mo[13], mo[14], mo[15], mo[16], mo[17], mo[18], mo[19], mo[20], mo[21]},
   { mp[1], mp[2], mp[3], mp[4], mp[5], mp[6], mp[7], mp[8], mp[9], mp[10], mp[11], mp[12], mp[13], mp[14], mp[15], mp[16], mp[17], mp[18], mp[19], mp[20], mp[21]},
   { mq[1], mq[2], mq[3], mq[4], mq[5], mq[6], mq[7], mq[8], mq[9], mq[10], mq[11], mq[12], mq[13], mq[14], mq[15], mq[16], mq[17], mq[18], mq[19], mq[20], mq[21]},
   { mr[1], mr[2], mr[3], mr[4], mr[5], mr[6], mr[7], mr[8], mr[9], mr[10], mr[11], mr[12], mr[13], mr[14], mr[15], mr[16], mr[17], mr[18], mr[19], mr[20], mr[21]},
   { ms[1], ms[2], ms[3], ms[4], ms[5], ms[6], ms[7], ms[8], ms[9], ms[10], ms[11], ms[12], ms[13], ms[14], ms[15], ms[16], ms[17], ms[18], ms[19], ms[20], ms[21]},
   { mt[1], mt[2], mt[3], mt[4], mt[5], mt[6], mt[7], mt[8], mt[9], mt[10], mt[11], mt[12], mt[13], mt[14], mt[15], mt[16], mt[17], mt[18], mt[19], mt[20], mt[21]},
}
Already due to it being so wide it's looking scruffy and hard to keep up with... but that's still not the problem.
The problem is... my map needs to be around 2000 wide (128000px) and around 1000 high.
Personally, I'm not so bothered about writing the 1000 different height variables, and the width one's are done automatically by calling them using they're number (e.g. ma[1], ma[2]).
That allows me to keep control over the generator, and adjust everything as nessesary.
But there is no way on this earth i'm writing from ma[1]...ma[2000] and all the way down to something like mzzzzzz[1]...mzzzzzz[2000].

now THAT is my problem.
If you need a better explanation please don't hesitate to ask (it's late at night/early morning so I probably don't make sense).
And if anybody can help me automate the map = {} table I will be so grateful... I may have to marry you ¬_¬

Cheers,

-NT

EDIT:
Perhaps I'm just not thinking tonight, but I think it may be somewhere along the lines of using a for statement to input them in, then the number variable can just start at 1 and +1 each time.
:L
err, like
for ma=1 do
table.insert(map,ma[n+1]))
end

O_o have I just answered my own question?

EDIT2: Nope that didn't work, but I think it's something along them lines I need. The ma[1] e.c.t. numbers are all automatically asigned, so i've no way to call that variable :/
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Automated tile map creation?

Post by Robin »

Code: Select all

for i=1,300 do -- how many did you want?
    local t = {}
    for n=1, do
        table.insert(t, ma[n]))
    end
    table.insert(map, t)
end
Don't code when you're tired. ;)
Help us help you: attach a .love.
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: Automated tile map creation?

Post by kikito »

When I write def I mean function.
User avatar
T-Bone
Inner party member
Posts: 1492
Joined: Thu Jun 09, 2011 9:03 am

Re: Automated tile map creation?

Post by T-Bone »

If you want it written to .lua files, you can do that too with love.filesystem.write. .lua-files written that way can be required.
User avatar
ntpspe
Prole
Posts: 31
Joined: Sun Aug 07, 2011 6:19 pm

Re: Automated tile map creation?

Post by ntpspe »

T-Bone wrote:If you want it written to .lua files, you can do that too with love.filesystem.write. .lua-files written that way can be required.
Hmm that might be incredibly useful, Instead of rendering a 2000 by 1000 map, I could do it in 'chunks' of 20x20 randomly generated tiles, patched together to make the end map.

Robin wrote:

Code: Select all

for i=1,300 do -- how many did you want?
    local t = {}
    for n=1, do
        table.insert(t, ma[n]))
    end
    table.insert(map, t)
end
Thanks, I'll give that a shot and do some fiddling to see the results :)
Robin wrote:Don't code when you're tired. ;)
I'm ALWAYS tired, I'm weird that way... tend to be more active during the night :P
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 11 guests