feat: rings and boxes

This commit is contained in:
Kazhnuz 2021-03-22 21:15:33 +01:00
parent 8bce75aad9
commit 62d9684944
10 changed files with 290 additions and 3 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

View file

@ -8,8 +8,8 @@ return {
height = 40, height = 40,
tilewidth = 16, tilewidth = 16,
tileheight = 16, tileheight = 16,
nextlayerid = 7, nextlayerid = 10,
nextobjectid = 13, nextobjectid = 25,
properties = {}, properties = {},
tilesets = { tilesets = {
{ {
@ -442,6 +442,181 @@ return {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 23, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 23, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
} }
}, },
{
type = "objectgroup",
draworder = "topdown",
id = 7,
name = "ring",
visible = true,
opacity = 1,
offsetx = 0,
offsety = 0,
properties = {},
objects = {
{
id = 13,
name = "",
type = "",
shape = "rectangle",
x = 112,
y = 144,
width = 16,
height = 16,
rotation = 0,
visible = true,
properties = {}
},
{
id = 14,
name = "",
type = "",
shape = "rectangle",
x = 112,
y = 176,
width = 16,
height = 16,
rotation = 0,
visible = true,
properties = {}
},
{
id = 15,
name = "",
type = "",
shape = "rectangle",
x = 112,
y = 208,
width = 16,
height = 16,
rotation = 0,
visible = true,
properties = {}
},
{
id = 16,
name = "",
type = "",
shape = "rectangle",
x = 112,
y = 240,
width = 16,
height = 16,
rotation = 0,
visible = true,
properties = {}
},
{
id = 17,
name = "",
type = "",
shape = "rectangle",
x = 112,
y = 272,
width = 16,
height = 16,
rotation = 0,
visible = true,
properties = {}
},
{
id = 18,
name = "",
type = "",
shape = "rectangle",
x = 288,
y = 272,
width = 16,
height = 16,
rotation = 0,
visible = true,
properties = {}
},
{
id = 19,
name = "",
type = "",
shape = "rectangle",
x = 320,
y = 272,
width = 16,
height = 16,
rotation = 0,
visible = true,
properties = {}
},
{
id = 20,
name = "",
type = "",
shape = "rectangle",
x = 352,
y = 272,
width = 16,
height = 16,
rotation = 0,
visible = true,
properties = {}
}
}
},
{
type = "objectgroup",
draworder = "topdown",
id = 8,
name = "itembox",
visible = true,
opacity = 1,
offsetx = 0,
offsety = 0,
properties = {},
objects = {
{
id = 24,
name = "",
type = "",
shape = "rectangle",
x = 48,
y = 64,
width = 16,
height = 16,
rotation = 0,
visible = true,
properties = {
["category"] = "medicines",
["item"] = "healthseed",
["number"] = "5"
}
}
}
},
{
type = "objectgroup",
draworder = "topdown",
id = 9,
name = "ringbox",
visible = true,
opacity = 1,
offsetx = 0,
offsety = 0,
properties = {},
objects = {
{
id = 22,
name = "",
type = "",
shape = "rectangle",
x = 96,
y = 64,
width = 16,
height = 16,
rotation = 0,
visible = true,
properties = {
["number"] = 500
}
}
}
},
{ {
type = "objectgroup", type = "objectgroup",
draworder = "topdown", draworder = "topdown",

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<map version="1.4" tiledversion="1.4.3" orientation="orthogonal" renderorder="right-down" width="30" height="40" tilewidth="16" tileheight="16" infinite="0" nextlayerid="7" nextobjectid="13"> <map version="1.4" tiledversion="1.4.3" orientation="orthogonal" renderorder="right-down" width="30" height="40" tilewidth="16" tileheight="16" infinite="0" nextlayerid="10" nextobjectid="25">
<editorsettings> <editorsettings>
<export target="test.lua" format="lua"/> <export target="test.lua" format="lua"/>
</editorsettings> </editorsettings>
@ -92,6 +92,32 @@
0,0,0,0,0,0,0,0,0,0,23,24,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 0,0,0,0,0,0,0,0,0,0,23,24,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
</data> </data>
</layer> </layer>
<objectgroup id="7" name="ring">
<object id="13" x="112" y="144" width="16" height="16"/>
<object id="14" x="112" y="176" width="16" height="16"/>
<object id="15" x="112" y="208" width="16" height="16"/>
<object id="16" x="112" y="240" width="16" height="16"/>
<object id="17" x="112" y="272" width="16" height="16"/>
<object id="18" x="288" y="272" width="16" height="16"/>
<object id="19" x="320" y="272" width="16" height="16"/>
<object id="20" x="352" y="272" width="16" height="16"/>
</objectgroup>
<objectgroup id="8" name="itembox">
<object id="24" x="48" y="64" width="16" height="16">
<properties>
<property name="category" value="medicines"/>
<property name="item" value="healthseed"/>
<property name="number" value="5"/>
</properties>
</object>
</objectgroup>
<objectgroup id="9" name="ringbox">
<object id="22" x="96" y="64" width="16" height="16">
<properties>
<property name="number" type="int" value="500"/>
</properties>
</object>
</objectgroup>
<objectgroup id="6" name="gizmo"> <objectgroup id="6" name="gizmo">
<object id="4" x="176" y="112" width="16" height="16"> <object id="4" x="176" y="112" width="16" height="16">
<properties> <properties>

View file

@ -4,10 +4,16 @@ local Obj = {}
local cwd = (...):gsub('%.init$', '') .. "." local cwd = (...):gsub('%.init$', '') .. "."
Obj.Player = require(cwd .. "player") Obj.Player = require(cwd .. "player")
Obj.Gizmo = require(cwd .. "gizmo") Obj.Gizmo = require(cwd .. "gizmo")
Obj.Ring = require(cwd .. "ring")
Obj.ItemBox = require(cwd .. "itembox")
Obj.RingBox = require(cwd .. "ringbox")
Obj.index = {} Obj.index = {}
Obj.index["player"] = Obj.Player Obj.index["player"] = Obj.Player
Obj.index["gizmo"] = Obj.Gizmo Obj.index["gizmo"] = Obj.Gizmo
Obj.index["ring"] = Obj.Ring
Obj.index["itembox"] = Obj.ItemBox
Obj.index["ringbox"] = Obj.RingBox
Obj.collisions = {} Obj.collisions = {}
Obj.collisions["wall"] = require(cwd .. "wall") Obj.collisions["wall"] = require(cwd .. "wall")

View file

@ -0,0 +1,27 @@
local cwd = (...):gsub('%.itembox$', '') .. "."
local Gizmo = require(cwd .. "gizmo")
local ItemBox = Gizmo:extend()
local overrides = {
["isSolid"] = true,
["charset"] = "item1",
["charId"] = 1,
["charDir"] = "right",
["destroy"] = "temp",
["needButton"] = true,
}
function ItemBox:new(world, x, y)
ItemBox.super.new(self, world, x, y, 16, 16, overrides)
end
function ItemBox:applyProperties()
ItemBox.super.applyProperties(self)
self.event = {
{"getItems", "", self.properties.category, self.properties.item, self.properties.number},
{"playSFX", "", "pop"},
{"simpleMessage", "", "You got " .. self.properties.number .. " " .. self.properties.item},
}
end
return ItemBox

View file

@ -0,0 +1,24 @@
local cwd = (...):gsub('%.ring$', '') .. "."
local Gizmo = require(cwd .. "gizmo")
local Ring = Gizmo:extend()
local overrides = {
["isSolid"] = false,
["charset"] = "item1",
["charId"] = 2,
["destroy"] = "temp",
["needButton"] = false,
["isTurning"] = true,
}
function Ring:new(world, x, y)
Ring.super.new(self, world, x, y, 16, 16, overrides)
end
function Ring:action()
self.assets.sfx["ring"]:stop()
self.assets.sfx["ring"]:play()
game.loot.rings = game.loot.rings + 1
end
return Ring

View file

@ -0,0 +1,27 @@
local cwd = (...):gsub('%.ringbox$', '') .. "."
local Gizmo = require(cwd .. "gizmo")
local RingBox = Gizmo:extend()
local overrides = {
["isSolid"] = true,
["charset"] = "item1",
["charId"] = 1,
["charDir"] = "down",
["destroy"] = "temp",
["needButton"] = true,
}
function RingBox:new(world, x, y)
RingBox.super.new(self, world, x, y, 16, 16, overrides)
end
function RingBox:applyProperties()
RingBox.super.applyProperties(self)
self.event = {
{"getRings", "", self.properties.number},
{"playSFX", "", "pop"},
{"simpleMessage", "", "You got " .. self.properties.number .. " rings"},
}
end
return RingBox

View file

@ -47,6 +47,8 @@ return {
{"woosh", "assets/sfx/woosh.wav"}, {"woosh", "assets/sfx/woosh.wav"},
{"spincharge", "assets/sfx/spincharge.wav"}, {"spincharge", "assets/sfx/spincharge.wav"},
{"spinrelease", "assets/sfx/spinrelease.wav"}, {"spinrelease", "assets/sfx/spinrelease.wav"},
{"ring", "assets/sfx/ring.wav"},
{"pop", "assets/sfx/pop.wav"},
{"mBack", "assets/sfx/menus/back.wav"}, {"mBack", "assets/sfx/menus/back.wav"},
{"mBeep", "assets/sfx/menus/beep.wav"}, {"mBeep", "assets/sfx/menus/beep.wav"},