<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<el:level xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://enigma-game.org/schema/level/1 level.xsd" xmlns:el="http://enigma-game.org/schema/level/1">
  <el:protected>
    <el:info el:type="level">
      <el:identity el:title="Space Walk" el:subtitle="" el:id="natmaze4"/>
      <el:version el:score="2" el:release="2" el:revision="0" el:status="released"/>
      <el:author  el:name="Nat Pryce" el:email="" el:homepage=""/>
      <el:copyright>Copyright © 2002 Nat Pryce</el:copyright>
      <el:license el:type="GPL v2.0 or above" el:open="true"/>
      <el:compatibility el:enigma="0.92">
       <el:dependency el:path="lib/natmaze" el:id="lib/natmaze" el:release="1" el:preload="true"/>
      </el:compatibility>
      <el:modes el:easy="false" el:single="true" el:network="false"/>
      <el:comments>
        <el:code>Lua 5.1 and XML converted by Leveladministrators</el:code>
      </el:comments>
      <el:score el:easy="-" el:difficult="-"/>
    </el:info>
    <el:luamain><![CDATA[
-- ant 2003-02-13: actor should not appear at space cell
-- May 06: Reduced size -- Andreas

function links_x( maze, cellx, celly )
    return maze:can_go_east(cellx,celly) and maze:can_go_west(cellx,celly)
end

function links_y( maze, cellx, celly )
    return maze:can_go_north(cellx,celly) and maze:can_go_south(cellx,celly) 
end

function leads_x( maze, cellx, celly )
    return maze:can_go_east(cellx,celly) or maze:can_go_west(cellx,celly)
end

function leads_y( maze, cellx, celly )
    return maze:can_go_north(cellx,celly) or maze:can_go_south(cellx,celly) 
end

function cell_is_straight( maze, cellx, celly )
    return links_x(maze,cellx,celly) and not leads_y(maze,cellx,celly)
        or links_y(maze,cellx,celly) and not leads_x(maze,cellx,celly)
end

originx = 1
originy = 1

function cell_to_level( cellx, celly )
    return originx + cellx * 2, originy + celly * 2
end

function render_cell( maze, cellx, celly )
    local x, y = cell_to_level( cellx, celly )
    
    if cell_is_straight( maze, cellx, celly ) then
        set_floor( "fl-space", x, y )
    else
        set_floor( "fl-gray", x, y )
        set_stone( "st-grate1", x, y )
    end
     
    if maze:can_go_south(cellx,celly) then
        set_floor( "fl-space", x, y+1 )
    end
    
    if maze:can_go_east(cellx,celly) then
        set_floor( "fl-space", x+1, y )
    end
end

do
    -- local maze = new_kruskal_maze(38,24)   
    local maze = new_kruskal_maze(19,18)

    --create_world( maze.width*2 + 2, maze.height*2 + 2 )
    create_world( maze.width*2 + 1, maze.height*2 + 1 )
    fill_floor( "fl-abyss")    
    render_maze( maze, render_cell )
    
    oxyd(1,0)
    oxyd(2*maze.width-1,2*maze.height)
    oxyd(1,2*maze.height)
    oxyd(2*maze.width-1,0)

    -- ant 2003-02-13: actor should not appear at space cell
    local actorx, actory = 0,0
    repeat
       actorx, actory = random(maze.width)-1, random(maze.height)-1
    until (not(cell_is_straight(maze, actorx, actory)))

    actorx, actory = cell_to_level(actorx, actory)
    set_actor( "ac-blackball", actorx + 0.5, actory + 0.5,
               { player=0 } )
end
display.SetFollowMode(display.FOLLOW_SCROLLING)
    ]]></el:luamain>
    <el:i18n>
      <el:string el:key="title">
        <el:english el:translate="false"/>
      </el:string>
    </el:i18n>
  </el:protected>
</el:level>
