waveaffector.java

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

JAVA
92
字号
// 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:   WaveAffector.java

package se.southend.drops.integeraffector;

import se.southend.drops.math.IntMath;
import se.southend.drops.screen.ScreenEngine;

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

public abstract class WaveAffector extends Affector
{

    public WaveAffector(int amplitude, int period)
    {
        this(amplitude, period, 0, 0);
    }

    public WaveAffector(int amplitudes[], int periods[])
    {
        this(amplitudes, periods, ((int []) (null)), 0);
    }

    public WaveAffector(int amplitude, int period, int phase)
    {
        this(amplitude, period, phase, 0);
    }

    public WaveAffector(int amplitudes[], int periods[], int phases[])
    {
        this(amplitudes, periods, phases, 0);
    }

    public WaveAffector(int amplitude, int period, int phase, int delay)
    {
        values = new int[1];
        lastValues = new int[1];
        init(amplitude, period, phase, delay);
    }

    public WaveAffector(int amplitudes[], int periods[], int phases[], int delay)
    {
        values = new int[periods.length];
        lastValues = new int[periods.length];
        init(amplitudes, periods, phases, delay);
    }

    public void update(long time)
    {
        for(int i = 0; i < values.length; i++)
            if(periods[i] != 0)
            {
                lastValues[i] = values[i];
                int theta = (((int)(time - startTime) & 0xfffff) * 2 * 512) / periods[i];
                values[i] = (int)(((long)amplitudes[i] * (long)IntMath.sin(phases[i] + theta) << 1) + 0x10000L >> 17);
            }

    }

    private void init(int amplitude, int period, int phase, int delay)
    {
        int amplitudes[] = {
            amplitude
        };
        int periods[] = {
            period
        };
        int phases[] = {
            phase
        };
        init(amplitudes, periods, phases, delay);
    }

    private void init(int amplitudes[], int periods[], int phases[], int delay)
    {
        this.amplitudes = amplitudes;
        this.periods = periods;
        if(phases == null)
            this.phases = new int[periods.length];
        else
            this.phases = phases;
        startTime = ScreenEngine.getInstance().getTime() + (long)delay;
    }

    protected int amplitudes[];
    protected int periods[];
    protected int phases[];
}

⌨️ 快捷键说明

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