- [NEW] Ja lleva o fica els items segons l'habitació que entra
This commit is contained in:
@@ -17,23 +17,27 @@ sprites = {
|
||||
end,
|
||||
|
||||
remove_out_of_room = function()
|
||||
print("Current room: "..rooms.current())
|
||||
for i,v in ipairs(sprites.list) do
|
||||
if v.room ~= rooms.current() then
|
||||
table.remove(sprites.list, i)
|
||||
print("Sprite removed: "..v.type)
|
||||
local room = v.room or 0
|
||||
print("Sprite at room "..room.." removed: "..v.type)
|
||||
end
|
||||
end
|
||||
end,
|
||||
|
||||
add_from_room = function()
|
||||
add_from_room = function(rx,ry)
|
||||
map.surf(rooms.surf_items)
|
||||
for y = rooms.pos.y, rooms.pos.y+19 do
|
||||
for x = rooms.pos.x, rooms.pos.x+11 do
|
||||
--if surf.pixel(x,y) ~= 0 then
|
||||
io.write(map.tile(x,y)..",")
|
||||
--end
|
||||
for y = ry, ry+11 do
|
||||
for x = rx, rx+19 do
|
||||
if map.tile(x,y) ~= 0 then
|
||||
local room = (rx//20) + (ry//12) * 8
|
||||
io.write("crear "..items[map.tile(x,y)].name.." en hab "..room.." ("..x..","..y..")...\n")
|
||||
table.insert(sprites.list, templates.create(items[map.tile(x,y)].name, {pos={x=x*8, y=y*8},flipped=true, room=room}))
|
||||
end
|
||||
end
|
||||
io.write("\n")
|
||||
--io.write("\n")
|
||||
end
|
||||
end,
|
||||
|
||||
@@ -113,14 +117,14 @@ sprites = {
|
||||
update_mummy = function(spr)
|
||||
if spr.state == templates.ALIVE then
|
||||
if spr.flipped then
|
||||
local tx, ty = (spr.pos.x+3)>>3, (spr.pos.y+16)>>3
|
||||
local tx, ty = (spr.pos.x+3)>>3, (spr.pos.y+15)>>3
|
||||
if map.tile(tx,ty) < 16 and map.tile(tx,ty-1) < 16 and map.tile(tx,ty+1) > 0 then
|
||||
spr.pos.x = spr.pos.x - 1
|
||||
else
|
||||
spr.flipped = not spr.flipped
|
||||
end
|
||||
else
|
||||
local tx, ty = (spr.pos.x+12)>>3, (spr.pos.y+16)>>3
|
||||
local tx, ty = (spr.pos.x+12)>>3, (spr.pos.y+15)>>3
|
||||
if map.tile(tx,ty) < 16 and map.tile(tx,ty-1) < 16 and map.tile(tx,ty+1) > 0 then
|
||||
spr.pos.x = spr.pos.x + 1
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user