[NEW] Elalien en marxa

This commit is contained in:
2026-04-30 22:55:02 +02:00
parent 8b758af0e7
commit cb525845ac
3 changed files with 85 additions and 25 deletions

View File

@@ -13,6 +13,7 @@ elalien={name="elalien",
flip=true,
goup=true,
frame=8,
parpadeig=false,
stairscooldown=0,
wait=0,
step=0,
@@ -23,7 +24,7 @@ elalien={name="elalien",
function elalien.init()
-- elalien.x=24
elalien.x=3
elalien.x=9
-- elalien.y=24
elalien.y=3
elalien.w=32
@@ -37,7 +38,8 @@ function elalien.init()
elalien.scene_intro=false
elalien.scene_object=false
local habs={66,56,59,53}
elalien.hab=habs[1+math.random(0,3)]
-- elalien.hab=habs[1+math.random(0,3)]
elalien.hab=56
local world_x, world_y = coords.room_to_world(elalien.hab,elalien.x,elalien.y)
elalien.x=world_x
@@ -49,25 +51,83 @@ function elalien.draw()
if elalien.update==elalien.update_stairs then
flip=(((elalien.x>>1)+(elalien.y>>1))%2)==0
end
-- draw.surf((elalien.frame&7)*cw,(elalien.frame>>cxr2)*ch,cw,ch,elalien.x*o2aX,elalien.y*o2aX,cw,ch,flip)
local xoff0 = 18
local xoff1 = 19
local xoff2 = 20
local xoff3 = 21
-- draw.surf((elalien.frame&7)*cw,(elalien.frame>>cxr2)*ch,cw,ch,elalien.x*o2aX,elalien.y*o2aX,cw,ch,flip)
local scr_x, scr_y = viewp:screen_coords( elalien.x, elalien.y )
local x = (elalien.frame&7)*cw
local y = (elalien.frame>>cxr2)*ch
draw.surf(x,y,cw,ch,scr_x,scr_y,elalien.w,elalien.h,flip)
if elalien.update == elalien.update_stay then
draw.surf(0,32,elalien.w,elalien.h,scr_x,scr_y,elalien.w,elalien.h,flip)
if elalien.parpadeig then
if elalien.flip then
xoff0 = 13
xoff1 = 12
xoff2 = 11
xoff3 = 10
end
if elalien.step==0 then
draw.line(scr_x+xoff0, scr_y+6, scr_x+xoff0, scr_y+11, 11)
surf.pixel(scr_x+xoff1, scr_y+11, 11)
surf.pixel(scr_x+xoff1, scr_y+7, 11)
elseif elalien.step<3 then
draw.line(scr_x+xoff0, scr_y+6, scr_x+xoff0, scr_y+11, 11)
draw.line(scr_x+xoff1, scr_y+7, scr_x+xoff1, scr_y+11, 11)
draw.line(scr_x+xoff2, scr_y+8, scr_x+xoff2, scr_y+11, 11)
draw.line(scr_x+xoff3, scr_y+8, scr_x+xoff3, scr_y+11, 11)
elseif elalien.step==3 then
draw.line(scr_x+xoff0, scr_y+6, scr_x+xoff0, scr_y+11, 11)
draw.line(scr_x+xoff1, scr_y+7, scr_x+xoff1, scr_y+11, 11)
draw.line(scr_x+xoff2, scr_y+8, scr_x+xoff2, scr_y+11, 11)
draw.line(scr_x+xoff3, scr_y+8, scr_x+xoff3, scr_y+11, 11)
elalien.parpadeig = false
end
end
else
local x = (elalien.frame&7)*cw
local y = (elalien.frame>>cxr2)*ch
draw.surf(x,y,cw,ch,scr_x,scr_y,elalien.w,elalien.h,flip)
end
end
function elalien.hit()
end
function elalien.update_stay()
elalien.wait=elalien.wait+1
if elalien.wait==6 then
if elalien.wait==18 then
elalien.wait=0
elalien.step=(elalien.step+1)%4
elalien.frame=elalien.anim[elalien.step+1]
if elalien.step==0 and not elalien.parpadeig then
if math.random(5)==5 then elalien.parpadeig = true end
end
-- elalien.frame=elalien.anim[elalien.step+1]
end
if elalien.hab==abad.hab then
if collision(abad,elalien) then
if not elalien.scene_intro then
if abad.objects.peu~=nil then
start_scene(scenes.elalien_intro_peu)
elalien.scene_object=true
abad.objects.clau_elalien=true
abad.objects.peu=nil
else
start_scene(scenes.elalien_intro)
end
elalien.scene_intro=true
elseif not elalien.scene_object and abad.objects.peu~=nil then
start_scene(scenes.elalien_peu)
elalien.scene_object=true
abad.objects.clau_elalien=true
abad.objects.peu=nil
end
end
end
end
function elalien.update_normal()