Jump to content
A 2021 backup has been restored. Forums are closed and work in progress. Join our Discord server for more updates! ×
SoaH City Message Board

Finding angle for sonic on slope (2d)


Recommended Posts

I have honestly looked at any source code of any Sonic engine so I do not know how to go about on this. As my journey into XNA, I am creating a small open source Sonic engine. Now please do not just say 'heres a link to my Sonic engine, look at that' as I am most of the time on my Wii, and I cannot download. I don't know the methods of how engines today do this. I was last night sitting at my desk, trying to come up with an equation to find the Angle according to the X and Y current position of Sonic on a Slope. I couldnt come up with a great one, and decided to post here to ask.

So, what do you think is the fastest way to do this?

Link to comment
Share on other sites

Here's a really old topic I made describing how angle detection is done, though not much attention is payed to the trigonometry; it's kinda taken for granted (I suggest learning the basic trig functions and how they are used in converting vectors to different forms as soon as possible):

http://www.sonicfangameshq.com/forum/showthread.php?t=2243

arctan2(-(y2-y1),(x2-x1)) is the formula for determining the angle from point (x1,y1) to point (x2,y2) {note: the y-axis is flipped in most computer programs}. The problem with arctan is it only returns half of the possible range of answers and gives a divide-by-0 error when (x2-x1) = 0.

Link to comment
Share on other sites

I like how cyborg_ar's avatar makes it look like spiderbyte is talking to himself when you're not paying enough attention. <_<

Take two points at the player's center. Move them out from sonic up to 25 steps. Use sin(angle)*radius for x and cos(angle)*radius for y. The left point should be angle-45 and the right point should be angle+45. (Or, like Kain did it, just add angle+/-90 for the x's and subtract angle+/-90 for the y's)

Keep moving the points until they both collide with something, then get the angle between the two points.

Link to comment
Share on other sites

  • 8 months later...

Self-narration anyone?

Simply put, it's nice that you took the time to dig through topics and find answers to issues that were already resolved, but there's no need to bump old threads stating that you found it useful.

Link to comment
Share on other sites

I agree with Lark. Please re-read the rules, FunkBassExtreme. I know I wrote somewhere in there that posting old threads that aren't your own is generally a bad idea.

edit: I actually consider the R&D forum the exception to this rule... with the sole condition that something useful is posted. If you can't add anything worthwhile to the discussion, don't bump a thread here.

Link to comment
Share on other sites

You gotta remember, I live in California, the 3rd worst state of education. I am in 10th grade and I am taking Geometry, i havnt even taken Trig

Um, excuse me? Going by standardized test scores California is certainly not the 3rd worst state of education. They aren't quite up to the median (though slightly above the average), but holy shit, you guys would have to go through all these guys in order to get there:

RANK STATE SATAVERAGE SAT% ACTAVERAGE ACT%

36 Maryland 1511 70 21.4 12

37 New Jersey 1507 82 21.8 8

38 Maine 1493 73 22.3 10

39 Indiana 1493 62 21.7 20

40 North Carolina 1493 71 20.5 14

41 Nevada 1487 40 21.5 27

42 Rhode Island 1487 69 21.2 8

43 New York 1486 88 22.6 17

44 Texas 1484 52 20.3 29

45 Delaware 1479 73 21.4 5

46 Georgia 1477 70 20.2 30

47 Pennsylvania 1476 74 21.8 9

48 Florida 1473 65 20.3 45

49 South Carolina 1465 62 19.5 39

50 Hawaii 1463 60 21.9 17

Oh, but none of them do nearly as poorly as the District of Columbia...

To be honest, I was a little surprised to find my home state of Alabama in the top 10% of the nation on average...

Link to comment
Share on other sites

  • 2 months later...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...