fallingaffector.java

来自「Sony Ericsson手机上的Facebook客户端全套代码」· Java 代码 · 共 48 行

JAVA
48
字号
// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   FallingAffector.java

package se.southend.drops.integeraffector;

import se.southend.drops.screen.ScreenEngine;

// Referenced classes of package se.southend.drops.integeraffector:
//            Affector

public abstract class FallingAffector extends Affector
{

    public FallingAffector(int initialPosition, int initialVelocity, int groundLevel, int delay)
    {
        this.groundLevel = groundLevel;
        values = new int[1];
        lastValues = new int[1];
        values[0] = initialPosition;
        velocity = initialVelocity;
        startTime = ScreenEngine.getInstance().getTime() + (long)delay;
    }

    public void update(long time)
    {
        lastValues[0] = values[0];
        int lastVelocity = velocity;
        values[0] += velocity;
        velocity += 80;
        if(values[0] > groundLevel)
        {
            int air = groundLevel - lastValues[0];
            int ground = values[0] - groundLevel;
            values[0] = groundLevel;
            if(velocity < 600 || air == 0)
                stop();
            velocity = lastVelocity + ((velocity - lastVelocity) * air) / (air + ground);
            velocity = -velocity / 2;
        }
    }

    private static final int G = 4;
    private int velocity;
    private int groundLevel;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?