-- The Tomb -- the Enigma Level -- (c) 2002 Petr Machata/ant_39 -- Licensed under GPL v2.0 or above -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- function cell_item(it) local n_it = {} n_it.face = (it.face or "") n_it.attr = (it.attr or {}) return n_it end function cell(structure) local cell = {} cell.tag = (structure.tag or "?") cell.setactor = structure.setactor cell.floor = cell_item(structure.floor or {}) cell.stone = cell_item(structure.stone or {}) cell.item = cell_item(structure.item or {}) return function(x, y) --call parents if (%structure.parent) then for i,parfun in %structure.parent do parfun(x,y) end end --map elements if (%structure.stone) then set_stone(%cell.stone.face, x, y, %cell.stone.attr) end if (%structure.floor) then set_floor(%cell.floor.face, x, y, %cell.floor.attr) end if (%structure.item) then if (%structure.item.actor) then set_actor(%cell.item.face, x+0.5, y+0.5, %cell.item.attr) else set_item(%cell.item.face, x, y, %cell.item.attr) end end end end cells={} cells[" "]=cell{floor={face="fl-sand"}} cells["."]=cell{} cells["#"]=cell{parent={cells[" "]},stone={face="st-greenbrown"}} cells["x"]=cell{parent={cells[" "]},stone={face="st-grate1"}} cells["@"]=cell{parent={cells[" "]},stone={face="st-wood"}} cells["O"]=cell{parent={cells[" "]},item={face="ac-blackball", attr={player=0}, actor=1}} cells["+"]=cell{parent={cells[" "]},stone={face="st-puzzle", attr={connections=PUZ_0000}}} cells["|"]=cell{parent={cells[" "]},stone={face="st-puzzle", attr={connections=PUZ_0101}}} cells[","]=cell{parent={cells[" "]},stone={face="st-puzzle", attr={connections=PUZ_0001}}} cells["'"]=cell{parent={cells[" "]},stone={face="st-puzzle", attr={connections=PUZ_0100}}} cells["A"]=cell{parent={cells[" "]},stone={face="st-door", attr={name="doorA", type="v"}}} cells["B"]=cell{parent={cells[" "]},stone={face="st-door", attr={name="doorB", type="h"}}} cells["C"]=cell{parent={cells[" "]},stone={face="st-door", attr={name="doorC", type="h"}}} cells["D"]=cell{parent={cells[" "]},stone={face="st-door", attr={name="doorD", type="v"}}} cells["E"]=cell{parent={cells[" "]},stone={face="st-door", attr={name="doorE", type="h"}}} cells["F"]=cell{parent={cells[" "]},stone={face="st-door", attr={name="doorF", type="v"}}} cells["a"]=cell{parent={cells[" "]},item={face="it-trigger", attr={action="openclose", target="doorA"}}} cells["b"]=cell{parent={cells[" "]},item={face="it-trigger", attr={action="openclose", target="doorB"}}} cells["c"]=cell{parent={cells[" "]},item={face="it-trigger", attr={action="openclose", target="doorC"}}} cells["d"]=cell{parent={cells[" "]},item={face="it-trigger", attr={action="openclose", target="doorD"}}} cells["e"]=cell{parent={cells[" "]},item={face="it-trigger", attr={action="openclose", target="doorE"}}} cells["f"]=cell{parent={cells[" "]},item={face="it-trigger", attr={action="openclose", target="doorF"}}} cells["1"]=cell{parent={cells[" "]},stone={face="st-oxyd", attr={flavor="b", color="1"}}} cells["2"]=cell{parent={cells[" "]},stone={face="st-oxyd", attr={flavor="b", color="2"}}} cells["3"]=cell{parent={cells[" "]},stone={face="st-oxyd", attr={flavor="b", color="3"}}} enigma1 = { ".#######.", ".# e@ ##", ".# O # #", "## ## #", "#xx#xx# #", "#x x# #", "## #c##D#", "#a x # #", "## # #' #", "## @ | #", "#x@b## #", "#x x# | #", "### B #", "..#A##.##", "..# | #.", "..# #+ #.", "..# ## #.", "..# #+#.", "#### Cd#.", "# ###,#.", "#@ E #.", "# @@# #.", "# @@ ###.", "#@@ @ #.", "# #.", "#......#.", "#......#.", "#112233#.", "########." } function draw_map(x0, y0, map) for y,str in map do for x = 1,strlen(str) do cell = strchar(strbyte(str,x)) cells[cell](y+y0-1, x+x0-1) end end end -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- levelw = 20+19 levelh = 13 create_world(levelw, levelh) fill_floor("fl-abyss", 0, 0, level_width, level_height) draw_map(2, 0, enigma1) oxyd_shuffle() display.SetFollowMode(display.FOLLOW_SCROLLING)