how do I let camera.pen just go between 0 and 359?

Posted By: elevationmind

how do I let camera.pen just go between 0 and 359? - 11/15/12 16:44

Hi,

I have to write a programe for a labyrinth that shows me that the player has made a mistake if he looked in to the direction of a dead end. I wanted to implement it, that if the player is on x,y coords and his pen goes for example 15 < or > -15 than it would count as a mistake.

But the problem is that pen counter never stops - if you rotate in one direction it goes over -+360 to much bigger numbers, and because I can't say how players would move around and rotate I can't really programme it the way I wanted to.

So here is my question: is it possible to specify in the script that pen can be ONLY 0 to 359, so that 360 would be again 0 and -1 would be 359?

my.pan += clamp(my.pan, 0, 359); just gets me an endless rotation...


I would be really greatful for any help!

Cheers

EM
Posted By: Superku

Re: how do I let camera.pen just go between 0 and 359? - 11/15/12 16:48

You almost got it right:

my.pan = clamp(my.pan+mouse_force.x*5*time_step,0,360);
Posted By: elevationmind

Re: how do I let camera.pen just go between 0 and 359? - 11/15/12 16:58

Hey thx for the quick reply.

It almost works;)! But now one can't rotate past the 0, but gets stuck there.

Is it possible not to impair the rotation but still get the pen number reset?
Posted By: WretchedSid

Re: how do I let camera.pen just go between 0 and 359? - 11/15/12 17:03

Pretty sure you want cycle() in this case!
Posted By: elevationmind

Re: how do I let camera.pen just go between 0 and 359? - 11/15/12 17:15

Originally Posted By: JustSid
Pretty sure you want cycle() in this case!


exactly:)! 1000 Thx!
© 2024 lite-C Forums