home *** CD-ROM | disk | FTP | other *** search
/ GameStar Special 2004 August / GSSH0804.iso / Geschicklichkeit / Enigma / Enigma-081.exe / data / levels / ant16.lua < prev    next >
Text File  |  2003-02-21  |  2KB  |  82 lines

  1. -- Meditation -- the Enigma Level
  2. -- (c) 2003 Petr Machata/ant_39
  3. -- Licensed under GPL v2.0 or above
  4. -- 2003-01-11
  5. -- 2003-02-09 -- fixed originx/originy handling
  6.  
  7. dofile(enigma.FindDataFile("levels/ant.lua"))
  8. dofile(enigma.FindDataFile("levels/natmaze.lua"))
  9.  
  10. -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  11. -- i took these from Nat Pryce's natmaze.lua maps
  12. function cell_to_level( cellx, celly )
  13.     return originx + cellx * 2, originy + celly * 2
  14. end
  15.  
  16. function render_cell(maze, cellx, celly)
  17.     x,y = cell_to_level(cellx, celly)
  18.  
  19.     cells["w"](x, y)
  20.  
  21.     if maze:can_go_south(cellx,celly) then
  22.        cells["w"](x, y+1)
  23.     end
  24.  
  25.     if maze:can_go_east(cellx,celly) then
  26.        cells["w"](x+1, y)
  27.     end
  28.  end
  29.  
  30. -- to get the size of maze
  31. originx, originy = nil, nil
  32. mazew, mazeh = nil, nil
  33.  
  34. function get_limits(x,y)
  35.    originx = originx or x
  36.    originy = originy or y
  37.  
  38.    if (x>originx) then
  39.       mazew = ceil((x-originx+1)/2)
  40.    end
  41.  
  42.    if (y>originy) then
  43.       mazeh = ceil((y-originy+1)/2)
  44.    end
  45. end
  46.  
  47. -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  48. cells={}
  49.  
  50. cells[" "]=cell{floor="fl-bluegray"}
  51. cells["~"]=cell{floor="fl-water"}
  52. cells["w"]=cell{floor="fl-samba"}
  53. cells["#"]=cell{stone="st-rock1"}
  54.  
  55. cells["+"]=cell{item={"it-magnet", {on=TRUE}}}
  56.  
  57. cells["o"]=cell{parent=cells["+"],actor={"ac-whiteball-small", {player=0, mouseforce=1}}}
  58. cells["O"]=cell{item="it-hollow"}
  59. cells["Z"]=cell{{{get_limits}}}
  60.  
  61. level = {
  62.    "####################",
  63.    "#   Z~~~~~~~~~~~~  #",
  64.    "# o ~~~~~~~~~~~~~ O#",
  65.    "#   ~~~~~~~~~~~~~  #",
  66.    "#   ~~~~~~~~~~~~~  #",
  67.    "#   ~~~~~~~~~~~~~  #",
  68.    "# o ~~~~~~~~~~~~~ O#",
  69.    "#   ~~~~~~~~~~~~~  #",
  70.    "#   ~~~~~~~~~~~~~  #",
  71.    "#   ~~~~~~~~~~~~~  #",
  72.    "# o ~~~~~~~~~~~~~ O#",
  73.    "#   ~~~~~~~~~~~~Z  #",
  74.    "####################"
  75. }
  76.  
  77. -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  78. set_default_parent(cells[" "])
  79. create_world_by_map(level)
  80. render_maze(new_kruskal_maze(mazew, mazeh), render_cell)
  81. -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  82.