Page 1 of 1

using minor logic in love.draw

Posted: Tue Mar 10, 2015 8:10 pm
by LastNameGames
I know that it's frowned upon to do any math/logic in the love.draw loop, but I was wondering how far that convention goes. For example, I have the following code in my draw loop:

Code: Select all

if player.slice_anim > 0 then
    love.graphics.draw(spr_slice,player.slice_x,player.slice_y,player.slice_direction,
    6-(player.slice_anim/player.slice_anim_max)*3,((player.slice_anim/player.slice_anim_max)*3),0,spr_slice:getHeight()/2)
end
Is the multiplication/division of variables to get my scales acceptable, or should I calculate those in update and then use them later in draw?

Re: using minor logic in love.draw

Posted: Tue Mar 10, 2015 9:22 pm
by T-Bone
First of all, it's really up to you. The point of separating drawing from game logic is to make your code more managable to you primarily. If some variables are only used in the rendering code, calculating them in the game logic doesn't make much sense either.

Setting up scales sounds pretty rendering-related to me, so I'd probably put something like that in love.draw.

Re: using minor logic in love.draw

Posted: Wed Mar 11, 2015 12:14 am
by s-ol
logic is not arithmetic.

when we talk about not putting logic into love.draw, we usually mean something like this:
  • don't update physics
  • don't step animations
  • don't take user input
of course you can calculate things in love.draw.