Refactor targeting code into a utility function, add reverse images until we add code to do that programmatically.
|
@ -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()
|
||||
|
|
BIN
src/images/kani/defend_reverse-table-1.png
Normal file
After Width: | Height: | Size: 285 B |
BIN
src/images/kani/defend_reverse-table-2.png
Normal file
After Width: | Height: | Size: 314 B |
BIN
src/images/kani/defend_reverse-table-3.png
Normal file
After Width: | Height: | Size: 322 B |
BIN
src/images/kani/defend_reverse-table-4.png
Normal file
After Width: | Height: | Size: 365 B |
BIN
src/images/kani/defend_reverse-table-5.png
Normal file
After Width: | Height: | Size: 442 B |
BIN
src/images/kani/defend_reverse-table-6.png
Normal file
After Width: | Height: | Size: 499 B |
BIN
src/images/kani/defend_reverse-table-7.png
Normal file
After Width: | Height: | Size: 525 B |
BIN
src/images/kani/defend_reverse-table-8.png
Normal file
After Width: | Height: | Size: 562 B |
20
src/util.lua
|
@ -6,14 +6,18 @@ local geom <const> = playdate.geometry
|
|||
|
||||
util = {}
|
||||
|
||||
-- creates a unit vector that "points" from point A to point B
|
||||
function util.unitPointer(a, b)
|
||||
return (b - a):normalized()
|
||||
-- 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 = 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
|
||||
|
||||
-- create a unit vector that points from x1, y1 to x2, y2
|
||||
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)
|
||||
return (b-a):normalized()
|
||||
end
|
||||
|
|