开发者

Scripting a players position (moving a object around on the screen)

开发者 https://www.devze.com 2023-01-26 17:18 出处:网络
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

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);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号