- WIP EL_ALIEN AI

This commit is contained in:
2022-10-27 13:08:39 +02:00
parent 2dc22d7d78
commit 6ee51f42a5
5 changed files with 46 additions and 31 deletions

View File

@@ -1,4 +1,4 @@
elalien={hab=59,x=24,y=24,flip=true,goup=true,frame=8,stairscooldown=0,wait=0,step=0,anim={8,9,8,10},bb={x=4,y=0,w=8,h=16},scene_intro=false,scene_object=false} elalien={hab=38,x=24,y=24,flip=true,goup=true,frame=8,stairscooldown=0,wait=0,step=0,anim={8,9,8,10},bb={x=4,y=0,w=8,h=16},scene_intro=false,scene_object=false}
function elalien.init() function elalien.init()
elalien.hit=elalien.hit elalien.hit=elalien.hit
@@ -20,7 +20,7 @@ end
function elalien.update_normal() function elalien.update_normal()
elalien.wait=elalien.wait+1 elalien.wait=elalien.wait+1
if elalien.wait==6 then if elalien.wait>=6 then
elalien.wait=0 elalien.wait=0
if elalien.stairscooldown>0 then elalien.stairscooldown=elalien.stairscooldown-1 end if elalien.stairscooldown>0 then elalien.stairscooldown=elalien.stairscooldown-1 end
elalien.step=(elalien.step+1)%4 elalien.step=(elalien.step+1)%4
@@ -30,6 +30,13 @@ function elalien.update_normal()
if not elalien.flip and elalien.x==84 then if not elalien.flip and elalien.x==84 then
elalien.hab=elalien.hab+1 elalien.hab=elalien.hab+1
elalien.x=-4 elalien.x=-4
elseif check_tile(elalien.hab,elalien.x+inc,elalien.y+14)==tiletype.nonpc then
if rnd(10)<8 then
elalien.update=elalien.update_jumping
elalien.step=0
else
elalien.flip=not elalien.flip
end
elseif check_tile(elalien.hab,elalien.x+inc,elalien.y+14)<tiletype.half then elseif check_tile(elalien.hab,elalien.x+inc,elalien.y+14)<tiletype.half then
if elalien.flip then if elalien.flip then
elalien.x=elalien.x-2 elalien.x=elalien.x-2
@@ -41,7 +48,9 @@ function elalien.update_normal()
elalien.x=84 elalien.x=84
end end
elseif check_tile(elalien.hab,elalien.x+inc,elalien.y+6)<tiletype.half then elseif check_tile(elalien.hab,elalien.x+inc,elalien.y+6)<tiletype.half then
if rnd(2)==0 then local r=rnd(2)
if check_tile(elalien.hab,elalien.x+inc,elalien.y+14)==tiletype.block then r=0 end
if r==0 then
elalien.update=elalien.update_jumping elalien.update=elalien.update_jumping
elalien.step=0 elalien.step=0
else else
@@ -63,8 +72,10 @@ function elalien.update_normal()
--end --end
end end
if check_tile(elalien.hab,elalien.x+6,elalien.y+8)==tiletype.stair and elalien.stairscooldown==0 then if elalien.stairscooldown==0 and
if rnd(10)<3 then check_tile(elalien.hab,elalien.x+6,elalien.y+8)==tiletype.stair and
check_tile(elalien.hab,elalien.x+14,elalien.y+8)==tiletype.stair then
if rnd(10)<6 then
elalien.update=elalien.update_stairs elalien.update=elalien.update_stairs
if check_tile(elalien.hab,elalien.x+4,elalien.y+16)==tiletype.block then if check_tile(elalien.hab,elalien.x+4,elalien.y+16)==tiletype.block then
elalien.goup=true elalien.goup=true
@@ -83,11 +94,13 @@ function elalien.update_normal()
if check_tile(elalien.hab,elalien.x+4,elalien.y+16)==tiletype.void and ((elalien.x+4)&7==0 or check_tile(elalien.hab,elalien.x+12,elalien.y+16)==tiletype.void) then if check_tile(elalien.hab,elalien.x+4,elalien.y+16)==tiletype.void and ((elalien.x+4)&7==0 or check_tile(elalien.hab,elalien.x+12,elalien.y+16)==tiletype.void) then
local option=rnd(10) local option=rnd(10)
if elalien.stairscooldown>0 then option=0 end
if option<5 then if option<5 then
elalien.update=elalien.update_falling elalien.update=elalien.update_falling
elseif option<8 then elseif option<8 then
elalien.update=elalien.update_jumping elalien.update=elalien.update_jumping
elalien.step=0 elalien.step=0
elalien.wait=0
else else
elalien.flip=not elalien.flip elalien.flip=not elalien.flip
end end
@@ -112,14 +125,14 @@ function elalien.update_jumping()
elalien.frame=9 elalien.frame=9
elalien.wait=elalien.wait+1 elalien.wait=elalien.wait+1
if elalien.wait==6 then if elalien.wait>=6 then
elalien.wait=0 elalien.wait=0
local inc=12 if elalien.flip then inc=2 end local inc=12 if elalien.flip then inc=2 end
if not elalien.flip and elalien.x==84 then if not elalien.flip and elalien.x==84 then
elalien.hab=elalien.hab+1 elalien.hab=elalien.hab+1
elalien.x=-4 elalien.x=-4
elseif check_tile(elalien.hab,elalien.x+inc,elalien.y+14)<tiletype.half and check_tile(elalien.hab,elalien.x+inc,elalien.y+16)~=tiletype.void then elseif check_tile(elalien.hab,elalien.x+inc,elalien.y+14)<tiletype.half then
if elalien.flip then if elalien.flip then
elalien.x=elalien.x-2 elalien.x=elalien.x-2
else else
@@ -154,7 +167,7 @@ function elalien.update_falling()
elalien.frame=9 elalien.frame=9
elalien.wait=elalien.wait+1 elalien.wait=elalien.wait+1
if elalien.wait==6 then if elalien.wait>=6 then
elalien.wait=0 elalien.wait=0
local inc=12 if elalien.flip then inc=2 end local inc=12 if elalien.flip then inc=2 end
@@ -193,7 +206,7 @@ function elalien.update_stairs()
elalien.frame=11 elalien.frame=11
elalien.wait=elalien.wait+1 elalien.wait=elalien.wait+1
if elalien.wait==6 then if elalien.wait>=6 then
elalien.wait=0 elalien.wait=0
--if btn(KEY_RIGHT) then --if btn(KEY_RIGHT) then

