41 lines
1.0 KiB
Lua
41 lines
1.0 KiB
Lua
-- posició en el gif (tiles de 32)
|
|
llibre_gif_col = 7
|
|
llibre_gif_row = 3
|
|
|
|
llibre={name="llibre",hab=5,x=6,y=3,w=32,h=32,bb={x=0,y=0,w=32,h=32}}
|
|
|
|
function llibre.init()
|
|
-- local habs={{33,8},{13,4},{51,9},{50,4},{42,7}}
|
|
-- local r=1+math.random(0,#habs-1)
|
|
-- llibre.hab=habs[r][1]
|
|
-- llibre.x=habs[r][2]*8
|
|
-- llibre.x=habs[r][2]
|
|
llibre.hab = 41
|
|
llibre.x = 10
|
|
llibre.y = 2
|
|
|
|
local world_x, world_y = coords.room_to_world(llibre.hab,llibre.x,llibre.y)
|
|
llibre.x=world_x-4
|
|
llibre.y=world_y-3
|
|
|
|
llibre.update=llibre.update
|
|
llibre.draw=llibre.draw
|
|
end
|
|
|
|
function llibre.draw()
|
|
local x = llibre_gif_col*llibre.w
|
|
local y = llibre_gif_row*llibre.h
|
|
local scr_x, scr_y = viewp:screen_coords( llibre.x, llibre.y )
|
|
draw.surf(x,y,llibre.w,llibre.h,scr_x,scr_y,llibre.w,llibre.h)
|
|
end
|
|
|
|
function llibre.update()
|
|
if llibre.hab==abad.hab then
|
|
if collision(abad,llibre) then
|
|
abad.objects.llibre=true
|
|
remove_actor(llibre)
|
|
start_scene(scenes.llibre_trobat)
|
|
end
|
|
end
|
|
end
|