metaloph1l / pacman

2 stars 1 forks source link

Map creation logic #8

Closed lanoxx closed 9 years ago

lanoxx commented 12 years ago

We still need a logic to create the game field in a sensible way. That is either we write a simple but reasonable algorithm to randomly create game fields. Or we need a way to store and load game fields from a map file.

I think a map generator would probably be overkill for this task, so I would suggest we use a way to load the map from a file. We could for example save a simple text file with the field coorinate and field type.

spookyTU commented 12 years ago

I agree, it is probably easier to just have pre-defined maps and load them for each game. The way you suggested is probably enough for this purpose. We could use a simple text field where each row represents one field row of the game. The coordinates would then result out of the position in the text file. Something like this:

- - - - - | . . . | | . . . | | - - - |

Each row has several columns and each character represents a specific type (vertical wall, horizontal wall, empty field, T wall, corner...). In this case we could also match each character to a tile...

We could also use a more structured approach (XML or something similar) but I think in our case we don't need it. I can target this issue (as soon as we agree on a representation (XML, Text...))

lanoxx commented 12 years ago

I vote for text representation. That makes it very easy to parse and update by hand.

But I would not encode characters like | (pipe) and _ etc. instead maybe something like space separated characters:

W D W D D D W D D D W D W D W W D D D D W D D W

Where newline is a new row and space a new column. Then the parser just needs to split by space and iterate over the items.

Sebastian Geiger

On 24.03.2012, at 18:11, spookyTU reply@reply.github.com wrote:

I agree, it is probably easier to just have pre-defined maps and load them for each game. The way you suggested it is probably enough for this purpose. We could use a simple text field where each row represents one field row of the game. The coordinates would then result out of the position in the text file. Something like this:

- - - - - | . . . | | . . . | | - - - |

We could also use a more structured approach (XML or something similar) but I think in our case we don't need it. I can target this issue (as soon as we agree on a representation (XML, Text...))


Reply to this email directly or view it on GitHub: https://github.com/metaloph1l/pacman/issues/8#issuecomment-4674968

spookyTU commented 12 years ago

yes, that was the idea. The representation was just an idea (I thought about making it easier to create the model in a file), but you are right. It is probably better and more understandable with just characters (after the parsing is in place, changing characters shouldn't be a problem).

lanoxx commented 12 years ago

Ah ok I see, so we actually meant the same. Could you write the parser and map loader then?

spookyTU commented 12 years ago

yes, I'll handle this task

metaloph1l commented 12 years ago

Yesterday I defined a simple factory method with an integer parameter, that should generate a labyrinth. Imo you can hardcode 3 maps into the factory and assign numbers to them. When the factory method is used, a new labyrinth of the given id is generated and returned.

Its in the domain branch. You can create a new branch out of the domain branch and write the necessary methods there.

lanoxx commented 12 years ago

Sorry I have accidentally deleted the domain branch when i was uploading something. Can you please push it again?