View File

@@ -155,7 +155,7 @@ function update_game()
prnt("x"..abad.vides,114,13,2) prnt("x"..abad.vides,114,13,2)
rectfill(102+(abad.energia>>1),30,122,37,16) rectfill(102+(abad.energia>>1),30,122,37,16)
mapa_update(abad.hab,premiere.hab) mapa_update(abad.hab,elalien.hab)
for key,actor in pairs(actors) do for key,actor in pairs(actors) do
actor:update() actor:update()

40
map.lua
View File

@@ -64,8 +64,8 @@ mapa={
42,43,256,256,256,256,65,256,256,256,256,64, 42,43,256,256,256,256,65,256,256,256,256,64,
256,41,256,67,256,256,256,256,68,256,256,256, 256,41,256,67,256,256,256,256,68,256,256,256,
256,41,256,256,256,66,256,256,256,256,256,256, 256,41,256,256,256,66,256,256,256,256,256,256,
256,256,256,64,256,256,256,256,67,256,67,256, 256,256,256,64,256,256,65,256,67,256,67,256,
256,256,256,256,256,256,65,256,256,256,256,256, 256,256,256,256,256,256,256,256,256,256,256,256,
42,43,20,21,20,21,20,21,20,21,20,21, 42,43,20,21,20,21,20,21,20,21,20,21,
}, },
@@ -74,8 +74,8 @@ mapa={
67,256,256,256,256,65,256,256,256,256,64,256, 67,256,256,256,256,65,256,256,256,256,64,256,
256,256,67,256,256,256,256,68,256,256,256,256, 256,256,67,256,256,256,256,68,256,256,256,256,
256,256,256,256,66,256,256,256,256,256,256,67, 256,256,256,256,66,256,256,256,256,256,256,67,
256,256,64,256,256,256,256,67,256,67,256,256, 256,256,64,256,256,65,256,67,256,67,256,256,
256,256,256,256,256,65,256,256,256,256,256,256, 256,256,256,256,256,111,111,256,256,256,256,256,
20,21,20,21,17,256,256,17,20,21,20,21, 20,21,20,21,17,256,256,17,20,21,20,21,
}, },
@@ -84,8 +84,8 @@ mapa={
256,256,256,256,65,256,256,256,256,64,17,17, 256,256,256,256,65,256,256,256,256,64,17,17,
256,67,256,256,256,256,68,256,256,256,17,256, 256,67,256,256,256,256,68,256,256,256,17,256,
256,256,256,66,256,256,256,256,256,256,17,256, 256,256,256,66,256,256,256,256,256,256,17,256,
256,64,256,256,256,256,67,256,67,256,256,256, 256,64,256,256,65,256,67,256,67,256,256,256,
256,256,256,256,65,256,256,256,256,256,256,256, 256,256,256,256,256,256,256,256,256,256,256,256,
20,21,20,21,20,21,20,21,20,21,20,21, 20,21,20,21,20,21,20,21,20,21,20,21,
}, },
@@ -173,8 +173,8 @@ mapa={
{ {
44,45,44,45,41,256,256,41,44,45,44,45, 44,45,44,45,41,256,256,41,44,45,44,45,
256,256,256,256,256,69,256,256,256,256,256,256, 256,256,256,256,256,69,256,256,256,256,256,256,
256,256,256,256,256,256,256,256,256,256,256,256,
256,256,256,256,256,256,69,256,256,256,256,256, 256,256,256,256,256,256,69,256,256,256,256,256,
256,256,256,256,256,111,111,256,256,256,256,256,
256,256,256,41,41,256,69,41,41,256,256,256, 256,256,256,41,41,256,69,41,41,256,256,256,
45,44,45,42,43,256,256,42,43,44,45,44, 45,44,45,42,43,256,256,42,43,44,45,44,
@@ -375,8 +375,8 @@ mapa={
29,256,256,256,256,256,69,256,256,256,256,28, 29,256,256,256,256,256,69,256,256,256,256,28,
256,256,98,96,98,256,256,98,98,96,256,256, 256,256,98,96,98,256,256,98,98,96,256,256,
256,256,99,256,100,256,256,99,256,100,256,256, 256,256,99,256,100,256,256,99,256,100,256,256,
256,256,256,256,256,69,256,256,10,11,256,256, 256,256,256,256,256,111,111,256,10,11,256,256,
29,28,29,28,29,256,256,28,10,11,29,28, 29,28,29,28,29,69,256,28,10,11,29,28,
}, },
-- 39 -- 39
@@ -385,8 +385,8 @@ mapa={
256,256,25,25,256,256,256,256,256,256,106,24, 256,256,25,25,256,256,256,256,256,256,106,24,
256,256,256,69,256,256,256,256,256,256,95,24, 256,256,256,69,256,256,256,256,256,256,95,24,
256,256,256,256,78,97,107,108,256,106,105,24, 256,256,256,256,78,97,107,108,256,106,105,24,
256,256,69,256,94,101,102,110,103,105,98,24, 256,256,111,111,94,101,102,110,103,105,98,24,
28,29,256,256,28,29,28,29,28,29,28,29, 28,29,69,256,28,29,28,29,28,29,28,29,
}, },
-- 40 -- 40
@@ -475,8 +475,8 @@ mapa={
256,256,256,256,256,256,69,256,10,11,256,256, 256,256,256,256,256,256,69,256,10,11,256,256,
256,256,96,97,256,256,69,256,10,11,256,256, 256,256,96,97,256,256,69,256,10,11,256,256,
256,115,99,100,256,256,256,256,10,11,256,256, 256,115,99,100,256,256,256,256,10,11,256,256,
256,101,102,103,256,69,256,256,10,11,256,256, 256,101,102,103,256,111,111,256,10,11,256,256,
19,18,19,18,19,256,256,18,19,18,19,18, 19,18,19,18,19,69,256,18,19,18,19,18,
}, },
-- 49 -- 49
@@ -484,9 +484,9 @@ mapa={
20,21,256,69,18,19,18,19,20,21,20,21, 20,21,256,69,18,19,18,19,20,21,20,21,
256,256,256,256,256,256,256,256,256,256,114,256, 256,256,256,256,256,256,256,256,256,256,114,256,
256,256,69,256,256,256,114,256,256,256,256,256, 256,256,69,256,256,256,114,256,256,256,256,256,
256,114,69,256,256,256,256,256,17,18,19,17, 256,114,69,111,256,256,256,256,17,18,19,17,
256,256,256,256,18,19,18,19,18,19,18,19, 256,256,111,256,18,19,18,19,18,19,18,19,
18,19,256,256,17,18,19,18,19,18,19,17, 18,19,256,69,17,18,19,18,19,18,19,17,
}, },
-- 50 -- 50
@@ -575,7 +575,7 @@ mapa={
256,256,256,256,256,69,256,256,256,256,256,256, 256,256,256,256,256,69,256,256,256,256,256,256,
256,113,70,71,114,256,256,112,107,108,113,256, 256,113,70,71,114,256,256,112,107,108,113,256,
256,256,86,87,256,256,69,256,109,110,256,256, 256,256,86,87,256,256,69,256,109,110,256,256,
256,256,256,256,256,256,69,256,256,256,256,256, 256,256,256,256,256,111,111,256,256,256,256,256,
37,36,37,36,37,256,256,36,37,36,37,36, 37,36,37,36,37,256,256,36,37,36,37,36,
}, },
@@ -584,7 +584,7 @@ mapa={
34,35,256,256,34,35,34,35,34,35,34,35, 34,35,256,256,34,35,34,35,34,35,34,35,
256,256,256,69,256,256,256,256,256,256,256,256, 256,256,256,69,256,256,256,256,256,256,256,256,
256,256,69,256,256,256,97,96,256,256,256,256, 256,256,69,256,256,256,97,96,256,256,256,256,
256,256,256,256,256,256,99,100,256,256,256,256, 256,256,111,111,256,256,99,100,256,256,256,256,
256,41,120,119,41,256,256,256,8,9,256,256, 256,41,120,119,41,256,256,256,8,9,256,256,
3,41,46,47,41,3,36,37,8,9,36,37, 3,41,46,47,41,3,36,37,8,9,36,37,
@@ -675,7 +675,7 @@ mapa={
24,97,256,256,256,256,256,256,256,256,256,256, 24,97,256,256,256,256,256,256,256,256,256,256,
24,99,256,256,256,69,256,256,256,256,256,256, 24,99,256,256,256,69,256,256,256,256,256,256,
24,256,95,256,113,69,256,256,114,75,76,256, 24,256,95,256,113,69,256,256,114,75,76,256,
24,101,102,103,256,256,256,256,256,91,92,256, 24,101,102,103,256,111,111,256,256,91,92,256,
28,28,29,28,29,256,69,28,29,28,29,28, 28,28,29,28,29,256,69,28,29,28,29,28,
}, },
@@ -774,7 +774,7 @@ mapa={
51,52,53,51,52,256,256,52,53,51,52,17, 51,52,53,51,52,256,256,52,53,51,52,17,
256,256,256,256,256,256,69,256,256,256,256,17, 256,256,256,256,256,256,69,256,256,256,256,17,
256,256,256,256,256,69,256,256,256,256,256,17, 256,256,256,256,256,69,256,256,256,256,256,17,
256,256,256,256,256,256,256,106,256,256,78,17, 256,256,256,256,256,111,111,106,256,256,78,17,
256,256,256,256,17,118,119,17,256,95,94,17, 256,256,256,256,17,118,119,17,256,95,94,17,
51,52,53,53,51,53,52,53,51,52,51,17, 51,52,53,53,51,53,52,53,51,52,51,17,

View File

@@ -1,5 +1,5 @@
--mapa={} --mapa={}
tiletype={void=0,stair=1,switch=2,half=3,block=4} tiletype={void=0,nonpc=1,stair=2,switch=3,half=4,block=5}
mapa.wait=0 mapa.wait=0
mapa.step=0 mapa.step=0
function mapa_do_backup() function mapa_do_backup()
@@ -137,6 +137,8 @@ function check_tile(hab,x,y)
return tiletype.switch return tiletype.switch
elseif tile<64 then elseif tile<64 then
return tiletype.block return tiletype.block
elseif tile==111 then
return tiletype.nonpc
else else
return tiletype.void return tiletype.void
end end

BIN
tiles.gif

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB