我目前正在研究在新的HTML 5应用程序中使用canvas的选项,并且想知道HTML canvas JavaScript库和框架中当前的最新技术水平是什么?
特别是,是否有框架支持游戏开发所需的东西 - 复杂的动画,管理场景图,处理事件和用户交互?
也愿意考虑商业和开源产品.
有没有人有一个实施轨道力学的例子(最好是在XNA中)?我目前使用的代码如下,但它执行时并没有"感觉正确".物体只是稍微向地球弯曲,无论我调整多少变量,我都无法进入轨道,甚至是部分轨道.
shot.Position += shot.Velocity;
foreach (Sprite planet in planets)
{
Vector2 directionToPlanet = (planet.Position - shot.Position);
directionToPlanet.Normalize();
float distance = Vector2.DistanceSquared(shot.Position, planet.Position);
float gPull = (float)(planet.gravityStrength * (planet.Mass * shot.Mass) / distance) + planet.gravityField;
shot.Position += new Vector2(directionToPlanet.X * gPull, directionToPlanet.Y * gPull);
}
Run Code Online (Sandbox Code Playgroud)
编辑 标记Mendelt的答案是正确的,指出我需要更新速度,而不是位置.我还需要将gPull的计算更改为
float gPull = shot.Mass * planet.Mass / distanceSqr * planet.gStr;
Run Code Online (Sandbox Code Playgroud)