Angle of degrees reversed?

0 favourites
  • 9 posts
From the Asset Store
Avoid obstacles and survive as long as you can!
  • 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? <img src="smileys/smiley9.gif" border="0" align="middle" />

  • 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.

  • 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.

  • 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!

  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

  • 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.

  • 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. :)

  • Trigonometry is used extensively internally to almost every movement behavior in Construct 2 (and Construct Classic). It's definitely useful to know.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)