From 516ed301bddc7334363cd42d5450ee77bb440a59 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sat, 27 Nov 2021 13:11:05 +0100 Subject: [PATCH] fix: multi-directionnal weapons --- .../subgames/world/actors/weapons/parent.lua | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/sonic-bluestreak.love/game/modules/subgames/world/actors/weapons/parent.lua b/sonic-bluestreak.love/game/modules/subgames/world/actors/weapons/parent.lua index 6eb1bfe..e3d1f5d 100644 --- a/sonic-bluestreak.love/game/modules/subgames/world/actors/weapons/parent.lua +++ b/sonic-bluestreak.love/game/modules/subgames/world/actors/weapons/parent.lua @@ -1,13 +1,13 @@ local Parent = require "game.modules.subgames.world.actors.parent" local WeaponShot = Parent:extend() -function WeaponShot:new(world, x, y, z, direction, data, creator) +function WeaponShot:new(world, x, y, z, angle, data, creator) WeaponShot.super.new(self, world, "shot", x, y, z, 16, 8, 16, false) self:setSprite("ringweapon", 0, 0) - self.direction = direction + self.angle = -angle self.data = data self.zsp = self.data.zspeed - self.xsp = (self.data.xspeed * direction) + self.xsp, self.ysp = utils.math.lengthdir(self.data.xspeed, angle) self.xfrc, self.yfrc = 0, 0 if (self.zsp ~= 0) then self:setGravity(480*2) @@ -16,7 +16,13 @@ function WeaponShot:new(world, x, y, z, direction, data, creator) end function WeaponShot:updateStart(dt) - if (self.xsp == 0) then + if (self.xsp == 0 and self.ysp == 0) then + self:destroy() + end +end + +function WeaponShot:collisionResponse(collision) + if collision.other.isSolid then self:destroy() end end @@ -25,9 +31,10 @@ function WeaponShot:draw() love.graphics.setColor(self.data.color[1], self.data.color[2], self.data.color[3], 1) WeaponShot.super.draw(self) love.graphics.setColor(self.data.color[1], self.data.color[2], self.data.color[3], 0.6) - local x, y = self.x + self.y/2 + 8, self.y - self.z - 3 + --local x, y = self.x + self.y/2 + 8, self.y - self.z - 3 + local x, y = self:computeDrawingPosition() local angle = utils.math.pointDirection(0, 0, self.xsp, self.zsp * -1) - self.scene.assets.sprites["ringtoss"]:draw(x, y, angle) + self.scene.assets.sprites["ringtoss"]:draw(x + 8, y + 8, self.angle) love.graphics.setColor(1, 1, 1, 1) end