Event stuff

This commit is contained in:
entar 2025-06-08 06:56:02 +07:00
parent d69542cbb0
commit f22131dbce
4 changed files with 462 additions and 14 deletions

346
charts/bopeebo/events.json Normal file
View File

@ -0,0 +1,346 @@
{
"song": {
"player1": "bf",
"song": "Bopeebo",
"player2": "dad",
"notes": [
{
"lengthInSteps": 16,
"sectionNotes": [],
"mustHitSection": false
},
{
"lengthInSteps": 16,
"sectionNotes": [
[
4290,
-1,
"Hey!",
"0",
""
]
],
"mustHitSection": true
},
{
"lengthInSteps": 16,
"sectionNotes": [],
"mustHitSection": false
},
{
"lengthInSteps": 16,
"sectionNotes": [
[
9090,
-1,
"Hey!",
"0",
""
]
],
"mustHitSection": true
},
{
"lengthInSteps": 16,
"sectionNotes": [],
"mustHitSection": false
},
{
"lengthInSteps": 16,
"sectionNotes": [
[
13890,
-1,
"Hey!",
"0",
""
]
],
"mustHitSection": true
},
{
"lengthInSteps": 16,
"sectionNotes": [],
"mustHitSection": false
},
{
"lengthInSteps": 16,
"sectionNotes": [
[
18690,
-1,
"Hey!",
"0",
""
]
],
"mustHitSection": true
},
{
"lengthInSteps": 16,
"sectionNotes": [],
"mustHitSection": false
},
{
"lengthInSteps": 16,
"sectionNotes": [
[
23490,
-1,
"Hey!",
"0",
""
]
],
"mustHitSection": true
},
{
"lengthInSteps": 16,
"sectionNotes": [],
"mustHitSection": false
},
{
"lengthInSteps": 16,
"sectionNotes": [
[
28290,
-1,
"Hey!",
"0",
""
]
],
"mustHitSection": true
},
{
"lengthInSteps": 16,
"sectionNotes": [],
"mustHitSection": false
},
{
"lengthInSteps": 16,
"sectionNotes": [
[
33090,
-1,
"Hey!",
"0",
""
]
],
"mustHitSection": true
},
{
"lengthInSteps": 16,
"sectionNotes": [],
"mustHitSection": false
},
{
"lengthInSteps": 16,
"sectionNotes": [
[
37890,
-1,
"Hey!",
"0",
""
]
],
"mustHitSection": true
},
{
"lengthInSteps": 16,
"sectionNotes": [],
"mustHitSection": false
},
{
"lengthInSteps": 16,
"sectionNotes": [
[
42690,
-1,
"Hey!",
"0",
""
]
],
"mustHitSection": true
},
{
"lengthInSteps": 16,
"sectionNotes": [],
"mustHitSection": false
},
{
"lengthInSteps": 16,
"sectionNotes": [
[
47490,
-1,
"Hey!",
"0",
""
]
],
"mustHitSection": true
},
{
"lengthInSteps": 16,
"sectionNotes": [],
"mustHitSection": false
},
{
"lengthInSteps": 16,
"sectionNotes": [
[
52290,
-1,
"Hey!",
"0",
""
]
],
"mustHitSection": true
},
{
"lengthInSteps": 16,
"sectionNotes": [],
"mustHitSection": false
},
{
"lengthInSteps": 16,
"sectionNotes": [
[
57090,
-1,
"Hey!",
"0",
""
]
],
"mustHitSection": true
},
{
"lengthInSteps": 16,
"sectionNotes": [],
"mustHitSection": false
},
{
"lengthInSteps": 16,
"sectionNotes": [
[
61890,
-1,
"Hey!",
"0",
""
]
],
"mustHitSection": true
},
{
"lengthInSteps": 16,
"sectionNotes": [],
"mustHitSection": false
},
{
"lengthInSteps": 16,
"sectionNotes": [
[
66690,
-1,
"Hey!",
"0",
""
]
],
"mustHitSection": true
},
{
"lengthInSteps": 16,
"sectionNotes": [],
"mustHitSection": false
},
{
"lengthInSteps": 16,
"sectionNotes": [
[
71490,
-1,
"Hey!",
"0",
""
]
],
"mustHitSection": true
},
{
"lengthInSteps": 16,
"sectionNotes": [],
"mustHitSection": false
},
{
"lengthInSteps": 16,
"sectionNotes": [
[
76290,
-1,
"Hey!",
"0",
""
]
],
"mustHitSection": true
},
{
"sectionNotes": [],
"typeOfSection": 0,
"lengthInSteps": 16,
"altAnim": false,
"mustHitSection": true,
"changeBPM": false,
"bpm": 100
},
{
"sectionNotes": [],
"typeOfSection": 0,
"lengthInSteps": 16,
"altAnim": false,
"mustHitSection": true,
"changeBPM": false,
"bpm": 100
},
{
"sectionNotes": [],
"typeOfSection": 0,
"lengthInSteps": 16,
"altAnim": false,
"mustHitSection": true,
"changeBPM": false,
"bpm": 100
},
{
"sectionNotes": [],
"typeOfSection": 0,
"lengthInSteps": 16,
"altAnim": false,
"mustHitSection": true,
"changeBPM": false,
"bpm": 100
},
{
"lengthInSteps": 16,
"altAnim": false,
"typeOfSection": 0,
"sectionNotes": [],
"bpm": 100,
"changeBPM": false,
"mustHitSection": true
}
],
"needsVoices": true,
"validScore": true,
"bpm": 100,
"speed": 1.3
}
}

