Scripting a players position (moving a object around on the screen)
Im looking开发者_如何学C into a small javascript game and is currently making a tool for testing "sqeuences" (game scenes where i want the script to move the player around thru waypoints, gonna call it actionscenes :D).
I think I almost got it right, but as you can see if you copypaste the code to a html the logic is broken. I need help with the trigonometric calculations:
http://pastebin.com/TfGU85ru
Any helpful tips? :D
It uses JQuery.
Depending on the quadrant you will also have to rotate the values a
and b
in the degree calculation. If the quadrant rotates 90 degrees, a
and b
have to be exchanged.
Also why use
var a = Math.pow( waypoint_x-player_x, 2);
var b = Math.pow( waypoint_y-player_y, 2);
and not
var a = Math.abs( waypoint_x-player_x);
var b = Math.abs( waypoint_y-player_y);
精彩评论