Reply to Taking Dink x and y coordinates
If you don't have an account, just leave the password field blank.
I stumbled upon some weird behavior recently. Apparently when you try to measure Dink's x and y coordinates in the main procedure of some script that runs straightaway when Dink enters the screen you actually get the x and y coordinates Dink had on the previous screen. Take for example this script and attach it to a sprite on the screen or to the screen itself:
Now Dink will say the coordinates he had on the previous screen.
A possible solution would be to rewrite this script as:
However Dink actually moves during this wait(0); command. This is a bad thing for a script I need because there I need to determine whether Dink enters from the left or from the bottom of the screen so I can't use large margins of error. This error is about 6 pixels in the x-direction on my computer using normal Dink speed or 12 pixels using herb boots. But I imagine that this is dependent on things like computer speed and the amount of scripts on a screen as well.
There is actually a similar error in the first script: It gives a typical value of x = 17 when I move from right to left using normal dink speed and x = 14 using herb boots. However this doesn't contribute to the 6 pixel error in the second script as freezing Dink during the wait(0); makes Dink appear at exactly the expected location.
Now I was wondering if I could actually use this strange behaviour to determine the direction Dink is coming from. (So a high x value means Dink comes from the left.)How reliable do you reckon this behaviour is?
EDIT: Actually I found that freezing Dink during a wait(0); command doesn't really influence the smoothness of Dink's movement noticeably. So I'll just use that and hope people will play my DMOD on a sufficiently fast computer. Still, my question remains interesting.
void main(void) { int &dx = sp_x(1,-1); int &dy = sp_y(1,-1); say("X: &dx Y: &dy",¤t_sprite); }
Now Dink will say the coordinates he had on the previous screen.
A possible solution would be to rewrite this script as:
void main(void) { wait(0); int &dx = sp_x(1,-1); int &dy = sp_y(1,-1); say("X: &dx Y: &dy",¤t_sprite); }
However Dink actually moves during this wait(0); command. This is a bad thing for a script I need because there I need to determine whether Dink enters from the left or from the bottom of the screen so I can't use large margins of error. This error is about 6 pixels in the x-direction on my computer using normal Dink speed or 12 pixels using herb boots. But I imagine that this is dependent on things like computer speed and the amount of scripts on a screen as well.
There is actually a similar error in the first script: It gives a typical value of x = 17 when I move from right to left using normal dink speed and x = 14 using herb boots. However this doesn't contribute to the 6 pixel error in the second script as freezing Dink during the wait(0); makes Dink appear at exactly the expected location.
Now I was wondering if I could actually use this strange behaviour to determine the direction Dink is coming from. (So a high x value means Dink comes from the left.)How reliable do you reckon this behaviour is?
EDIT: Actually I found that freezing Dink during a wait(0); command doesn't really influence the smoothness of Dink's movement noticeably. So I'll just use that and hope people will play my DMOD on a sufficiently fast computer. Still, my question remains interesting.