update aseprite loader so, it would work in builds
This commit is contained in:
parent
5b51be8556
commit
f19fbda061
@ -22,6 +22,25 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
]]--
|
||||
|
||||
local File = {}
|
||||
File.__index = File
|
||||
|
||||
function File.open(filename)
|
||||
local data, err = love.filesystem.read(filename)
|
||||
if not data then return nil, err end
|
||||
|
||||
local self = setmetatable({}, File)
|
||||
self.data = data
|
||||
self.cursor = 1
|
||||
return self
|
||||
end
|
||||
|
||||
function File:read(size)
|
||||
local bytes = self.data:sub(self.cursor, self.cursor+size-1)
|
||||
self.cursor = self.cursor + size
|
||||
return bytes
|
||||
end
|
||||
|
||||
-- sizes in bytes
|
||||
local BYTE = 1
|
||||
local WORD = 2
|
||||
@ -329,7 +348,7 @@ local function grab_chunk(data)
|
||||
end
|
||||
|
||||
local function ase_loader(src)
|
||||
local data = io.open(src, "rb")
|
||||
local data = File.open(src)
|
||||
assert(data, "can't open " .. src)
|
||||
local ase = {}
|
||||
|
||||
@ -346,7 +365,6 @@ local function ase_loader(src)
|
||||
end
|
||||
end
|
||||
|
||||
data.close()
|
||||
return ase
|
||||
end
|
||||
|
||||
|
@ -7,6 +7,8 @@ local GRID_COLOR = rgb(30, 30, 30)
|
||||
local DRAW_COLLIDERS = false
|
||||
local COLLIDER_COLOR = rgb(200, 20, 200)
|
||||
|
||||
local DRAW_PING = false
|
||||
|
||||
function Debug:drawColliders()
|
||||
local physics = self.pool:getSystem(require("systems.physics"))
|
||||
love.graphics.setColor(COLLIDER_COLOR)
|
||||
@ -40,6 +42,14 @@ function Debug:draw()
|
||||
if DRAW_COLLIDERS then
|
||||
self:drawColliders()
|
||||
end
|
||||
if DRAW_PING and self.pool.data.host_socket then
|
||||
local host_socket = self.pool.data.host_socket
|
||||
local height = love.graphics.getFont():getHeight()
|
||||
for _, index in ipairs(self.connected_peers) do
|
||||
local peer = host_socket:get_peer(index)
|
||||
love.graphics.print(peer:round_trip_time(), 0, (index-1)*height)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return Debug
|
||||
|
@ -3,6 +3,8 @@ local binser = require("lib.binser")
|
||||
local pprint = require("lib.pprint")
|
||||
local uid = require("helpers.uid")
|
||||
|
||||
local RATE_LIMIT = 20
|
||||
|
||||
local CMD = {
|
||||
SPAWN_PLAYER = 1,
|
||||
MOVE_PLAYER = 2,
|
||||
@ -146,12 +148,4 @@ function Multiplayer:playerShot(player)
|
||||
self:sendToAllPeers(CMD.PLAYER_SHOT, player.id)
|
||||
end
|
||||
|
||||
function Multiplayer:draw()
|
||||
local host_socket = self.pool.data.host_socket
|
||||
for _, index in ipairs(self.connected_peers) do
|
||||
local peer = host_socket:get_peer(index)
|
||||
love.graphics.print(peer:round_trip_time())
|
||||
end
|
||||
end
|
||||
|
||||
return Multiplayer
|
||||
|
@ -32,12 +32,13 @@ end
|
||||
function Player:getAimDirection(player)
|
||||
if self.use_mouse_aim then
|
||||
local ScreenScaler = self.pool:getSystem(require("systems.screen-scaler"))
|
||||
local dir = Vec(ScreenScaler:getMousePosition()) - player.pos
|
||||
|
||||
local MAX_DIRECTIONS = 8
|
||||
local angle_segment = math.pi*2/MAX_DIRECTIONS
|
||||
local angle = (Vec(ScreenScaler:getMousePosition()) - player.pos).angle
|
||||
local new_angle = math.floor(angle/angle_segment+0.5)*angle_segment
|
||||
return Vec(math.cos(new_angle), math.sin(new_angle))
|
||||
return dir.normalized
|
||||
-- local MAX_DIRECTIONS = 8
|
||||
-- local angle_segment = math.pi*2/MAX_DIRECTIONS
|
||||
-- local new_angle = math.floor(dir.angle/angle_segment+0.5)*angle_segment
|
||||
-- return Vec(math.cos(new_angle), math.sin(new_angle))
|
||||
else
|
||||
return getDirection(
|
||||
controls.aim_up,
|
||||
|
Loading…
Reference in New Issue
Block a user