spiderbyte Posted September 16, 2008 Report Share Posted September 16, 2008 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 More sharing options...
cyborg_ar Posted September 16, 2008 Report Share Posted September 16, 2008 atn(deltaY/deltaX) however, i dont think you really need the angle, just make a normalized vector sqrt(deltaY**2 + deltaX**2) Link to comment Share on other sites More sharing options...
spiderbyte Posted September 17, 2008 Author Report Share Posted September 17, 2008 Thanks but what exactly is 'delta' when you say DeltaX and DeltaY Link to comment Share on other sites More sharing options...
cyborg_ar Posted September 17, 2008 Report Share Posted September 17, 2008 dX = bX - aX dY = bY - aY θ = atn(dY/dX) man this is baaaaaaasic trigonometry, i seen this (in depth) in the first year of high school edit: normalized 2d vector (i wish i could use LaTex here) length = sqrt(dX²+dY²) vX = dX / length vY = dY / length Link to comment Share on other sites More sharing options...
spiderbyte Posted September 17, 2008 Author Report Share Posted September 17, 2008 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 Link to comment Share on other sites More sharing options...
cyborg_ar Posted September 17, 2008 Report Share Posted September 17, 2008 god thats really bad, and what about limits&continuity, derivative functions, integrals (what i'm learning now, 5th grade in the high school =D), etc? Link to comment Share on other sites More sharing options...
spiderbyte Posted September 17, 2008 Author Report Share Posted September 17, 2008 Ah now that i looked on Wikipedia, i have learned this. i think you are misunderstanding me. I mean a CURVED slope like a quarter pipe. Link to comment Share on other sites More sharing options...
cyborg_ar Posted September 17, 2008 Report Share Posted September 17, 2008 a curve is an infinite array of angled lines, duh, you tessellate it at the resolution you want, getting a polygon of many edges(each one in a tile). and by the way, if you want a system true to the original sonic games, just read Yuji Naka's patent on the slope system. Link to comment Share on other sites More sharing options...
Kain Posted September 17, 2008 Report Share Posted September 17, 2008 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 More sharing options...
DimensionWarped Posted September 17, 2008 Report Share Posted September 17, 2008 California isn't that bad. It's no Georgia or Hawaii. Link to comment Share on other sites More sharing options...
VectorSatyr Posted September 17, 2008 Report Share Posted September 17, 2008 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 More sharing options...
Serephim Posted September 17, 2008 Report Share Posted September 17, 2008 California isn't that bad. It's no Georgia or Hawaii. Fuck you Link to comment Share on other sites More sharing options...
Sockman Posted September 21, 2008 Report Share Posted September 21, 2008 Hope that helps. Although this probably isn't helpful if Sonic isn't moving. Link to comment Share on other sites More sharing options...
DimensionWarped Posted September 22, 2008 Report Share Posted September 22, 2008 Fuck you I'm from Georgia too genius. And it's no secret that the public schools here are garbage. Link to comment Share on other sites More sharing options...
Serephim Posted September 22, 2008 Report Share Posted September 22, 2008 Oh i never said they wernt. This state is fucking retarded. Link to comment Share on other sites More sharing options...
VectorSatyr Posted September 22, 2008 Report Share Posted September 22, 2008 I'm from Georgia too genius. And it's no secret that the public schools here are garbage. As far as I'm concerned, we're both tied - and that's means, we're all losers. Link to comment Share on other sites More sharing options...
cyborg_ar Posted September 22, 2008 Report Share Posted September 22, 2008 I like how cyborg_ar's avatar makes it look like spiderbyte is talking to himself when you're not paying enough attention. well now i ruined it, i changed my avatar xD btw, what sockman drew is pretty interesting there you can get the angle and the velocity vector Link to comment Share on other sites More sharing options...
FunkBassExtreme Posted May 22, 2009 Report Share Posted May 22, 2009 Ive been messin with an engine for grenades / balls / barrels and such. This topic is becoming very helpful. *bookmark* Link to comment Share on other sites More sharing options...
LarkSS Posted May 23, 2009 Report Share Posted May 23, 2009 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 More sharing options...
Rael0505 Posted May 23, 2009 Report Share Posted May 23, 2009 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 More sharing options...
DimensionWarped Posted May 23, 2009 Report Share Posted May 23, 2009 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 More sharing options...
FunkBassExtreme Posted May 25, 2009 Report Share Posted May 25, 2009 I saw this on page one of the threads. I didnt have to dig. Even if I had dug it out and brushed the cobwebs off, it may be helpful to someone surfing round to see it up top that may have otherwise over looked it. Link to comment Share on other sites More sharing options...
Mecha the Slag Posted August 16, 2009 Report Share Posted August 16, 2009 man this is baaaaaaasic trigonometry, i seen this (in depth) in the first year of high school could've meant something entirely different depending on the situation can't always assume people know what you're talking about edit: oops sorry for the necro bump. Unintended ;o; Link to comment Share on other sites More sharing options...
Recommended Posts