Moving objects each second

I created a space invader watch face, and I have this code placed on the x axis (and the odd seconds for the y axis). It basically says that when the seconds reach an even number the invaders move right and at the next even number it moves back left again. Same thing was made for the y axis with odd numbers, but I have the feeling I am doing something wrong:

$#Ds#>=2&&#Ds#<4?241+6:241$&&$#Ds#>=4&&#Ds#<6?241:241+6$&&$#Ds#>=6&&#Ds#<8?241+6:241$&&$#Ds#>=8&&#Ds#<10?241:241$&&$#Ds#>=10&&#Ds#<12?241+6:241$&&$#Ds#>=12&&#Ds#<14?241:241$&&$#Ds#>=14&&#Ds#<16?241+6:241$&&$#Ds#>=16&&#Ds#<18?241:241$&&$#Ds#>=18&&#Ds#<20?241+6:241$&&$#Ds#>=20&&#Ds#<22?241:241$&&$#Ds#>=22&&#Ds#<24?241+6:241$&&$#Ds#>=24&&#Ds#<26?241:241$&&$#Ds#>=26&&#Ds#<28?241+6:241$&&$#Ds#>=28&&#Ds#<30?241:241$&&$#Ds#>=30&&#Ds#<32?241+6:241$&&$#Ds#>=32&&#Ds#<34?241:241$&&$#Ds#>=34&&#Ds#<36?241+6:241$&&$#Ds#>=36&&#Ds#<38?241:241$&&$#Ds#>=38&&#Ds#<40?241+6:241$&&$#Ds#>=40&&#Ds#<42?241:241$&&$#Ds#>=42&&#Ds#<44?241+6:241$&&$#Ds#>=44&&#Ds#<46?241:241$&&$#Ds#>=46&&#Ds#<48?241+6:241$&&$#Ds#>=48&&#Ds#<50?241:241$&&$#Ds#>=50&&#Ds#<52?241+6:241$&&$#Ds#>=52&&#Ds#<54?241:241$&&$#Ds#>=54&&#Ds#<56?241+6:241$&&$#Ds#>=56&&#Ds#<58?241:241$&&$#Ds#>=58&&#Ds#<0?241+6:241$&&$#Ds#>=0&&#Ds#<2?241:241$

Is there some easier way to set this conditionals?

BTW the moving ship is a sinus function, and the laser beam is a cosinus function, both set with your heartrate (bpm)

Looks like you could really stand to make use of Modulo instead of chaining so many separate ranges. If I understand your function correctly, I believe this should do the same job:

$(#Ds#%4)<2?241:247$

The ‘#Ds#%4’ gets the remainder of the current seconds divided by 4, so it’ll count 0,1,2,3 and loop through those. By saying ‘<2’, I set the conditional to treat the ‘0,1’ values separate from ‘2,3’, so it should flip every two seconds.

For the Y axis working with odds, you could use two conditionals to group them as ‘1,2’ and ‘3,0’, but it’s probably easier to just add one first (use whatever your y-value positions are for ‘yVal1’ and ‘yVal2’):

$(#Ds#+1%4)<2?yVal1:yVal2$

1 Like

wow you’re smart! took me so long to write that

The conditional for the x-axis works like a charm

unfortunately this doesn’t work for me. I’ll figure something out

thanks for the help!

I suppose it might need to be ‘((#Ds#+1)%4)<2’, not quite sure how Facer will handle the order of operations for that one, as I haven’t tested this myself

1 Like

yea, probably would have figured that one out haha

It’s working great thanks!! (check above)

I was wondering if it had an influence on processor, having to go through all conditionals