# Angle of degrees reversed?

Discussion and feedback on Construct 2

### » Sat Dec 08, 2012 9:03 pm

First off, I'm not much of a game developer so this question is probably in the realm of "How do I facebook my google books".

I noticed that if I have a bullet fire at an angle of 90 degrees, instead of the bullet going straight up it actually goes straight down. 0 still goes right and 180 still goes left, but 135 goes to the bottom left instead of the top left. It seems the angle of degrees has been flipped upside down.

Is there a reason for this? Is it something specific to video games?
B
24
S
4
G
1
Posts: 244
Reputation: 3,462

### » Sat Dec 08, 2012 9:26 pm

I was wondering about this too. Not working out the math here, but it might be a natural side-effect of the y-axis pointing downwards instead of upwards.
B
92
S
31
G
24
Posts: 3,191
Reputation: 32,749

### » Sat Dec 08, 2012 10:02 pm

Actually its just an engine specific thing. Some will have 0 at 12 o-clock etc.
It just so happens 0 at 3 o-clockwise works quite well for platforms, and side scrollers.
B
179
S
50
G
207
Posts: 8,719
Reputation: 128,306

### » Sat Dec 08, 2012 10:43 pm

Ah I see. It's interesting that engines differ on how to handle this - One would think that the maths is the maths and everyone would follow it the same. Very interesting.

Thanks newt!
B
24
S
4
G
1
Posts: 244
Reputation: 3,462

### » Sun Dec 09, 2012 2:33 pm

90 degrees would be up, but because in computers the Y axis has traditionally incremented downwards, C2 follows suit and that means 90 degrees is down.

There are a few different ways of doing it - we could have made 0 degrees point up - but 0 degrees points right due to the way the math works out. Using:
x += speed * cos(a)
y += speed * sin(a)
then 0 degrees ends up being right (because cos(0) = 1 and sin(0) = 0). If we changed this it could cause problems, especially with third party plugins that might assume the above formula works when C2 does it differently.
Scirra Founder
B
415
S
247
G
92
Posts: 25,281
Reputation: 200,831

### » Sun Dec 09, 2012 7:31 pm

Really cool.

Is this a relatively new thing some engines do, or is this one of those tricks that goes back to the early days of video games (given the extreme number of platformers back in the day)?

I should probably start reading up on sin/cos/tan in video games. I found this thread from the contruct classic forums if anyone is interested.
B
24
S
4
G
1
Posts: 244
Reputation: 3,462

### » Sun Dec 09, 2012 11:48 pm

@boolean a good knowledge of trig can help you so much. It's amazing how often these concepts pop up. Even more advanced math (calculus concepts, exponential decay) can help on rare occasions.sqiddster2012-12-09 23:48:34
B
92
S
31
G
24
Posts: 3,191
Reputation: 32,749

### » Mon Dec 10, 2012 12:24 am

Ha! I feel like such a simpleton now.

I just understood it as 'rotate 90 degrees clockwise'; clockwise, to the right, seems a reasonable direction to rotate. X and Y move from the top-left corner, tracking # pixels moved from that position: right and down, since there's nowhere else to go.

Sqiddster's talking about trig and I'm basically counting on my fingers. It just goes to show that Construct caters to all, even the "duh" folks. :)
B
16
S
6
G
2
Posts: 152
Reputation: 3,764

### » Mon Dec 10, 2012 10:51 am

Trigonometry is used extensively internally to almost every movement behavior in Construct 2 (and Construct Classic). It's definitely useful to know.
Scirra Founder
B
415
S
247
G
92
Posts: 25,281
Reputation: 200,831