Destiny-dashing (enemy dashes)

This commit is contained in:
Jaidyn Ann 2020-09-21 17:18:26 -05:00
parent e1bd05d2fa
commit cabf913f2f

111
main.lua
View File

@ -796,7 +796,18 @@ function Bird:destiny_x ()
self.direction = right self.direction = right
end end
end end
if ( self.species > 1 ) then
if ( inRange( self.x, player.x - 30, player.x + 30 )
and math.random(0,300) == 25 ) then
if ( self.y < player.y ) then
self.pointing = down
else
self.pointing = up
end
self:dash()
end
end
self.moving = true self.moving = true
end end
@ -805,6 +816,18 @@ function Bird:destiny_y ()
if ( self.y > player.y + 50 and math.random(0,100) == 25 ) then if ( self.y > player.y + 50 and math.random(0,100) == 25 ) then
self.flying = 2 self.flying = 2
end end
if ( self.species > 1 ) then
if ( inRange( self.y, player.y - 30, player.y + 30 )
and math.random(0,300) == 25 ) then
if ( self.x < player.x ) then
self.pointing = right
else
self.pointing = left
end
self:dash()
end
end
end end
@ -989,90 +1012,52 @@ end
-------------------- --------------------
-- idk if Lua has macros, if it does, that'd be *WAY* better than this shit -- idk if Lua has macros, if it does, that'd be *WAY* better than this shit
function isRight ( direction ) function isRight ( direction ) return ( direction == 2 or direction == 12 or direction == 22 ) end
return ( direction == 2 or direction == 12 or direction == 22 ) function isLeft ( direction ) return ( direction == 1 or direction == 11 or direction == 21 ) end
end function isUp ( direction ) return ( 10 <= direction and direction < 20 ) end
function isDown ( direction ) return ( 20 <= direction and direction < 30 ) end
function isLeft ( direction )
return ( direction == 1 or direction == 11 or direction == 21 )
end
function isUp ( direction )
return ( 10 <= direction and direction < 20 )
end
function isDown ( direction )
return ( 20 <= direction and direction < 30 )
end
function setLeft ( direction ) function setLeft ( direction )
if ( isLeft(direction) ) then if ( isLeft(direction) ) then return direction
return direction elseif ( isRight(direction) ) then return direction - 1
elseif ( isRight(direction) ) then else return direction + 1
return direction - 1
else
return direction + 1
end end
end end
function unsetLeft ( direction ) function unsetLeft ( direction )
if ( isLeft(direction ) ) then if ( isLeft(direction ) ) then return direction - left
return direction - left else return direction
else
return direction
end end
end end
function setRight ( direction ) function setRight ( direction )
if ( isRight(direction) ) then if ( isRight(direction) ) then return direction
return direction elseif ( isLeft(direction) ) then return direction + 1
elseif ( isLeft(direction) ) then else return direction + 2
return direction + 1
else
return direction + 2
end end
end end
function unsetRight ( direction ) function unsetRight ( direction )
if ( isRight(direction ) ) then if ( isRight(direction ) ) then return direction - right
return direction - right else return direction
else
return direction
end end
end end
function setUp ( direction ) function setUp ( direction )
if ( isUp(direction) == true ) then if ( isUp(direction) == true ) then return direction
return direction elseif ( isDown(direction) == true ) then return direction - 10
elseif ( isDown(direction) == true ) then else return direction + up
return direction - 10
else
return direction + up
end end
end end
function unsetUp ( direction ) function unsetUp ( direction )
if ( isUp(direction ) ) then if ( isUp(direction ) ) then return direction - up
return direction - up else return direction
else
return direction
end end
end end
function setDown ( direction ) function setDown ( direction )
if ( isDown(direction) ) then if ( isDown(direction) ) then return direction
return direction elseif ( isUp(direction) ) then return direction + 10
elseif ( isUp(direction) ) then else return direction + down
return direction + 10
else
return direction + down
end end
end end
function unsetDown ( direction ) function unsetDown ( direction )
if ( isDown( direction ) ) then if ( isDown( direction ) ) then return direction - down
return direction - down else return direction
else
return direction
end end
end end