Android Open Source - raycaster Controls






From Project

Back to project page raycaster.

License

The source code is released under:

Copyright (c) 2014 Fredrik Wallgren Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the...

If you think the Android project raycaster listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package me.ramblingsby.raycaster;
/*from  w  w  w .  j av  a 2  s.com*/
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;

public class Controls {
  protected boolean left;
  protected boolean right;
  protected boolean forward;
  protected boolean backward;

  public Controls() {
    left = right = forward = backward = false;
  }

  public void update() {
    left = right = forward = backward = false;

    if(Gdx.input.isKeyPressed(Input.Keys.LEFT)) {
      left = true;
    }
    if(Gdx.input.isKeyPressed(Input.Keys.RIGHT)) {
      right = true;
    }
    if(Gdx.input.isKeyPressed(Input.Keys.UP)) {
      forward = true;
    }
    if(Gdx.input.isKeyPressed(Input.Keys.DOWN)) {
      backward = true;
    }

    if(Gdx.input.isTouched()) {
      if (Gdx.input.getY() < Gdx.graphics.getHeight() * 0.5) {
        forward = true;
      } else if (Gdx.input.getX() < Gdx.graphics.getWidth() * 0.5) {
        left = true;
      } else if (Gdx.input.getX() > Gdx.graphics.getWidth() * 0.5) {
        right = true;
      }
    }
  }
}




Java Source Code List

me.ramblingsby.raycaster.Camera.java
me.ramblingsby.raycaster.Controls.java
me.ramblingsby.raycaster.IOSLauncher.java
me.ramblingsby.raycaster.Map.java
me.ramblingsby.raycaster.Player.java
me.ramblingsby.raycaster.Point.java
me.ramblingsby.raycaster.Projection.java
me.ramblingsby.raycaster.Ray.java
me.ramblingsby.raycaster.Raycaster.java
me.ramblingsby.raycaster.Step.java
me.ramblingsby.raycaster.android.AndroidLauncher.java
me.ramblingsby.raycaster.client.HtmlLauncher.java
me.ramblingsby.raycaster.desktop.DesktopLauncher.java