# Angle range?

### » Sun Apr 05, 2009 7:42 am

Say you have one event you want to pick two different ranges of angles from, like left and right, but a little more complicated. I need to have one event that checks that an angle is between 315, and 45, or 135, and 225. Basically left and right, with out a top and bottom.
Like if you were looking at a clock if its between 2 and 4 o'clock, or 8 and 10 o'clock do something.
Initially I started with angle compare of angle is greater than 315, or less than 45... that works great for the right side, but since I need this in the same event I need to add a left side. Thing is when I add angle is greater than 135, or less than 225 Im basically saying if the angle is greater than zero, and less than 360 do this.

Is there a way to compare a angle range without using </>, and also how the heck do I deal with one of those ranges being between 90, and 315?
I know if it was set up with 0 degrees at the top it would be a little easier, but then again Im going to have to set up another event that does the opposite, and picks top and bottom.

Any ways HELP!
B
160
S
48
G
80
Posts: 7,234
Reputation: 61,496

### » Sun Apr 05, 2009 9:04 am

the cap shows what I'm about to say
but

[code:2iro1rpi]system - is number (sprite.angle) between (135) and (225)
system - OR
sprite - compare angle (less than) (45)
system - OR
sprite - compare angle (greater than) (315)[/code:2iro1rpi]
Spriter Dev
B
85
S
20
G
12
Posts: 3,231
Reputation: 16,293

### » Sun Apr 05, 2009 10:01 am

See now I wouldn't have even thought to mix sprite compare with system compare.
Thats ok cause I didnt even know there was a system between.

Thanks, I do believe that will fix it!
B
160
S
48
G
80
Posts: 7,234
Reputation: 61,496

### » Sun Apr 05, 2009 10:03 am

[quote="newt":1bw7fgbp]Thats ok cause I didnt even know there was a system between. [/quote:1bw7fgbp]

Going to have to say, neither did I!
B
3
S
2
G
5
Posts: 1,777
Reputation: 5,529

### » Sun Apr 05, 2009 1:36 pm

There are built in functions for handling angle comparisons. Don't use the ordinary compare less than/greater than. They won't take in to account the 0 degrees/360 degrees crossover point, nor will it know that 410 degrees is wrapped around and becomes 50 degrees.
Scirra Founder
B
355
S
208
G
71
Posts: 22,829
Reputation: 176,654

### » Sun Apr 05, 2009 8:04 pm

What are these functions and why do I not know about them when I am making a game that relies heavily on changing the angle of, well, everything?

The 360/0 thing has been plaguing me to no end, and I've had to make some really crude workarounds
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

### » Sun Apr 05, 2009 8:59 pm

Yeah, I gotta try something else, seems system compare is doing something buggy with family compare.
B
160
S
48
G
80
Posts: 7,234
Reputation: 61,496