View File

@ -56,6 +56,8 @@ local function state(songName, songDifficulty)
local unspawnedHoldNotes = {}
local holdNotes = {}
local events = {}
local characters = {}
local icons = {}
@ -441,6 +443,20 @@ local function state(songName, songDifficulty)
end
end
for index, event in next, events do
if event.time - elapsed < 0 then
events[index] = nil
if event.name == "change character" then
characters[event.var1] = myTypes.character(event.var2)
elseif event.name == "play animation" then
characters[event.var2]:PlayAnimation(event.var1)
elseif event.name == "hey!" then
characters.bf:PlayAnimation("hey")
end
end
end
zoom = myMath.lerp(zoom, 1, .05)
if inst and inst:getVolume() ~= volume / 100 then
@ -602,24 +618,95 @@ local function state(songName, songDifficulty)
-- Load the notes AFTER the receptors to make sure they are always above them
for index, section in next, chart.notes do
for index, note in next, section.sectionNotes do
local newNote = myTypes.note(note, section.mustHitSection)
unspawnedNotes[#unspawnedNotes+1] = newNote
if note[2] >= 0 then
local newNote = myTypes.note(note, section.mustHitSection)
unspawnedNotes[#unspawnedNotes+1] = newNote
if note[3] > 0 then
local length = math.floor(note[3] / conductor.stepCrochet)
if note[3] > 0 then
local length = math.floor(note[3] / conductor.stepCrochet)
for i = 0, length - .1, .1 do
local newHold = myTypes.note({note[1] + i * conductor.stepCrochet, note[2], note[3], note[4]}, section.mustHitSection, true)
for i = 0, length - .1, .1 do
local newHold = myTypes.note({note[1] + i * conductor.stepCrochet, note[2], note[3], note[4]}, section.mustHitSection, true)
unspawnedHoldNotes[#unspawnedHoldNotes+1] = newHold
end
local newHold = myTypes.note({note[1] + length * conductor.stepCrochet, note[2], note[3], note[4]}, section.mustHitSection, true, true)
unspawnedHoldNotes[#unspawnedHoldNotes+1] = newHold
newHold.holdEnd = true
if settings.Downscroll then
newHold.flipY = true
end
newHold.speed = speed
end
local newHold = myTypes.note({note[1] + length * conductor.stepCrochet, note[2], note[3], note[4]}, section.mustHitSection, true, true)
unspawnedHoldNotes[#unspawnedHoldNotes+1] = newHold
newHold.holdEnd = true
if settings.Downscroll then
newHold.flipY = true
else
local newEvent = {
time = note[1],
name = string.lower(note[3]),
var1 = string.lower(note[4]),
var2 = string.lower(note[5])
}
events[#events+1] = newEvent
if newEvent.name == "change character" then
myTypes.preloadChar(newEvent.var2)
end
newHold.speed = speed
end
end
end
local eventChartFile = files.read_file(string.format("charts/%s/events.json", songName))
if eventChartFile then
local eventChart = json.parse(eventChartFile)
if eventChart.notes then
for index, section in next, eventChart.notes do
for index, note in next, section.sectionNotes do
local newEvent = {
time = note[1],
name = string.lower(note[3]),
var1 = string.lower(note[4]),
var2 = string.lower(note[5])
}
events[#events+1] = newEvent
if newEvent.name == "change character" then
myTypes.preloadChar(newEvent.var2)
end
end
end
end
if eventChart.events then
for index, event in next, eventChart.events do
for index in next, event[2] do
local newEvent = {
time = event[1],
name = string.lower(event[2][index][1]),
var1 = string.lower(event[2][index][2]),
var2 = string.lower(event[2][index][3])
}
events[#events+1] = newEvent
if newEvent.name == "change character" then
myTypes.preloadChar(newEvent.var2)
end
end
end
end
end
for index, event in next, chart.events do
for index in next, event[2] do
local newEvent = {
time = event[1],
name = string.lower(event[2][index][1]),
var1 = string.lower(event[2][index][2]),
var2 = string.lower(event[2][index][3])
}
events[#events+1] = newEvent
if newEvent.name == "change character" then
myTypes.preloadChar(newEvent.var2)
end
end
end

View File

@ -18,10 +18,10 @@ module.Image = renderClasses.Image
module.destroyAllSprites = renderClasses.destroyAllSprites
module.drawSprites = renderClasses.drawSprites
module.updateSprites = renderClasses.updateSprites
module.preload = renderClasses.preLoad
module.Vector2 = vectorClass.Vector2
module.render = renderClasses
return module

View File

@ -72,4 +72,19 @@ function module.character(name)
return newCharacter
end
function module.preload(name)
local charFile = files.read_file(string.format("characters/%s.json", name))
if not charFile then
error("Failed to load character "..name)
end
local parsed = json.parse(charFile)
local image = parsed.image..".png"
local sheet = parsed.image..".json"
module.myTypes.preload(image, sheet)
end
return module