Page 1 of 1

Convert text file to map wall

Posted: Sat May 27, 2017 5:24 pm
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!

Re: Convert text file to map wall

Posted: Sat May 27, 2017 9:35 pm
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.