diff --git a/src/data/init.lua b/src/data/init.lua index a2a8941..b1e4ab4 100644 --- a/src/data/init.lua +++ b/src/data/init.lua @@ -23,7 +23,9 @@ local function loadAsepriteSprite(filename) local frames = {} local tags = {} local layers = {} - local first_tag + + love.graphics.push("transform") + love.graphics.origin() for i, ase_frame in ipairs(ase.header.frames) do for _, chunk in ipairs(ase_frame.chunks) do @@ -50,11 +52,6 @@ local function loadAsepriteSprite(filename) love.graphics.setCanvas() elseif chunk.type == TAG_CHUNK then for j, tag in ipairs(chunk.data.tags) do - -- first tag as default - if j == 1 then - first_tag = tag.name - end - -- aseprite use 0 notation to begin -- but in lua, everthing starts in 1 tag.to = tag.to + 1 @@ -68,6 +65,8 @@ local function loadAsepriteSprite(filename) end end + love.graphics.push() + for _, tag in pairs(tags) do local variant = {} sprite.variants[tag.name] = variant @@ -77,7 +76,7 @@ local function loadAsepriteSprite(filename) end if not sprite.variants.default then - sprite.variants.default = {frames[0]} + sprite.variants.default = {frames[1]} end return sprite diff --git a/src/data/sprites/bolt-ghost.aseprite b/src/data/sprites/bolt-ghost.aseprite new file mode 100644 index 0000000..cf7ba3f Binary files /dev/null and b/src/data/sprites/bolt-ghost.aseprite differ diff --git a/src/states/main-menu.lua b/src/states/main-menu.lua index 4458221..4017f8f 100644 --- a/src/states/main-menu.lua +++ b/src/states/main-menu.lua @@ -50,11 +50,12 @@ function MainMenu:init() do local tileSize = 16 local screenW, screenH = love.graphics.getDimensions() - local w = 16 * tileSize - local h = 16 * screenH/screenW * tileSize - self.canvas = love.graphics.newCanvas(w, h) + self.screenWidth = 16 * tileSize + self.screenHeight = 16 * screenH/screenW * tileSize local border = 2.5 + local w = self.screenWidth + local h = self.screenHeight self.ecs:queue{ collider = {0, 0, w, border} } self.ecs:queue{ collider = {0, 0, border, h} } self.ecs:queue{ collider = {w-border, 0, w, h} } @@ -80,6 +81,8 @@ function MainMenu:init() self.ecs:on("on_btn_pressed", function(btn) if btn == quit_btn then love.event.quit() + elseif btn == host_btn then + Gamestate.switch(require("states.main"), self.host_socket) end end) end @@ -107,7 +110,7 @@ end function MainMenu:draw() local ScreenScaler = self.ecs:getSystem(require("systems.screen-scaler")) - ScreenScaler:start(self.canvas) + ScreenScaler:start(self.screenWidth, self.screenHeight) self.ecs:emit("draw") ScreenScaler:finish() diff --git a/src/states/main.lua b/src/states/main.lua index 570af7f..487b775 100644 --- a/src/states/main.lua +++ b/src/states/main.lua @@ -52,11 +52,8 @@ function MainState:refreshDownscaledCanvas(map) end end - self.downscaled_canvas = love.graphics.newCanvas( - map.width * map.tilewidth, - map.height * map.tileheight - ) - self.downscaled_canvas:setFilter("nearest", "nearest") + self.screenWidth = map.width * map.tilewidth + self.screenHeight = map.height * map.tileheight end function MainState:update(dt) @@ -96,7 +93,7 @@ end function MainState:draw() local ScreenScaler = self.ecs:getSystem(require("systems.screen-scaler")) - ScreenScaler:start(self.downscaled_canvas) + ScreenScaler:start(self.screenWidth, self.screenHeight) self.ecs:emit("draw") ScreenScaler:finish() end diff --git a/src/systems/player.lua b/src/systems/player.lua index 7126fef..7bb3f6c 100644 --- a/src/systems/player.lua +++ b/src/systems/player.lua @@ -232,15 +232,27 @@ end function Player:draw() for _, e in ipairs(self.pool.groups.controllable_player.entities) do - if e.aim_dir.x ~= 0 or e.aim_dir.y ~= 0 then + if (e.aim_dir.x ~= 0 or e.aim_dir.y ~= 0) and #e.bolts > 0 then local boltSystem = self.pool:getSystem(require("systems.bolt")) local pos = e.pos + e.aim_dir * AIMED_BOLT_DISTANCE*0 local vel = (e.aim_dir * e.bolt_speed).normalized * AIMED_BOLT_DISTANCE*1 - local point_amount = 5 + local point_amount = 8 local points = boltSystem:projectTrajectory(pos, vel, point_amount+3) for i=3, point_amount+3-1 do - love.graphics.circle("line", points[i].x, points[i].y, 5) + local ghost = data.sprites["bolt-ghost"] + local point = points[i] + local frame = ghost.variants.default[1] + love.graphics.setColor(1, 1, 1, (point_amount-(i-3))/point_amount) + love.graphics.draw( + frame.image, + point.x, + point.y, + nil, + nil, + nil, + ghost.width/2, ghost.height/2 + ) end end end