LAYERS
This commit is contained in:
parent
5fa7860c94
commit
d69542cbb0
56
characters/bf-car-dead.json
Normal file
56
characters/bf-car-dead.json
Normal file
@ -0,0 +1,56 @@
|
||||
{
|
||||
"animations": [
|
||||
{
|
||||
"offsets": [
|
||||
37,
|
||||
11
|
||||
],
|
||||
"loop": false,
|
||||
"fps": 24,
|
||||
"anim": "firstDeath",
|
||||
"indices": [],
|
||||
"name": "BF dies"
|
||||
},
|
||||
{
|
||||
"offsets": [
|
||||
37,
|
||||
5
|
||||
],
|
||||
"loop": true,
|
||||
"fps": 24,
|
||||
"anim": "deathLoop",
|
||||
"indices": [],
|
||||
"name": "BF Dead Loop"
|
||||
},
|
||||
{
|
||||
"offsets": [
|
||||
37,
|
||||
69
|
||||
],
|
||||
"loop": false,
|
||||
"fps": 24,
|
||||
"anim": "deathConfirm",
|
||||
"indices": [],
|
||||
"name": "BF Dead confirm"
|
||||
}
|
||||
],
|
||||
"no_antialiasing": false,
|
||||
"image": "sprites/characters/BOYFRIEND_DEAD",
|
||||
"position": [
|
||||
0,
|
||||
350
|
||||
],
|
||||
"healthicon": "bf",
|
||||
"flip_x": false,
|
||||
"healthbar_colors": [
|
||||
49,
|
||||
176,
|
||||
209
|
||||
],
|
||||
"camera_position": [
|
||||
700,
|
||||
-300
|
||||
],
|
||||
"sing_duration": 4,
|
||||
"scale": 1
|
||||
}
|
@ -151,11 +151,12 @@ local function state(songName, songDifficulty)
|
||||
for index, module in next, modules do
|
||||
if module.onClose then
|
||||
module.onClose()
|
||||
modules[index] = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
modules = nil
|
||||
modules = {}
|
||||
|
||||
if not dead then
|
||||
inst:stop()
|
||||
@ -187,11 +188,12 @@ local function state(songName, songDifficulty)
|
||||
for index, module in next, modules do
|
||||
if module.onClose then
|
||||
module.onClose()
|
||||
modules[index] = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
modules = nil
|
||||
modules = {}
|
||||
|
||||
inst:stop()
|
||||
inst:release()
|
||||
@ -570,7 +572,7 @@ local function state(songName, songDifficulty)
|
||||
for i = 0, 3 do
|
||||
local receptor = myTypes.Rect("sprites/NOTE_assets.png", "sprites/NOTE_assets.json")
|
||||
receptor:Frame("arrow"..directions[i+1], 0)
|
||||
|
||||
receptor.layer = 9
|
||||
receptor.position = myTypes.Vector2(600 + (79* i), settings.Downscroll and 430 or 0)
|
||||
|
||||
receptor.ui = true -- So it doesnt move with the camera.
|
||||
@ -579,6 +581,8 @@ local function state(songName, songDifficulty)
|
||||
|
||||
local splash = myTypes.Sprite("sprites/noteSplashes.png", "sprites/noteSplashes.json")
|
||||
|
||||
splash.layer = 11
|
||||
|
||||
splash.position = myTypes.Vector2(550 + (79* i), settings.Downscroll and 380 or -50)
|
||||
splash.ui = true
|
||||
|
||||
@ -591,6 +595,7 @@ local function state(songName, songDifficulty)
|
||||
|
||||
receptor.position = myTypes.Vector2(50 + 79 * i, settings.Downscroll and 430 or 0)
|
||||
|
||||
receptor.layer = 9
|
||||
receptor.ui = true -- So it doesnt move with the camera.
|
||||
end
|
||||
|
||||
@ -627,6 +632,7 @@ local function state(songName, songDifficulty)
|
||||
|
||||
for i, module in next, modules do
|
||||
for i, func in next, module do
|
||||
if type(func) ~= "function" then goto evilContinue end
|
||||
local newEnv = getfenv(func)
|
||||
newEnv.game = {
|
||||
characters=characters,
|
||||
@ -638,6 +644,7 @@ local function state(songName, songDifficulty)
|
||||
zoom=zoom
|
||||
}
|
||||
setfenv(func, newEnv)
|
||||
::evilContinue::
|
||||
end
|
||||
module.characters = characters
|
||||
end
|
||||
|
@ -42,6 +42,7 @@ function module.character(name)
|
||||
sprite.position = module.myTypes.Vector2(parsed.position[1], parsed.position[2])
|
||||
|
||||
sprite.flipX = parsed.flip_x
|
||||
sprite.layer = 5
|
||||
|
||||
local newCharacter = setmetatable({
|
||||
scale = parsed.scale,
|
||||
|
@ -33,9 +33,10 @@ function NoteClass:spawn()
|
||||
local sprite = module.types.Rect("sprites/NOTE_assets.png", "sprites/NOTE_assets.json")
|
||||
|
||||
self.sprite = sprite
|
||||
|
||||
sprite.layer = 10
|
||||
local spriteName
|
||||
if self.hold then
|
||||
sprite.layer = 9
|
||||
if self.holdEnd then
|
||||
spriteName = string.format("%s hold end", sprites[self.direction])
|
||||
if self.flipY then
|
||||
|
@ -35,7 +35,8 @@ function module.Sprite(image, sheet)
|
||||
looping = false,
|
||||
extraOffset = module.myTypes.Vector2(0,0),
|
||||
rect = false,
|
||||
modifier = 1
|
||||
modifier = 1,
|
||||
layer = 0
|
||||
}, Sprite)
|
||||
|
||||
for index, sprite in next, atlas do
|
||||
@ -78,7 +79,8 @@ function module.Sprite(image, sheet)
|
||||
extraOffset = module.myTypes.Vector2(0,0),
|
||||
rect = false,
|
||||
modifier = 1,
|
||||
allowedFrame = 0
|
||||
allowedFrame = 0,
|
||||
layer = 0
|
||||
}, Sprite)
|
||||
|
||||
Sprites[#Sprites+1] = newSprite
|
||||
@ -176,54 +178,66 @@ function module.updateSprites(dt)
|
||||
end
|
||||
|
||||
function module.drawSprites()
|
||||
local everything = {}
|
||||
|
||||
for index, image in next, Images do
|
||||
if not image.ui then
|
||||
local cameraOffset = module.cameraPosition
|
||||
love.graphics.draw(image.image, image.position.x + cameraOffset.x * image.modifier , image.position.y + cameraOffset.y * image.modifier, image.rotation, image.resize.x * (image.flipX and -1 or 1), image.resize.y * (image.flipY and -1 or 1))
|
||||
end
|
||||
everything[#everything+1] = image
|
||||
image.isImage = true
|
||||
end
|
||||
|
||||
for index, sprite in next, Sprites do
|
||||
if sprite.animation and sprite.quads and sprite.quads[sprite.animation] then
|
||||
local quad = sprite.quads[sprite.animation][sprite.frame] or sprite.quads[sprite.animation][0]
|
||||
if quad then
|
||||
if quad.offset.x == 0 and quad.offset.y == 0 and sprite.quads[sprite.animation][0].offset.x ~= 0 then
|
||||
quad.offset.x = sprite.quads[sprite.animation][0].offset.x
|
||||
quad.offset.y = sprite.quads[sprite.animation][0].offset.y
|
||||
everything[#everything+1] = sprite
|
||||
sprite.isSprite = true
|
||||
end
|
||||
|
||||
for index, rect in next, Rects do
|
||||
everything[#everything+1] = rect
|
||||
rect.isRect = true
|
||||
end
|
||||
|
||||
table.sort(everything, function(a, b)
|
||||
return a.layer < b.layer
|
||||
end)
|
||||
|
||||
for index, thing in ipairs(everything) do
|
||||
|
||||
if thing.isImage then
|
||||
local cameraOffset = thing.ui and module.myTypes.Vector2() or module.cameraPosition
|
||||
love.graphics.draw(thing.image, thing.position.x + cameraOffset.x * thing.modifier , thing.position.y + cameraOffset.y * thing.modifier, thing.rotation, thing.resize.x * (thing.flipX and -1 or 1), thing.resize.y * (thing.flipY and -1 or 1))
|
||||
elseif thing.isSprite then
|
||||
local sprite = thing
|
||||
if sprite.animation and sprite.quads and sprite.quads[sprite.animation] then
|
||||
local quad = sprite.quads[sprite.animation][sprite.frame] or sprite.quads[sprite.animation][0]
|
||||
if quad then
|
||||
if quad.offset.x == 0 and quad.offset.y == 0 and sprite.quads[sprite.animation][0].offset.x ~= 0 then
|
||||
quad.offset.x = sprite.quads[sprite.animation][0].offset.x
|
||||
quad.offset.y = sprite.quads[sprite.animation][0].offset.y
|
||||
end
|
||||
if sprite.flipX and not quad.flipped then
|
||||
quad.flipped = true
|
||||
quad.offset.x = -quad.offset.x
|
||||
end
|
||||
|
||||
local cameraOffset = sprite.ui and module.myTypes.Vector2() or module.cameraPosition or module.myTypes.Vector2()
|
||||
|
||||
love.graphics.draw(sprite.image, quad.quad, (sprite.position.x + (sprite.position.x - quad.offset.x - sprite.extraOffset.x) + cameraOffset.x * sprite.modifier), (sprite.position.y + (sprite.position.y - quad.offset.y - sprite.extraOffset.y) + cameraOffset.y * sprite.modifier), 0, quad.resize.x * (sprite.flipX and -1 or 1), quad.resize.y* (sprite.flipY and -1 or 1))
|
||||
end
|
||||
if sprite.flipX and not quad.flipped then
|
||||
end
|
||||
elseif thing.isRect then
|
||||
local rect = thing
|
||||
if rect.animation then
|
||||
local quad = rect.quads[rect.animation][0]
|
||||
if rect.flipX and not quad.flipped then
|
||||
quad.flipped = true
|
||||
quad.offset.x = -quad.offset.x
|
||||
end
|
||||
|
||||
local cameraOffset = sprite.ui and module.myTypes.Vector2() or module.cameraPosition or module.myTypes.Vector2()
|
||||
local cameraOffset = rect.ui and module.myTypes.Vector2() or module.cameraPosition or module.myTypes.Vector2()
|
||||
|
||||
love.graphics.draw(sprite.image, quad.quad, (sprite.position.x + (sprite.position.x - quad.offset.x - sprite.extraOffset.x) + cameraOffset.x * sprite.modifier), (sprite.position.y + (sprite.position.y - quad.offset.y - sprite.extraOffset.y) + cameraOffset.y * sprite.modifier), 0, quad.resize.x * (sprite.flipX and -1 or 1), quad.resize.y* (sprite.flipY and -1 or 1))
|
||||
love.graphics.draw(rect.image, quad.quad, (rect.position.x + (rect.position.x - quad.offset.x - rect.extraOffset.x) + cameraOffset.x * rect.modifier), (rect.position.y + (rect.position.y - quad.offset.y - rect.extraOffset.y) + cameraOffset.y * rect.modifier), 0, quad.resize.x * (rect.flipX and -1 or 1), quad.resize.y* (rect.flipY and -1 or 1))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
for index, rect in next, Rects do
|
||||
if rect.animation then
|
||||
local quad = rect.quads[rect.animation][0]
|
||||
if rect.flipX and not quad.flipped then
|
||||
quad.flipped = true
|
||||
quad.offset.x = -quad.offset.x
|
||||
end
|
||||
|
||||
local cameraOffset = rect.ui and module.myTypes.Vector2() or module.cameraPosition or module.myTypes.Vector2()
|
||||
|
||||
love.graphics.draw(rect.image, quad.quad, (rect.position.x + (rect.position.x - quad.offset.x - rect.extraOffset.x) + cameraOffset.x * rect.modifier), (rect.position.y + (rect.position.y - quad.offset.y - rect.extraOffset.y) + cameraOffset.y * rect.modifier), 0, quad.resize.x * (rect.flipX and -1 or 1), quad.resize.y* (rect.flipY and -1 or 1))
|
||||
end
|
||||
end
|
||||
|
||||
for index, image in next, Images do
|
||||
if image.ui then
|
||||
local cameraOffset = image.ui and module.myTypes.Vector2()
|
||||
|
||||
love.graphics.draw(image.image, (image.position.x) + cameraOffset.x, image.position.y + cameraOffset.y, image.rotation, image.resize.x * (image.flipX and -1 or 1), image.resize.y)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function module.Rect(image, sheet)
|
||||
@ -249,7 +263,8 @@ function module.Rect(image, sheet)
|
||||
looping = false,
|
||||
extraOffset = module.myTypes.Vector2(0,0),
|
||||
rect = false,
|
||||
modifier = 1
|
||||
modifier = 1,
|
||||
layer = 0
|
||||
}, Sprite)
|
||||
|
||||
for index, sprite in next, atlas do
|
||||
@ -291,7 +306,8 @@ function module.Rect(image, sheet)
|
||||
looping = false,
|
||||
extraOffset = module.myTypes.Vector2(0,0),
|
||||
rect = false,
|
||||
modifier = 1
|
||||
modifier = 1,
|
||||
layer = 0
|
||||
}, Sprite)
|
||||
|
||||
Sprites[#Sprites+1] = newSprite
|
||||
@ -323,7 +339,8 @@ function module.Image(path, scrollFactor)
|
||||
resize = module.myTypes.Vector2(1,1),
|
||||
position = module.myTypes.Vector2(),
|
||||
modifier = scrollFactor or 1,
|
||||
rotation = 0
|
||||
rotation = 0,
|
||||
layer = 0
|
||||
}, Image)
|
||||
|
||||
Images[#Images+1] = newImage
|
||||
|
@ -3,13 +3,16 @@ local myTypes = require("modules.types")
|
||||
return {
|
||||
onCreate = function(song)
|
||||
local back = myTypes.Image("images/stage/stageback.png")
|
||||
back.layer = -10
|
||||
back.position = myTypes.Vector2(-800, 50)
|
||||
|
||||
local front = myTypes.Image("images/stage/stagefront.png")
|
||||
front.layer = -1
|
||||
front.position = myTypes.Vector2(-900, 1000)
|
||||
|
||||
local curtains = myTypes.Image("images/stage/stagecurtains.png")
|
||||
curtains.position = myTypes.Vector2(-1150, 50)
|
||||
curtains.modifier = 1.3
|
||||
curtains.layer = 5
|
||||
end
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user