Re: logic for creating maps in python
So I thought I'd write you a little example to explain making a map file and a parser, then I realised that making parsers are a bitch.
There's probably a few reasons to avoid parsers, but the main is validation.
Say you create your map like @4 suggests, so you give each tile a numerical value. That's fine, but what if the map creator puts spaces between the characters? What if they type a letter instead of a number? or their number is out of range? What if they don't fill out the entire map? Do you fill the extra space with a "default" tile? Do you allow the map creator to specify the default?
Better to make something like a command line (or GUI) based map editor, then dump the created maps using a language like YAML, or JSON.
Then you can ignore validation errors, because if the person who created the map decides to fart about with the resulting map file, it's their loss when your program breaks.
I've included a MAP file created with my own fledgling editor. As I'm sure you'll agree, it's quite complex, and not something you'd want to code by hand. That said, maps are complicated. If they're not, then they're simplistic. I'd wager that many of the best people for map creating are some of the worst for coding. Give them a lovely easy to use editor, and you'll be laughing.
maps:
- ambiances:
- sound: ambience\Lake.wav
x: 0
y: 0
z: 0
default_surface_id: G7as96Ymnv3GczoWYaDBg5
directions_2d:
- north
- north-east
- east
- south-east
- south
- south-west
- west
- north-west
footstep_length: 0.5
id: GQsnkuaqDQyZaNSphBVeAz
max_x: 200
max_y: 200
start_facing: 0
start_x: 0
start_y: 0
terrains:
- end_x: 5
end_y: 5
start_x: 0
start_y: 0
surface_id: 6oFmgzkuYRAyrBc9HSXbfo
title: narrow path
- end_x: 2
end_y: 2
start_x: 2
start_y: 2
surface_id: WRi82wWTpTmofhJgExnW9U
title: stone plaque
title: Darkrise Forest
turn_amount: 45
wall_sound: wall.wav
- ambiances: []
default_surface_id: 6oFmgzkuYRAyrBc9HSXbfo
directions_2d:
- north
- north-east
- east
- south-east
- south
- south-west
- west
- north-west
footstep_length: 0.5
id: grQdN4HHzZrnoCf8aCyzUt
max_x: 200
max_y: 200
start_facing: 0
start_x: 0
start_y: 0
terrains: []
title: Darkrise Village
turn_amount: 45
wall_sound: null
surfaces:
- footstep_sounds:
- Surfaces\catwalk\Station1.wav
- Surfaces\catwalk\Station2.wav
- Surfaces\catwalk\Station3.wav
- Surfaces\catwalk\Station4.wav
- Surfaces\catwalk\Station5.wav
- Surfaces\catwalk\Station6.wav
- Surfaces\catwalk\Station7.wav
- Surfaces\catwalk\Station8.wav
id: CAndNXQagb39XMoTJUHtdP
title: Catwalk
- footstep_sounds:
- Surfaces\concrete\Room1.wav
- Surfaces\concrete\room2.wav
- Surfaces\concrete\room3.wav
- Surfaces\concrete\Room4.wav
id: 6oFmgzkuYRAyrBc9HSXbfo
title: Concrete
- footstep_sounds:
- Surfaces\duct\Duct1.wav
- Surfaces\duct\Duct2.wav
- Surfaces\duct\Duct3.wav
- Surfaces\duct\Duct4.wav
- Surfaces\duct\Duct5.wav
- Surfaces\duct\Duct6.wav
- Surfaces\duct\Duct7.wav
id: Le52wgjqrWr8Usq3N7ekKb
title: Duct
- footstep_sounds:
- Surfaces\grass\Grass1.wav
- Surfaces\grass\Grass2.wav
- Surfaces\grass\Grass3.wav
- Surfaces\grass\Grass4.wav
- Surfaces\grass\Grass5.wav
- Surfaces\grass\Grass6.wav
- Surfaces\grass\Grass7.wav
- Surfaces\grass\Grass8.wav
id: G7as96Ymnv3GczoWYaDBg5
title: Grass
- footstep_sounds:
- Surfaces\gridwork\Ship1.wav
- Surfaces\gridwork\Ship2.wav
- Surfaces\gridwork\Ship3.wav
- Surfaces\gridwork\Ship4.wav
- Surfaces\gridwork\Ship5.wav
- Surfaces\gridwork\Ship6.wav
- Surfaces\gridwork\Ship7.wav
- Surfaces\gridwork\Ship8.wav
id: ZRhdNKbjyeVtoz4crS7U3W
title: Gridwork
- footstep_sounds:
- Surfaces\grit\Grit1.wav
- Surfaces\grit\Grit2.wav
- Surfaces\grit\Grit3.wav
- Surfaces\grit\Grit4.wav
- Surfaces\grit\Grit5.wav
- Surfaces\grit\Grit6.wav
- Surfaces\grit\Grit7.wav
- Surfaces\grit\Grit8.wav
id: WRi82wWTpTmofhJgExnW9U
title: Grit
- footstep_sounds:
- Surfaces\mud\Mud1.wav
- Surfaces\mud\Mud2.wav
- Surfaces\mud\Mud3.wav
- Surfaces\mud\Mud4.wav
- Surfaces\mud\Mud5.wav
- Surfaces\mud\Mud6.wav
- Surfaces\mud\Mud7.wav
- Surfaces\mud\Mud8.wav
id: CHMucvz9w2XCfP46mhcH9F
title: Mud
- footstep_sounds:
- Surfaces\sand\Sand1.wav
- Surfaces\sand\Sand2.wav
- Surfaces\sand\Sand3.wav
- Surfaces\sand\Sand4.wav
- Surfaces\sand\Sand5.wav
- Surfaces\sand\Sand6.wav
- Surfaces\sand\Sand7.wav
- Surfaces\sand\Sand8.wav
id: HBDBgnq9TJikXdG8Aa6xWk
title: Sand
- footstep_sounds:
- Surfaces\water\Water1.wav
- Surfaces\water\Water2.wav
- Surfaces\water\Water3.wav
- Surfaces\water\Water4.wav
id: bRD7uk6MWMG3keqAZQSwKv
title: Water
title: Darkrise
-- Audiogames-reflector mailing list Audiogames-reflector@sabahattin-gucukoglu.com https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector