Alternatively, he gets too many emails from people asking for his code, so he just deletes them upon sight. Or maybe not.
Just got back on the internet after losing my access for a week. Read more on Random Discussion.
Alternatively, he gets too many emails from people asking for his code, so he just deletes them upon sight. Or maybe not.
I emailed him twice, and he didn't reply... In the second I just asked what math function he used for slope detection... does anyone know the math function he uses for slope detection?
What do you mean by "math function"? Please elaborate (I don't know AS but I may be able to help in a general coding-sense).
@Komputer: If the only thing that is holding you back is your slope detector, then find a way to scrap it from your game. Simple enough..
atan2() is the function used to find the angle between two points, but it doesn't work for slopes over 90 degrees. I'm pretty sure Brad just uses cos() and sin().
Cosine and Sine? Hmmm... I tried those and it didn't work too well...
Anybody making progress on slope detection? I'm stuck... For the 27 ime or so.
Dude!! Slope Detection is far too hard to create to just give out to a random like you.
Your gonna have to start to realise that!!!
Just scrap it. If its not a motorcycle game then there is probably some way around it.
actually, before you try to do ANY of that, you have to get it so slowdown on the slopes, you really don't need to use atan2, cos, or even sin... just normal atan works just fine, you've just got to do a separate if statement code for the angles 90 degrees or higher, for both the guy itself, and the ground.
I thought I posted this a while ago already, but anyway...
How to do 360° angle check.
It troubled me for a long while as well, but I found out Flash has some problem with negative angles. So you have to keep the actual angle (upper textox) always positive (absolute value) and use a multiplier (lower textbox) to make the actual value negative when needed.
Of course, this isn't slope detection yet, I'll leave it to you guys to implement this into your platformer.
If tan doesn't work, you can use sin and cos. If you know what the x,y difference is you can find the hypotenuse of the right-angled triangle.
If you understand that.
atan2 works, you just need to use the multiplier.
Yea ok, or that.
What I'm dOing right now is getting the slope of the two lines, then using tangent and multipling the number to turn radians to degrees. The only place I use cosine and sine is to move the two dots that get the slope of the line.
Var dy = p1.y-p2.y
var dx=p1.x-p2.x
var slope=dy/dx
var ata= Math.atan(slope)
char.rotation=ata*180/math.pi
where's my mistake?
thats all right, but you have to use some of that for your moving left and right code, not just "if(Key.isDown(Key.RIGHT)){this._x++;}" you're going to have to use you slope to determine how much of a y change you get, and ho much an x change you get. i've got some stuff working with this, but haven't had the time to get the whole 306 degree rotation stuff, although i probably could if i put some time into it, but as most of you know... parallels... twisted... lots of projects..... not time for useless code i'll never use....
Well your problem is that the inverse of tangent only gives you an answer in quadrants 1 and 4 (-90 to 90 degrees). The reason for this is because otherwise it wouldn't be a function--you'll learn about this in trig. So because of this you could do as nyubis shows in his example and use a multiplier for atan/atan2 so you can get all angles.
[EDIT]The inverse of tangent is atan and atan2 btw
I am using atan...
I guess I'll try to implement what nyubis linked... But, I don't remember much math...
PLEASE BRAD, HELP US!!!!!!!

This whole topic makes me want to buy Flash and totally make an awesome game with great slope detection.
Implement it into a SMW hack
Slope detection? That would require a LOT of hacking. Mainly mody 7.
You must log in to post.