From dd4d21272197c24327d2f4a6f0f0599d3df00e99 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Wed, 21 Apr 2021 21:14:45 +0200 Subject: [PATCH] feat: add GFX on the overworld Fixes #91 --- .../assets/sprites/gfx/smallsmoke.lua | 12 ++++----- .../assets/sprites/gfx/smallsmoke.png | Bin 1192 -> 1182 bytes .../assets/sprites/gfx/sparkles.lua | 18 +++++++++++++ .../assets/sprites/gfx/sparkles.png | Bin 0 -> 785 bytes sonic-radiance.love/game/events/arguments.lua | 3 ++- .../game/events/event/init.lua | 3 ++- .../game/events/event/showGFX.lua | 16 ++++++++++++ .../scenes/overworld/actors/gfx.lua | 24 ++++++++++++++++++ .../scenes/overworld/actors/init.lua | 1 + .../scenes/overworld/actors/loot/itembox.lua | 1 + .../scenes/overworld/actors/loot/ring.lua | 2 +- .../scenes/overworld/actors/loot/ringbox.lua | 1 + .../scenes/overworld/assets.lua | 2 ++ 13 files changed, 74 insertions(+), 9 deletions(-) create mode 100644 sonic-radiance.love/assets/sprites/gfx/sparkles.lua create mode 100644 sonic-radiance.love/assets/sprites/gfx/sparkles.png create mode 100644 sonic-radiance.love/game/events/event/showGFX.lua create mode 100644 sonic-radiance.love/scenes/overworld/actors/gfx.lua diff --git a/sonic-radiance.love/assets/sprites/gfx/smallsmoke.lua b/sonic-radiance.love/assets/sprites/gfx/smallsmoke.lua index 4dbd8f2..f03c073 100644 --- a/sonic-radiance.love/assets/sprites/gfx/smallsmoke.lua +++ b/sonic-radiance.love/assets/sprites/gfx/smallsmoke.lua @@ -1,18 +1,18 @@ return { metadata = { - height = 16, - width = 16, + width = 18, + height = 22, defaultAnim = "default", - ox = 8, - oy = 8, + ox = 9, + oy = 11, }, animations = { ["default"] = { startAt = 1, - endAt = 8, + endAt = 5, loop = 1, speed = 15, - pauseAtEnd = false, + pauseAtEnd = true, }, } } diff --git a/sonic-radiance.love/assets/sprites/gfx/smallsmoke.png b/sonic-radiance.love/assets/sprites/gfx/smallsmoke.png index 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DPoHwF*V35Nd^19ZW9$ zf+h_~ii@M*T5#}VvFhOBtgC~oAP9bdI5|2gx=4xtOA9T3VmvtR$GdxvyLW(4Ei%n& z8wWJqHWRU^m`bmTfma03j}8oDNM@EXCrNR5j<0+8_<9%NS>EUV9NlWhVt`L1o@It< z6K@btZ`uauec}+y%PR3X@t8>$B!1+&Qs+0$IhO^V88VZJdEyYUm}_CBg<0Ozh^L6d zs-{!EkgBtP%6W^kRxGo|J^2fR8GU7$>of-u!y=X-L4<-b3Mj%xgjSst3klkfdiV!i zzeFyDTm>+4ET9Apvg-%`gWug+*~y7|QZNd%zc|jv2oTr>Y8A)%K6aei3E+PQuJoqA zR0U=}Nv|}u@Db3n4P0C|HDwRD+yVNY4B3=j$xl->$Yz1}Gy0}9(0dDXt<`&L?BnzS zNK#kv8{ps&7|l`ky2raaTYLNWOryUaYm{=N+*^0#le_^i4&(%GX|(+IoNB4UBDNoj>>7xT{xx6GQb8>`ekF5T{2u2`amX&KW%L22PLC zJG)FEQUAJi@JztiR@V7zvfku(R~4X7N{Cn?KWb*om1wlFt=_=L47FvtF35B|0bvY6unu-j-n)a5`Q`nurxfKk61R?rJ%fUe}R; z#wzY=uc}ECY>U1ACIpDP8X{K6rpU)cnnQ5D%1rjvP6Q6i_Zl+l8o?!pIFw|6Iv=OU zSHtH5pjsW`?z_`pBO^=5^RaUP+n(2Fu1{cSU?Wz@QcsCw%FNg0oA9(p;F$n+58-wB zYQ998YklB4P50I3EQ!k}dXL>51gV6fSuxi@(yF1`v(JG>!O#I?A~QCxuChUWzb>_R zlfG*LY;}@IgQ~msY2w<(QG%`{wSxdVsd_##K*t{h_~G^!)_%Sdx!ws)00000NkvXX Hu0mjf<&F|$ diff --git a/sonic-radiance.love/assets/sprites/gfx/sparkles.lua b/sonic-radiance.love/assets/sprites/gfx/sparkles.lua new file mode 100644 index 0000000..bf392eb --- /dev/null +++ b/sonic-radiance.love/assets/sprites/gfx/sparkles.lua @@ -0,0 +1,18 @@ +return { + metadata = { + width = 16, + height = 16, + defaultAnim = "default", + ox = 8, + oy = 8, + }, + animations = { + ["default"] = { + startAt = 1, + endAt = 4, + loop = 1, + speed = 20, + pauseAtEnd = true, + }, + } +} diff --git a/sonic-radiance.love/assets/sprites/gfx/sparkles.png b/sonic-radiance.love/assets/sprites/gfx/sparkles.png new file mode 100644 index 0000000000000000000000000000000000000000..4415eb1d53a157f316f2537db1211dc77b73e6c9 GIT binary patch literal 785 zcmV+s1Md8ZP)EX>4Tx04R}tk-ba9P!z>a(~3nZA}WY<$WR@`f+&cCi&ZQ_g-|P4bufAT5|T6| zDK3tJYr#Qu@oUgOKy-C*6$C*ML|ps_{92^M`;tJ5v_5#;Urz2lymuZToU2T;LZg7D z+h#hM5SOznV*49H=tDPR2+PberX?wbmh1Zg0bcLp+^cn8)76>FTMP(@#BH~ z#HMX(x#+SG=4@utGsID1vDm;$1GAE;5l<1va+*&5 z!n(&f&fAm$*e;(9TfnMIjAW!C}xE&gU~6~@OrrwBQ>y*SRtAke-G)T)m2bL=>^6Cn5uTK$&gLim4dW|LIHR`qvy&3J$FFIs+XVtAE%E% zW(!E&0{aKRP?5aXTHHJA=Qoc9NdNZu3H}1y*mSIEA!iBz000JJOGiWi{{a60|De66 zlK=n!32;bRa{vG?BLDy{BLR4&KXw2B00(qQO+^Rg1Qinn7x>;yR{#J29CSrkbVF}# zZDnqB07G(RVRU6=Aa`kWXdp*yX>D+GW$sQG2LJ#7+et)0R9M5!S2+&DFbos&G=C{? z>E^e2O&=kEUD^&gXgM+>3CJXvA!%8bMRu{R1wx{ikBlkY(FC4+WK7`>R4@mD3QrX< z5*~9c+?cjMh^ihywzU9F092?dfC@A@{TU_j#W)knatzzb?MmALNL8u0uFH-x^sHsv zsJ6X>zwgS)yCkelh^-wpe@L690xTlDXWX-%nrG0~KPS$ssM~}LP1wWBq%D#_h7AZS z!7NAc@g|h235Q%mS+3#mK_qw(%Q1=ukK!pFBTqlZmYHDhS8?TMVT{BF$g0x$5i8qF P00000NkvXXu0mjfLPJ$Q literal 0 HcmV?d00001 diff --git a/sonic-radiance.love/game/events/arguments.lua b/sonic-radiance.love/game/events/arguments.lua index e642aa1..d1268a2 100644 --- a/sonic-radiance.love/game/events/arguments.lua +++ b/sonic-radiance.love/game/events/arguments.lua @@ -6,7 +6,8 @@ return { ["playSFX"] = {"sfx"}, ["getRings"] = {"number"}, ["getItems"] = {"type", "item", "number"}, - ["teleport"] = {"area", "x", "y", "charDir"} + ["teleport"] = {"area", "x", "y", "charDir"}, + ["showGFX"] = {"x", "y", "spritename"} --[name] = {args...}, } diff --git a/sonic-radiance.love/game/events/event/init.lua b/sonic-radiance.love/game/events/event/init.lua index 2c10671..15afa66 100644 --- a/sonic-radiance.love/game/events/event/init.lua +++ b/sonic-radiance.love/game/events/event/init.lua @@ -6,5 +6,6 @@ return { ["playSFX"] = require("game.events.event.playSFX"), ["getRings"] = require("game.events.event.getRings"), ["getItems"] = require("game.events.event.getItems"), - ["teleport"] = require("game.events.event.teleport") + ["teleport"] = require("game.events.event.teleport"), + ["showGFX"] = require("game.events.event.showGFX") } \ No newline at end of file diff --git a/sonic-radiance.love/game/events/event/showGFX.lua b/sonic-radiance.love/game/events/event/showGFX.lua new file mode 100644 index 0000000..2e83cbc --- /dev/null +++ b/sonic-radiance.love/game/events/event/showGFX.lua @@ -0,0 +1,16 @@ +local StepParent = require "game.events.event.parent" +local SimpleMessageStep = StepParent:extend() + +function SimpleMessageStep:new(controller, args) + SimpleMessageStep.super.new(self, controller, args) +end + +function SimpleMessageStep:start() + self.events.scene.world.obj.GFX(self.events.scene.world, self.arguments.x, self.arguments.y, self.arguments.spritename) +end + +function SimpleMessageStep:update(dt) + self:finish() +end + +return SimpleMessageStep; diff --git a/sonic-radiance.love/scenes/overworld/actors/gfx.lua b/sonic-radiance.love/scenes/overworld/actors/gfx.lua new file mode 100644 index 0000000..0ad5c02 --- /dev/null +++ b/sonic-radiance.love/scenes/overworld/actors/gfx.lua @@ -0,0 +1,24 @@ +local cwd = (...):gsub('%.gfx$', '') .. "." +local Parent = require(cwd .. "parent") +local GFX = Parent:extend() + +function GFX:new(world, x, y, spritename) + local width, height = world.scene.assets.sprites[spritename]:getDimensions() + + GFX.super.new(self, world, "gfx", x - (width/2), y - (height/2), width, height) + self:setSprite(spritename) + self:cloneSprite() + print(self.x, self.y, spritename) +end + +function GFX:animationEnded(animation) + core.debug:print("gfx2D", 'Current animation "' .. animation .. '" have ended, destroying gfx') + self:destroy() +end + +function GFX:draw() + local x, y = math.floor(self.x), math.floor(self.y) + self:drawSprite(x, y) +end + +return GFX \ No newline at end of file diff --git a/sonic-radiance.love/scenes/overworld/actors/init.lua b/sonic-radiance.love/scenes/overworld/actors/init.lua index 7c6481f..4637d79 100644 --- a/sonic-radiance.love/scenes/overworld/actors/init.lua +++ b/sonic-radiance.love/scenes/overworld/actors/init.lua @@ -7,6 +7,7 @@ Obj.Gizmo = require(cwd .. "gizmo") Obj.Teleporter = require(cwd .. "teleport") Obj.PNJ = require(cwd .. "pnj") Obj.Encounter = require(cwd .. "encounter") +Obj.GFX = require(cwd .. "gfx") Obj.loot = require(cwd .. "loot") diff --git a/sonic-radiance.love/scenes/overworld/actors/loot/itembox.lua b/sonic-radiance.love/scenes/overworld/actors/loot/itembox.lua index 7c5f61b..23dd48d 100644 --- a/sonic-radiance.love/scenes/overworld/actors/loot/itembox.lua +++ b/sonic-radiance.love/scenes/overworld/actors/loot/itembox.lua @@ -21,6 +21,7 @@ function ItemBox:applyProperties() {"getItems", "", self.properties.category, self.properties.item, self.properties.number}, {"playSFX", "", "pop"}, {"simpleMessage", "", "You got " .. self.properties.number .. " " .. self.properties.item}, + {"showGFX", "", self.x + 16, self.y + 14, "smallsmoke"} } end diff --git a/sonic-radiance.love/scenes/overworld/actors/loot/ring.lua b/sonic-radiance.love/scenes/overworld/actors/loot/ring.lua index 242f45d..fb78260 100644 --- a/sonic-radiance.love/scenes/overworld/actors/loot/ring.lua +++ b/sonic-radiance.love/scenes/overworld/actors/loot/ring.lua @@ -15,9 +15,9 @@ function Ring:new(world, x, y) end function Ring:action() - self.assets.sfx["ring"]:stop() self.assets.sfx["ring"]:play() game.loot.rings = game.loot.rings + 1 + self.world.obj.GFX(self.world, self.x + 16, self.y + 12, "sparkles") end return Ring \ No newline at end of file diff --git a/sonic-radiance.love/scenes/overworld/actors/loot/ringbox.lua b/sonic-radiance.love/scenes/overworld/actors/loot/ringbox.lua index 56980a2..94c5369 100644 --- a/sonic-radiance.love/scenes/overworld/actors/loot/ringbox.lua +++ b/sonic-radiance.love/scenes/overworld/actors/loot/ringbox.lua @@ -21,6 +21,7 @@ function RingBox:applyProperties() {"getRings", "", self.properties.number}, {"playSFX", "", "pop"}, {"simpleMessage", "", "You got " .. self.properties.number .. " rings"}, + {"showGFX", "", self.x + 16, self.y + 14, "smallsmoke"} } end diff --git a/sonic-radiance.love/scenes/overworld/assets.lua b/sonic-radiance.love/scenes/overworld/assets.lua index 46187d3..a01c280 100644 --- a/sonic-radiance.love/scenes/overworld/assets.lua +++ b/sonic-radiance.love/scenes/overworld/assets.lua @@ -11,6 +11,8 @@ return { {"encounter", "assets/sprites/encounter"}, {"punch", "assets/sprites/gfx/punch"}, {"dash", "assets/sprites/gfx/dash"}, + {"smallsmoke", "assets/sprites/gfx/smallsmoke"}, + {"sparkles", "assets/sprites/gfx/sparkles"}, }, ["textures"] = { {"menucursor", "assets/gui/cursor-menulist.png"},