lumo tells me that frame based is betterand far easier.
Which should I use! and how do I use frame based?
I believe the animation plays at the same speed no matter what the frame rate while using timer based animations. Is that correct?
Code: Select all
local timer = Timer.new()
stop = false
if pfenemhealth <= 0 and pfenemorient == -1 then
pfenemalive = false
elapsedTenthSeconds = math.floor(timer:start() / 100 + 0.5)
if elapsedTenthSeconds <= 1 and pfenemalive == false then
screen:blit(pfenemxpos, pfenemypos, pfflip.df1)
elseif elapsedTenthSeconds <= 2 and pfenemalive == false then
screen:blit(pfenemxpos, pfenemypos, pfflip.df2)
elseif elapsedTenthSeconds <= 3 and pfenemalive == false then
screen:blit(pfenemxpos, pfenemypos, pfflip.df3)
elseif elapsedTenthSeconds <= 4 and pfenemalive == false then
screen:blit(pfenemxpos, pfenemypos, pfflip.df4)
elseif elapsedTenthSeconds <= 5 and pfenemalive == false then
screen:blit(pfenemxpos, pfenemypos, pfflip.df5)
elseif elapsedTenthSeconds <= 6 and pfenemalive == false then
screen:blit(pfenemxpos, pfenemypos, pfflip.df6)
elseif elapsedTenthSeconds <= 7 and pfenemalive == false then
screen:blit(pfenemxpos, pfenemypos, pfflip.df7)
elseif elapsedTenthSeconds <= 8 and pfenemalive == false then
screen:blit(pfenemxpos, pfenemypos, pfflip.df8)
elseif elapsedTenthSeconds <= 9 and pfenemalive == false then
screen:blit(pfenemxpos, pfenemypos, pfflip.df9)
elseif elapsedTenthSeconds <= 10 and pfenemalive == false then
screen:blit(pfenemxpos, pfenemypos, pfflip.df10)
elseif elapsedTenthSeconds <= 11 and pfenemalive == false then
screen:blit(pfenemxpos, pfenemypos, pfflip.df12)
elseif elapsedTenthSeconds <= 12 and pfenemalive == false then
screen:blit(pfenemxpos, pfenemypos, pfflip.df13)
elseif elapsedTenthSeconds <= 13 and pfenemalive == false then
screen:blit(pfenemxpos, pfenemypos, pfflip.df14)
elseif elapsedTenthSeconds <= 14 and pfenemalive == false then
screen:blit(pfenemxpos, pfenemypos, pfflip.df15)
elseif elapsedTenthSeconds <= 15 and pfenemalive == false then
screen:blit(pfenemxpos, pfenemypos, pfflip.df16)
elseif elapsedTenthSeconds >= 30 and pfenemalive == false then
pfenemalive = true
pfenemhealth = 20
if charhealth < 100 then
charhealth = charhealth + 10
end
score = score + 10
pfenemxpos = math.random(480)
timer:reset(0)
timer:stop()
end