franzenzenhofer / lsd

LSD - line-square-dot: an addicting game
159 stars 17 forks source link

Something about if statement #4

Open myozka opened 9 years ago

myozka commented 9 years ago

https://github.com/franzenzenhofer/lsd/blob/gh-pages/main.coffee#L113-L116

Here when I was trying to simplify the code, I changed it to,

setTimeout(startLsd, 200+800*( _W_.won ? 1:0 ), wins, av)

(or something like this.) (getting rid of conditionals increases performance.)

But when I did that, the levels started to jump around. Sometimes I goes directly to 4, sometimes to 10, sometimes to 2 from the starter level.

Do you have any idea why? ( Browser Chrome Version 44.0.2403.157 m)

franzenzenhofer commented 9 years ago

Do you have any idea why? no, but to be honest i never liked the "? 1:0 " notation as it's non obvious what happens

plus, this is not in an performance critical part of the game, this happens in the endgame (ragnorak) so an if is ok here

i removed some ifs from the drawDot function to see if it helps performance, nothing happened

i also made some fancy logic where now the whole canvas is only updated when lines are activly drawn, the dot now lives on another canvas and gets updated in real time

saddly performance is still shit on my own samsung 3 chrome - but fine in the native cygonmod browser ....