Convert text file to map wall

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
ByteStorm
Prole
Posts: 1
Joined: Sat May 27, 2017 5:06 pm

Convert text file to map wall

Post by ByteStorm »

Hi all.

I would like to learn how to convert text files in map walls, to build something like the classic Pacman. :)
I found some games written in Love2d/Lua, but I need a deeper explanation about how the conversion works,
Where can i find some step by step tutorials about that process? :o:

Thanks!
User avatar
zorg
Party member
Posts: 3441
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Convert text file to map wall

Post by zorg »

Hi and welcome to the forums!

Not sure where tutorials would be, but this in and of itself is not too hard of a problem.
You open a file, you read in contents, you iterate over contents and parse them however you want to. (there are multiple ways to read in a file though, and i'm not even going to talk about different encodings)

You have a text file with symbols that you previously agreed on what will function as what (wall, power pellet, normal pellet, spawn point, etc.), then you read in the file with love.filesystem.lines for example, and then go through each character, and build up the world in some form; usually you'd either want to put all "tiles" into one table, and use math to get the x and y coordinates, or use a table of tables (basically a "2D" table) for less math.

Everything else depends on the game implementation.
Me and my stuff :3True 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.
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 35 guests