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

  1. -- Space Walk
  2. -- A level for Enigma
  3. -- Copyright (c) 2002 Nat Pryce
  4. -- License: GPL v2.0 or above
  5.  
  6. dofile( enigma.FindDataFile("levels/natmaze.lua") )
  7.  
  8.  
  9. function links_x( maze, cellx, celly )
  10.     return maze:can_go_east(cellx,celly) and maze:can_go_west(cellx,celly)
  11. end
  12.  
  13. function links_y( maze, cellx, celly )
  14.     return maze:can_go_north(cellx,celly) and maze:can_go_south(cellx,celly) 
  15. end
  16.  
  17. function leads_x( maze, cellx, celly )
  18.     return maze:can_go_east(cellx,celly) or maze:can_go_west(cellx,celly)
  19. end
  20.  
  21. function leads_y( maze, cellx, celly )
  22.     return maze:can_go_north(cellx,celly) or maze:can_go_south(cellx,celly) 
  23. end
  24.  
  25. function cell_is_straight( maze, cellx, celly )
  26.     return links_x(maze,cellx,celly) and not leads_y(maze,cellx,celly)
  27.         or links_y(maze,cellx,celly) and not leads_x(maze,cellx,celly)
  28. end
  29.  
  30.  
  31.  
  32. originx = 1
  33. originy = 1
  34.  
  35. function cell_to_level( cellx, celly )
  36.     return %originx + cellx * 2, %originy + celly * 2
  37. end
  38.  
  39. function render_cell( maze, cellx, celly )
  40.     local x, y = cell_to_level( cellx, celly )
  41.     
  42.     if cell_is_straight( maze, cellx, celly ) then
  43.         set_floor( "fl-space", x, y )
  44.     else
  45.         set_floor( "fl-gray", x, y )
  46.         set_stone( "st-grate1", x, y )
  47.     end
  48.      
  49.     if maze:can_go_south(cellx,celly) then
  50.         set_floor( "fl-space", x, y+1 )
  51.     end
  52.     
  53.     if maze:can_go_east(cellx,celly) then
  54.         set_floor( "fl-space", x+1, y )
  55.     end
  56. end
  57.  
  58. do
  59.     local maze = new_kruskal_maze(38,24)   
  60.     
  61.     create_world( maze.width*2 + 2, maze.height*2 + 2 )
  62.     fill_floor( "fl-abyss", 0, 0, level_width, level_height )
  63.     render_maze( maze, render_cell )
  64.     
  65.     oxyd(1,0)
  66.     oxyd(2*maze.width-1,2*maze.height)
  67.     oxyd(1,2*maze.height)
  68.     oxyd(2*maze.width-1,0)
  69.  
  70.     -- ant 2003-02-13: actor should not appear at space cell
  71.     local actorx, actory = 0,0
  72.     repeat
  73.        actorx, actory = random(maze.width)-1, random(maze.height)-1
  74.     until (not(cell_is_straight(maze, actorx, actory)))
  75.  
  76.     actorx, actory = cell_to_level(actorx, actory)
  77.     set_actor( "ac-blackball", actorx + 0.5, actory + 0.5,
  78.                { player=0 } )
  79. end
  80. display.SetFollowMode(display.FOLLOW_SCROLLING)
  81.