Say direction is 0 and length is 10, it ld_x should be 10 and ld_y should be 0.
It works in this case.
If I make dir start out as 45, ld_x is still 10 and ld_y is 0.1
This should work, though.
Here's a diagram of what I mean.
Can anyone tell me what I'm doing wrong?
Offline
Not quite sure I fully understand where you're going with this, but I doubt you need PI in your trigonometric functions - just give them the angle and you get the sine or cosine of that angle back
Last edited by Ratty1967UK (2010-05-05 08:28:34)
Offline
I don't think you understand what I mean.
I'm trying to figure out what the X and Y of L pixels to the right, and D pixels rotated based on it's center.
Is there an easier way of doing this?
Offline
so on your little picture above, you want to know the (x,y) position of the point at the end of the light blue line near the word "rotates"?
Offline
Ratty1967UK wrote:
so on your little picture above, you want to know the (x,y) position of the point at the end of the light blue line near the word "rotates"?
For the third time now, yes...
Offline
calm down kid! lol
assume px and py are the co-ordinates of the player...
x = l * sin(dir) + px
y = l * cos(dir) + py
all angles should be in degrees - no pi's required
are you ok turning that into scratch blocks?
Offline
Scratch uses degrees, not radians.
I had the problem using actionscript for the first time, but the other way round.
Offline