Package sc.client

Source Code of sc.client.HUD

package sc.client;

import k8.Logic;
import k8.text.Text;
import k8.wt.Layer;

public class HUD extends Logic
{
  // The HUDs Layer
  public Layer layer;
 
  private Text position;
  private Text fps;
  private float textScale;

  /** Creates an instance of HUD */
  public HUD(float depth)
  {
    // Create the Layer
    layer = new Layer(depth);   

    // Set the text scaling proportional to width
    textScale = layer.getWidth() / 5000;

    // Position
    position = new Text();
    position.setScale(textScale);
    position.moveRight(layer.getWidth() / 2);
    position.moveUp(0.001f);
    layer.add(position);

    // FPS Counter
    fps = new Text();
    fps.setScale(textScale);
    fps.moveRight(0.001f);
    fps.moveUp(0.001f);
    layer.add(fps);
   
    // Update the HUD 3 times a second
    setUpdateRate(3);
  }
 
  @Override
  public void update(long time)
  {
    // Update the HUD elements
    position.setText(((float) (int) (Client.avatar.T[3] * 100) / 100) + ", "
        + ((float) (int) (Client.avatar.T[7] * 100) / 100) + ", "
        + ((float) (int) (Client.avatar.T[11] * 100) / 100));
    fps.setText(FPS.fps);
  }
}
TOP

Related Classes of sc.client.HUD

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.