I want to use a counter to store a number. This number should increase/decrease when you press up/down.
I also want another counter, with the above number shown as an angle - ie. When the number exceeds 359, it should "wrap" around to 0 again. This much I can do, using the mod function in mmf.
However, I also want the number in the second counter to stay positive when it goes below 0. For example, -90 should become 270. Is there a formula for calculating this? (in a single line, and without extensions).
thanks, but those don't actually answer my question. the problem i have is just with keeping the angle between 0 and 359. i think i've seen it done before, but after searching here and at the clickteam forum i haven't found a solution.
Thanks for the suggestion, but that wouldn't work if counter1 went below -360 (if you turned more than one full turn anticlockwise, which is quite likely after a while). You'd start to get negative answers again; -400 for example, would produce the answer -40.
The first mod puts the number in the range of -360 to 360; adding the 360 then shifts the value into the range 0-720 (so no negative values); the second mod then puts the number in the range 0-360, which was the aim of the exercise
Sorry...did'nt se that you were using two counters... If you only use 1 this will work... since the moment it goes below 0 (eg -1) it will add 360 (359 then)...
CUBE: That's 2 separate events, so you couldn't use it as part of a more complicated formula. I may or may not use two counters (that was just me trying to explain the problem as clearly as I could), but I always prefer to do stuff in the minimum number of events anyway - it's more "elegant", and in theory, it'll make your game run quicker too.
Umm, yeah you could use it as part of a bigger formula, just follow order of events and you'll be fine, cause every event below those 2 events would have the counter between 0-360.
But then again, I'm not entirely sure of what you are trying to do, so I guess it wouldn't work under some conditions.