More explicit collision type.
Skip over globals defined in generated/assets during luacheck
This commit is contained in:
parent
ba9a7d8042
commit
e242ab8b30
2
Makefile
2
Makefile
|
@ -3,7 +3,7 @@ preprocess:
|
|||
|
||||
check: preprocess
|
||||
stylua -c --indent-type Spaces ./
|
||||
luacheck -d --globals tiny T Arr Maybe TextStyle --codes ./ --exclude-files ./test/ ./generated/ ./lib/ ./tiny-*
|
||||
luacheck -d --no-self --globals bit tiny T Arr Maybe TextStyle $$(grep "^[A-Z]" generated/assets.lua | awk '{print $$1}' | tr '\n' ' ') --codes ./ --exclude-files ./test/ ./generated/ ./lib/ ./tiny-*
|
||||
|
||||
test: check
|
||||
find ./test -name '*.lua' | xargs -L1 -I %% lua %% -v
|
||||
|
|
|
@ -7,7 +7,7 @@ local SOME_TABLE = {}
|
|||
|
||||
---@alias AnyComponent any
|
||||
---@alias BitMask number
|
||||
---@alias Collision { collisionBetween: Entity[] }
|
||||
---@alias Collision { collidedInto: Entity, collider: Entity }
|
||||
---@alias Entity table
|
||||
---@alias FontData love.FontData
|
||||
---@alias KeyState table<string, boolean>
|
||||
|
|
|
@ -57,7 +57,7 @@ local SOME_TABLE = {}
|
|||
AnyComponent = "any",
|
||||
Entity = "table",
|
||||
XyPair = "{ x: number, y: number }",
|
||||
Collision = "{ collisionBetween: Entity[] }",
|
||||
Collision = "{ collidedInto: Entity, collider: Entity }",
|
||||
BitMask = "number",
|
||||
FontData = "love.FontData",
|
||||
KeyState = "table<string, boolean>",
|
||||
|
|
|
@ -34,7 +34,7 @@ world:filteredSystem(
|
|||
and bit.band(collider.canCollideWith, e.canBeCollidedBy) ~= 0
|
||||
then
|
||||
if intersects(e, collider) then
|
||||
system.world:addEntity({ collisionBetween = { e, collider } })
|
||||
system.world:addEntity({ collisionBetween = { collider = collider, collidedInto = e } })
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
local world = require("world")
|
||||
|
||||
world:filteredSystem("collisionResolution", { collisionBetween = T.Collision }, function(e, _, system)
|
||||
local collidedInto, collider = e.collisionBetween[1], e.collisionBetween[2]
|
||||
system.world:removeEntity(e)
|
||||
end)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
local world = require("world")
|
||||
local sqrt = math.sqrt
|
||||
|
||||
world:filteredSystem("velocity", { position = T.XyPair, velocity = T.XyPair }, function(e, dt, system)
|
||||
world:filteredSystem("velocity", { position = T.XyPair, velocity = T.XyPair }, function(e, dt, _)
|
||||
if sqrt((e.velocity.x * e.velocity.x) + (e.velocity.y * e.velocity.y)) < 2 then
|
||||
-- velocity = nil
|
||||
else
|
||||
|
@ -10,7 +10,7 @@ world:filteredSystem("velocity", { position = T.XyPair, velocity = T.XyPair }, f
|
|||
end
|
||||
end)
|
||||
|
||||
world:filteredSystem("drag", { velocity = T.XyPair, drag = T.number }, function(e, dt, system)
|
||||
world:filteredSystem("drag", { velocity = T.XyPair, drag = T.number }, function(e, dt, _)
|
||||
local currentDrag = e.drag * dt
|
||||
e.velocity.x = e.velocity.x - (e.velocity.x * currentDrag * dt)
|
||||
e.velocity.y = e.velocity.y - (e.velocity.y * currentDrag * dt)
|
||||
|
|
Loading…
Reference in New Issue