Jasoco wrote:I mean, have you seen my Adventure engine? And you never complained about it?
Not sure about the other fella, but I've
seen the Adventure engine, but I haven't read the source.
Jasoco wrote:You're going to have to give me an idea of what you guys expect code to look like.
Most of the time, I do it like you—OK, not completely, I never violate the boundary between love.update and love.draw for minor optimizations. But in the Programming course at university, we learned that a function should usually consist of no more than 7 lines, although that's not a hard law, more like a rule of thumb. Those functions should be logical units of the process, with a descriptive name, like:
Code: Select all
function animate_player_dying(player)
player.dying_f = player.dying_f - dt --Dying frame advance
player.rotate = player.rotate + 720 * dt --Rotate player twice per second
if player.dying_f < 0 then --If the death animation is over...
dying_animation_over(player)
end
end
function dying_animation_over(player)
player.dying_f = 0 --Reset frame to 0
player.dying = false --Turn off death
player.x = 2 --Reset player position
player.y = 0
player.rotate = 0 --Reset rotation
player.jumping = false --In case he was jumping
player.facing = 0 --Reset facing
level.time = 90 --Reset level time
player.idletime = 0 --Reset idle time too
if player.lives <= 0 then --Make sure player isn't out of lives -- this part should probably be somewhere else, it has nothing to do with the animation
gamemode = inMenu --If so, return to menu
end
end
Jasoco wrote:Can we change the subject? Unless you want to show me an example of what you expect me to do.
Oh, I'm all for changing the topic.