<?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="Devil's Bolder" el:subtitle="" el:id="just14"/>
      <el:version el:score="1" el:release="1" el:revision="2" el:status="released"/>
      <el:author  el:name="JuSt" el:email="" el:homepage=""/>
      <el:copyright>Copyright © 2007 JuSt</el:copyright>
      <el:license el:type="GPL v2.0 or above" el:open="true"/>
      <el:compatibility el:enigma="1.00">
      </el:compatibility>
      <el:modes el:easy="true" el:single="true" el:network="false"/>
      <el:comments>
        <el:dedication el:showinfo="true" el:showstart="false">Dedicated to Raoul</el:dedication>
      </el:comments>
      <el:score el:easy="-" el:difficult="-"/>
    </el:info>
    <el:luamain><![CDATA[
enigma.ConserveLevel = FALSE

create_world(20, 13)
oxyd_default_flavor="b"

-- Code
function bolderdir()
    obj = enigma.GetNamedObject("bolder1")
    if obj ~= nil then
        dir = enigma.GetAttrib(obj, "direction")
        repeat
            newdir = random (0, 3)
        until newdir ~= dir
        SendMessage ("bolder1", "direction", newdir)
    end
end

-- Floor Layer
fill_floor("fl-rough")

draw_floor("fl-water", {5, 4}, {1, 0}, 3)
draw_floor("fl-water", {5, 5}, {0, 1}, 2)
draw_floor("fl-water", {7, 5}, {0, 1}, 2)
draw_floor("fl-water", {12, 6}, {1, 0}, 3)
draw_floor("fl-water", {12, 7}, {0, 1}, 2)
draw_floor("fl-water", {14, 7}, {0, 1}, 2)
draw_floor("fl-water", {5, 10}, {1, 0}, 3)
draw_floor("fl-water", {12, 10}, {1, 0}, 3)
draw_floor("fl-water", {5, 11}, {0, 1}, 2)
draw_floor("fl-water", {7, 11}, {0, 1}, 2)
draw_floor("fl-water", {12, 11}, {0, 1}, 2)
draw_floor("fl-water", {14, 11}, {0, 1}, 2)
set_floor("fl-water", 6, 6)
set_floor("fl-water", 13, 8)
set_floor("fl-water", 6, 12)
set_floor("fl-water", 13, 12)

-- Item Layer
-- // Obstacle Code from Raoul //
-- The rectangles with legal position for an obstacle
-- The numbers are top-left and bottom-right corners coordinates
rects = {{{3,1},{5,2}},{{1,3},{5,11}},{{6,1},{16,4}},{{18,1},{18,4}},{{7,6},{12,10}},{{13,6},{18,6}},{{14,8},{17,10}}}

function set_obstacle(rect)
    local left_border = rect[1][1]
    local right_border = rect[2][1]
    local top_border = rect[1][2]
    local bottom_border = rect[2][2]

    repeat
        x = random(left_border, right_border)
        y = random(top_border, bottom_border)
    until enigma.GetItem(x,y) == nil -- until we won't overwrite another obstacle
    set_item("it-blackbomb",x,y)
end

-- How many obstacles we set?
if not difficult then
    e = 2
else
    e = 9
end

for i = 1, e do
    local r = random(1,7)
    set_obstacle(rects[r])
end

set_item("it-trigger", 1, 1, {action="callback", target="bolderdir", invisible=FALSE})
set_item("it-magicwand", 6, 8)

-- Stone Layer
oxyd(19, 11)
oxyd(19, 7)

draw_stones("st-woven", {0, 0}, {1, 0}, 20)
draw_stones("st-woven", {0, 1}, {0, 1}, 12)
draw_stones("st-woven", {19, 1}, {0, 1}, 4)
draw_stones("st-woven", {19, 8}, {0, 1}, 3)
draw_stones("st-woven", {1, 12}, {1, 0}, 19)
set_stone("st-woven", 19, 6)

if difficult then
    set_stone("st-woven", 2, 2)
    set_stone("st-grate1", 2, 1)
    set_stone("st-grate1", 1, 2)
else
    set_stone("st-grate1", 1, 1)
end

set_stones("st-pmirror", {{6, 5}, {13, 7}}, {movable=FALSE, transparent=FALSE, orientation="3"})
set_stone("st-pmirror", 6, 11, {movable=FALSE, transparent=FALSE, orientation="1"})
set_stone("st-pmirror", 13, 11, {movable=FALSE, transparent=TRUE, orientation="1"})

set_stone("st-laser", 19, 5, {dir=WEST, on="1"})

draw_stones("st-glass", {18, 7}, {0, 1}, 5, {type="0"})

set_stone("st-bolder", 17, 1, {name="bolder1", direction=SOUTH})

-- Actor Layer
set_actor("ac-blackball", 6.5, 8.5, {player="0", mouseforce="1"})
oxyd_shuffle()
  ]]></el:luamain>
    <el:i18n>
      <el:string el:key="title">
        <el:english el:translate="false"/>
      </el:string>
    </el:i18n>
  </el:protected>
</el:level>
