Mari0Maker wrote:How can I make this feature: when you enter the Konami Code, it has the possibility of playing one song, or another, or another different one.
And I don't want to use songs already included in Mari0, I want it to use new ones I add to the game.
Like playing a random sound? Easy (I think).
First of all: put the sounds you want in the "sounds" folder.
Go to main.lua, to the function
love.load.
Add to the music lists the musics you want. If you call them with something like konami1sound, konami2sound, konami3sound and so on, they'll be easier to be loaded in the future.
They are loaded like this:
Code: Select all
konamisound = love.audio.newSource("sounds/konami.ogg", "static");konamisound:setVolume(0);konamisound:play();konamisound:stop();konamisound:setVolume(1)
So add the file name of your sounds there.
Later, add them to the sound list:
Code: Select all
soundlist = {jumpsound, jumpbigsound, stompsound, shotsound, blockhitsound, blockbreaksound, coinsound, pipesound, boomsound, mushroomappearsound, mushroomeatsound, shrinksound, deathsound, gameoversound,
fireballsound, oneupsound, levelendsound, castleendsound, scoreringsound, intermissionsound, firesound, bridgebreaksound, bowserfallsound, vinesound, swimsound, rainboomsoud,
portal1opensound, portal2opensound, portalentersound, portalfizzlesound, lowtime, konamisound, pausesound, stabsound, bulletbillsound}
On the
love.keypressed function, change this:
Code: Select all
if key == konami[konamii] then
konamii = konamii + 1
if konamii == #konami+1 then
if konamisound:isStopped() then
playsound(konamisound)
end
gamefinished = true
saveconfig()
konamii = 1
end
else
konamii = 1
end
To this:
Code: Select all
if key == konami[konamii] then
konamii = konamii + 1
if konamii == #konami+1 then
if konamisound:isStopped() then
local randomsound = math.random(THE NUMBER OF SOUNDS YOU HAVE FOR THIS)
playsound(_G["konami" .. tostring(randomsound) .. "sound"])
end
gamefinished = true
saveconfig()
konamii = 1
end
else
konamii = 1
end
In this example, you'd have 3 sounds, so it'd be like this:
Code: Select all
if key == konami[konamii] then
konamii = konamii + 1
if konamii == #konami+1 then
if konamisound:isStopped() then
local randomsound = math.random(3)
playsound(_G["konami" .. tostring(randomsound) .. "sound"])
end
gamefinished = true
saveconfig()
konamii = 1
end
else
konamii = 1
end
I hope that's what you want, and I hope it works :)