[Tutor] calculation issue.

Alan Gauld alan.gauld at btinternet.com
Sun Aug 26 23:56:07 CEST 2012


On 26/08/12 19:09, Matthew Ngaha wrote:

> heres the code:
 > self.time_til_drop = int(new_pizza.height * 1.3 /
> Pizza.speed) + 1
>
> so if, let's say the pizza height is 60(pixels). multiplying it by 1.3
> gives me 78. dividing it by Pizza.speed seems pointless as Pizza.speed
> is 1, and i will get 78 again. then adding one makes it 79.

Caveat: This is a guess since as you say we can't see the full code and 
don't know for sure what height refers to.

What I think the author is saying is that before releasing a new pizza 
the previous one must be fully clear(ie its full height) plus some 
clearance(a buffer) and in this case its about 30% Thus the first pizza 
must travel 130% of its height before we are safe to release the next 
pizza without the images overlapping.

For a 60px pizza that means a gap of 79 pixels approx.

HTH

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/



More information about the Tutor mailing list