diff --git a/src/enemy/ika.lua b/src/enemy/ika.lua index dc506d2..1c1562c 100644 --- a/src/enemy/ika.lua +++ b/src/enemy/ika.lua @@ -19,7 +19,7 @@ function Ika:init(target) end function Ika:onReady() - self.weaponTimer = playdate.timer.new(7000, + self.weaponTimer = playdate.timer.new(5000, function() local b = Bullet(10, 20, self:calculateVector(self.target)) b:moveTo(self.x - (self.width/2) - 1, self.y) @@ -30,7 +30,9 @@ function Ika:onReady() end function Ika:calculateVector(target) - return util.unitPointer(self:getPosition(), target:getPosition()) * 5 + local x1,y1 = self:getPosition() + local x2,y2 = target:getPosition() + return util.unitPointer(x1,y1,x2,y2) * 5 end function Ika:remove() diff --git a/src/images/kani/defend_reverse-table-1.png b/src/images/kani/defend_reverse-table-1.png new file mode 100644 index 0000000..a81b4cd Binary files /dev/null and b/src/images/kani/defend_reverse-table-1.png differ diff --git a/src/images/kani/defend_reverse-table-2.png b/src/images/kani/defend_reverse-table-2.png new file mode 100644 index 0000000..178aa32 Binary files /dev/null and b/src/images/kani/defend_reverse-table-2.png differ diff --git a/src/images/kani/defend_reverse-table-3.png b/src/images/kani/defend_reverse-table-3.png new file mode 100644 index 0000000..38376ff Binary files /dev/null and b/src/images/kani/defend_reverse-table-3.png differ diff --git a/src/images/kani/defend_reverse-table-4.png b/src/images/kani/defend_reverse-table-4.png new file mode 100644 index 0000000..ea970b3 Binary files /dev/null and b/src/images/kani/defend_reverse-table-4.png differ diff --git a/src/images/kani/defend_reverse-table-5.png b/src/images/kani/defend_reverse-table-5.png new file mode 100644 index 0000000..b5fc32f Binary files /dev/null and b/src/images/kani/defend_reverse-table-5.png differ diff --git a/src/images/kani/defend_reverse-table-6.png b/src/images/kani/defend_reverse-table-6.png new file mode 100644 index 0000000..cfc04cb Binary files /dev/null and b/src/images/kani/defend_reverse-table-6.png differ diff --git a/src/images/kani/defend_reverse-table-7.png b/src/images/kani/defend_reverse-table-7.png new file mode 100644 index 0000000..4627733 Binary files /dev/null and b/src/images/kani/defend_reverse-table-7.png differ diff --git a/src/images/kani/defend_reverse-table-8.png b/src/images/kani/defend_reverse-table-8.png new file mode 100644 index 0000000..26d786b Binary files /dev/null and b/src/images/kani/defend_reverse-table-8.png differ diff --git a/src/util.lua b/src/util.lua index cb0facd..315c7f3 100644 --- a/src/util.lua +++ b/src/util.lua @@ -6,14 +6,18 @@ local geom = playdate.geometry util = {} --- creates a unit vector that "points" from point A to point B -function util.unitPointer(a, b) - return (b - a):normalized() -end - -- create a unit vector that points from x1, y1 to x2, y2 +-- alternately you can pass 2 playdate.geometry.point() objects instead function util.unitPointer(x1, y1, x2, y2) - local a = geom.point.new(x1, y1) - local b = geom.point.new(x2, y2) - return unitPointer(a,b) + local a = nil + local b = nil + if type(x1) == "number" then + a = geom.point.new(x1, y1) + b = geom.point.new(x2, y2) + else + a = x1 + b = y1 + end + + return (b-a):normalized() end