2 |
-- (c) 2002 Petr Machata/ant_39 |
-- (c) 2002 Petr Machata/ant_39 |
3 |
-- Licensed under GPL v2.0 or above |
-- Licensed under GPL v2.0 or above |
4 |
|
|
5 |
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- |
dofile(enigma.FindDataFile("levels/ant.lua")) |
|
|
|
|
function cell_item(it) |
|
|
local n_it = {} |
|
|
n_it.face = (it.face or "") |
|
|
n_it.attr = (it.attr or {}) |
|
|
return n_it |
|
|
end |
|
6 |
|
|
7 |
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 |
|
8 |
|
|
9 |
boldercount=0 |
boldercount=0 |
10 |
function add_bolder(x,y,dir) |
function add_bolder(x,y,dir) |
71 |
"############~############" |
"############~############" |
72 |
} |
} |
73 |
|
|
|
|
|
|
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 |
|
|
|
|
74 |
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- |
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- |
75 |
levelw = 20 |
levelw = 20 |
76 |
levelh = 25 |
levelh = 25 |
77 |
create_world(levelw, levelh) |
create_world(levelw, levelh) |
78 |
randomseed(enigma.GetTicks()) |
randomseed(enigma.GetTicks()) |
79 |
draw_map(0, 0, level) |
draw_map(0, 0, level, TRANSPOSE_MAP) |