javascript - 如何在我的 JavaScript 游戏中围绕网格移动玩家?
问题描述
在我正在制作的游戏界面中,玩家将鼠标朝他们希望角色移动的方向移动。
度数值(如东方的 90)被发送回游戏服务器。
调用该函数时move
,我希望玩家的 x 和 y 位置根据度数值发生变化。
所以, move(90, 0, 0)
will return{x:1, y:0}
并且move(45, 8, 14)
could return {x:8.something, y:14.something}
。
代码需要是 JavaScript,看起来像这样:
function move(degree, currentX, currentY) {
//Complicated maths things with pi and circles and stuff
return {x:newX,y:newY};
}
解决方案
推荐阅读
- node.js - 在 message.content 中检测图像/文本或仅图像或文本
- oracle - 通过标记化并将特定标记发送到 Oracle 中的两列来拆分列数据
- ios - 如何在加载主视图控制器之前呈现视图控制器?
- java - 如何从另一个包中导入枚举?
- greasemonkey - html 多行替换 Greasemonkey
- vue.js - 将值设置为计算值
- arrays - 如何使用 RestAssured 反序列化没有名称的 JSON 数组?
- android - 如何在instagram上的通知上实现箭头警报
- r - 在 R 中的同一折线图中绘制具有不同 Y 比例的两个数据框
- oracle - 仅当非零时如何格式化带小数位的数字?