using minor logic in love.draw

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
LastNameGames
Prole
Posts: 7
Joined: Tue Mar 10, 2015 8:04 pm

using minor logic in love.draw

Post 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?
User avatar
T-Bone
Inner party member
Posts: 1492
Joined: Thu Jun 09, 2011 9:03 am

Re: using minor logic in love.draw

Post 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.
User avatar
s-ol
Party member
Posts: 1079
Joined: Mon Sep 15, 2014 7:41 pm
Location: Milan, Italy
Contact:

Re: using minor logic in love.draw

Post 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.

s-ol.nu

Code: Select all

print( type(love) )
if false then
  baby:hurt(me)
end
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Amazon [Bot], Bing [Bot] and 6 guests