小编Fa2*_*a2m的帖子

在java中跳跃球物理,引力

我做了一个简单的代码来获得跳球位置,但我肯定错过了一些东西,因为我得到了这个: http://i60.tinypic.com/2guxibn.png

这是获取x和y位置的代码:

public Vector2f[] draw() {
    float x = 0, y = height; // height - float value from class constructor;
    ArrayList<Vector2f> graphic = new ArrayList<Vector2f>();
    for(;;){
        Vector2f a = new Vector2f(x, y);
        graphic.add(a);
        ySpeed -= 10;
        y += ySpeed*Math.cos(angle);
        x += xSpeed*Math.sin(angle);
        if(y <= 0){
            // float coef = -10 * y / ySpeed;
            // ySpeed = ((ySpeed + coef) * (-1) ) * bouncyness;
            ySpeed = (ySpeed * (-1)) * bouncyness;
            System.out.println(ySpeed + " " + y);
            y …
Run Code Online (Sandbox Code Playgroud)

java animation sprite game-physics

5
推荐指数
1
解决办法
256
查看次数

标签 统计

animation ×1

game-physics ×1

java ×1

sprite ×1