Resolve collisions with the sword

This commit is contained in:
Jean-André Santoni 2017-07-01 21:18:37 +02:00
parent aa789106e9
commit 2e4303ba77
3 changed files with 16 additions and 0 deletions

View File

@ -201,6 +201,12 @@ function demon:on_collide(e1, e2, dx, dy)
end
end
elseif e2.type == "sword" and e2.anim.id >= 4 and e2.anim.id <= 5 and self.hit == 0 and self.die == 0 then
if dx ~= 0 then
self.xspeed = 0
self.x = self.x + dx
end
self.hp = self.hp - 2
screen_shake = 15
if self.hp <= 0 then

View File

@ -113,6 +113,11 @@ function obake:on_collide(e1, e2, dx, dy)
end
elseif e2.type == "sword" and e2.anim.id >= 4 and e2.anim.id <= 5 and self.hit == 0 and self.die == 0 then
if dx ~= 0 then
self.xspeed = 0
self.x = self.x + dx
end
self.hit = 30
if e2.direction == "right" then
self.xspeed = 100

View File

@ -189,6 +189,11 @@ function porc:on_collide(e1, e2, dx, dy)
end
end
elseif e2.type == "sword" and e2.anim.id >= 4 and e2.anim.id <= 5 and self.hit == 0 and self.die == 0 then
if dx ~= 0 then
self.xspeed = 0
self.x = self.x + dx
end
self.hp = self.hp - 1
screen_shake = 15
if self.hp <= 0 then