I am also aware that my software needs work, but I'm not yet ready to focus on animation speeds and sound clips. I prefer to work on game states next.
Anyhow, I could use some input into how to convert some of the globals in love.load() into local declarations instead. Any suggestions will be highly appreciated. Thanks!
Code: Select all
local back_ground = love.graphics.newImage("background01.png")
--______________________________________________________________________
local spritesheet1 = love.graphics.newImage("sparkle_set01.png")
local spritesheet2 = love.graphics.newImage("sparkle_set02.png")
local spritesheet3 = love.graphics.newImage("sparkle_set03.png")
--______________________________________________________________________
local spritesheet4 = love.graphics.newImage("safir_test01.png")
local spritesheet5 = love.graphics.newImage("shell_burst_03.png")
--______________________________________________________________________
local animationState_Effects = "Effect_0"
local animationState_Saphir = "Effect_Saphir_1"
local soundState = "Sound_1"
local sound03 = love.audio.newSource("explosion03.ogg", "static")
local sound04 = love.audio.newSource("explosion04.ogg", "static")
function love.load()
require("anal")
spritesheet1:setFilter("nearest", "nearest")
animation1 = newAnimation(spritesheet1, 192, 192, 0.1, 110)
--______________________________________________________________________
spritesheet2:setFilter("nearest", "nearest")
animation2 = newAnimation(spritesheet2, 200, 200, 0.1, 80)
--______________________________________________________________________
spritesheet3:setFilter("nearest", "nearest")
animation3 = newAnimation(spritesheet3, 200, 200, 0.1, 80)
--______________________________________________________________________
spritesheet4:setFilter("nearest", "nearest")
--MAKE SURE THE LAST NUMBER IS THE NUMBER OF FRAMES!!!
animation4 = newAnimation(spritesheet4, 120, 203, 0.1, 60)
--______________________________________________________________________
spritesheet5:setFilter("nearest", "nearest")
--MAKE SURE THE LAST NUMBER IS THE NUMBER OF FRAMES!!!
animation5 = newAnimation(spritesheet5, 159, 203, 0.1, 31)
--______________________________________________________________________
--TO DO: Add more sound here.
--______________________________________________________________________
--Background music for battles.
local battle_music_shuffle = table.shuffle{'battle_music_Derek_Oldman_-_Notch.ogg', 'battle_music_Melodie_en_sous-sol_-_azul_ul_inu.ogg', 'battle_music_mindthings_-_Eve_.ogg', 'battle_music_Outsider_-_Dangerous_Groups.ogg', 'battle_music_Piter_-_Reveranger__amp__Piter_-_HYMNOMYNA__chillout_.ogg', 'battle_music_Tripple_T_-_The_Chill_Area.ogg', 'battle_music_Wade_-_Pozitivli_Tuned_Up.ogg', 'battle_music_WoNd3RBoY_-_WoNd3RBoY_-_MilkyWay__original_mix_.ogg'}
background_Music01 = love.audio.newSource(battle_music_shuffle[1])
background_Music01:setVolume(0.25)
--______________________________________________________________________
end
function table.shuffle(array)
local arrayCount = #array
for i = arrayCount, 2, -1 do
local j = love.math.random(1, i)
array[i], array[j] = array[j], array[i]
end
return array
end
function love.update(dt)
animation1:update(dt)
animation2:update(dt)
animation3:update(dt)
animation4:update(dt)
animation5:update(dt)
end
function love.draw()
love.graphics.draw(back_ground, 0, 0)
love.graphics.print("Press 1, 2, 3, or 4 to alternate between animations.", 50, 50)
love.graphics.print(animationState_Effects, 50, 110)
if animationState_Saphir == "Effect_Saphir_1" then
animation4:setMode("loop")
animation4:draw(600, 150)
elseif animationState_Saphir == "Effect_Saphir_2" then
animation5:setMode("once")
animation5:draw(580, 150)
if animation5:getCurrentFrame() == 31 then
animationState_Saphir = "Effect_Saphir_1"
animation4:reset()
animation4:play()
end
end
--______________________________________________________________________
if animationState_Effects == "Effect_1" then
animation1:setMode("once")
animation1:draw(250, 250)
if animation1:getCurrentFrame() == 110 then
animationState_Effects = "Effect_0"
end
elseif animationState_Effects == "Effect_2" then
animation2:setMode("once")
animation2:draw(250, 250)
if animation2:getCurrentFrame() == 80 then
animationState_Effects = "Effect_0"
end
elseif animationState_Effects == "Effect_3" then
animation3:setMode("once")
animation3:draw(250, 250)
if animation3:getCurrentFrame() == 80 then
animationState_Effects = "Effect_0"
end
elseif animationState_Effects == "Effect_4" then
animationState_Saphir = "Effect_Saphir_2"
end
if not background_Music01:isPlaying() then
stop_songs()
--The reason to call this stuff a second time is to re-shuffle the music.
battle_music_shuffle = table.shuffle{'battle_music_Derek_Oldman_-_Notch.ogg', 'battle_music_Melodie_en_sous-sol_-_azul_ul_inu.ogg', 'battle_music_mindthings_-_Eve_.ogg', 'battle_music_Outsider_-_Dangerous_Groups.ogg', 'battle_music_Piter_-_Reveranger__amp__Piter_-_HYMNOMYNA__chillout_.ogg', 'battle_music_Tripple_T_-_The_Chill_Area.ogg', 'battle_music_Wade_-_Pozitivli_Tuned_Up.ogg', 'battle_music_WoNd3RBoY_-_WoNd3RBoY_-_MilkyWay__original_mix_.ogg'}
background_Music01 = love.audio.newSource(battle_music_shuffle[1])
background_Music01:setVolume(0.25)
background_Music01:play()
end
end
function love.keypressed(key)
if key == "1" then
animationState_Effects = "Effect_1"
animation1:reset()
animation1:play()
elseif key == "2" then
animationState_Effects = "Effect_2"
animation2:reset()
animation2:play()
love.audio.play(sound03)
elseif key == "3" then
animationState_Effects = "Effect_3"
animation3:reset()
animation3:play()
love.audio.play(sound04)
elseif key == "4" then
animationState_Saphir = "Effect_Saphir_2"
animation5:reset()
animation5:play()
end
end
--Place more songs here as the list grows so that all background music ceases before starting a new one.
function stop_songs()
love.audio.stop(background_Music01)
end
https://www.dropbox.com/s/cy5s7erwij76k ... de_21.love