Android Open Source - mobius Terrain Collision Box Rendering Debug System






From Project

Back to project page mobius.

License

The source code is released under:

MIT License

If you think the Android project mobius 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 com.sgtcodfish.mobiusListing.systems;
/*www.  j  a  va 2s .c  o m*/
import com.artemis.systems.VoidEntitySystem;
import com.badlogic.gdx.graphics.Camera;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType;
import com.sgtcodfish.mobiusListing.TerrainCollisionMap;

/**
 * @author Ashley Davis (SgtCoDFish)
 */
public class TerrainCollisionBoxRenderingDebugSystem extends VoidEntitySystem {
  private ShapeRenderer      renderer        = null;
  private Camera          camera          = null;

  private TerrainCollisionSystem  terrainCollisionSystem  = null;
  private TerrainCollisionMap    map            = null;

  public TerrainCollisionBoxRenderingDebugSystem(Camera camera, TerrainCollisionSystem terrainCollisionSystem) {
    super();

    this.renderer = new ShapeRenderer();
    this.terrainCollisionSystem = terrainCollisionSystem;
    this.camera = camera;
  }

  @Override
  public void begin() {
    this.map = terrainCollisionSystem.getCollisionMap();

    renderer.begin(ShapeType.Line);
    renderer.setProjectionMatrix(camera.combined);
    renderer.setColor(Color.YELLOW);

    super.begin();
  }

  @Override
  protected void processSystem() {
    for (int y = 0; y < map.actualHeightInTiles(); y++) {
      for (int x = 0; x < map.actualWidthInTiles(); x++) {
        int solidity = map.mapRetrieve(x, y);

        if (solidity >= 1) {
          if (solidity >= 2) {
            renderer.setColor(Color.RED);
          } else {
            renderer.setColor(Color.YELLOW);
          }

          renderer.rect(map.tileToWorldCoordinatesX(x), map.tileToWorldCoordinatesY(y), 32, 32);
        }
      }
    }
  }

  @Override
  public void end() {
    renderer.end();
    super.end();
  }
}




Java Source Code List

com.sgtcodfish.mobiusListing.Item.java
com.sgtcodfish.mobiusListing.MobiusListingGame.java
com.sgtcodfish.mobiusListing.TerrainCollisionMap.java
com.sgtcodfish.mobiusListing.WorldConstants.java
com.sgtcodfish.mobiusListing.android.AndroidLauncher.java
com.sgtcodfish.mobiusListing.components.ChildLinked.java
com.sgtcodfish.mobiusListing.components.Collectable.java
com.sgtcodfish.mobiusListing.components.DxLayer.java
com.sgtcodfish.mobiusListing.components.DyLayer.java
com.sgtcodfish.mobiusListing.components.FadableLayer.java
com.sgtcodfish.mobiusListing.components.FocusTaker.java
com.sgtcodfish.mobiusListing.components.InteractableLayer.java
com.sgtcodfish.mobiusListing.components.Interactable.java
com.sgtcodfish.mobiusListing.components.Inventory.java
com.sgtcodfish.mobiusListing.components.Linked.java
com.sgtcodfish.mobiusListing.components.MobiusSprite.java
com.sgtcodfish.mobiusListing.components.MovingLayer.java
com.sgtcodfish.mobiusListing.components.Opacity.java
com.sgtcodfish.mobiusListing.components.PlatformInputListener.java
com.sgtcodfish.mobiusListing.components.PlatformSprite.java
com.sgtcodfish.mobiusListing.components.PlayerInputListener.java
com.sgtcodfish.mobiusListing.components.PlayerSprite.java
com.sgtcodfish.mobiusListing.components.PlayerState.java
com.sgtcodfish.mobiusListing.components.Position.java
com.sgtcodfish.mobiusListing.components.Solid.java
com.sgtcodfish.mobiusListing.components.StaticSprite.java
com.sgtcodfish.mobiusListing.components.TiledRenderable.java
com.sgtcodfish.mobiusListing.components.Velocity.java
com.sgtcodfish.mobiusListing.desktop.DesktopLauncher.java
com.sgtcodfish.mobiusListing.levels.LevelEntityFactory.java
com.sgtcodfish.mobiusListing.player.HumanoidAnimationState.java
com.sgtcodfish.mobiusListing.player.PlayerConstants.java
com.sgtcodfish.mobiusListing.player.PlayerEntityFactory.java
com.sgtcodfish.mobiusListing.systems.AudioSystem.java
com.sgtcodfish.mobiusListing.systems.CollisionBoxRenderingDebugSystem.java
com.sgtcodfish.mobiusListing.systems.FocusTakerSystem.java
com.sgtcodfish.mobiusListing.systems.LevelAdvanceSystem.java
com.sgtcodfish.mobiusListing.systems.LinkingSystem.java
com.sgtcodfish.mobiusListing.systems.MovementSystem.java
com.sgtcodfish.mobiusListing.systems.PlatformInputSystem.java
com.sgtcodfish.mobiusListing.systems.PlayerInputSystem.java
com.sgtcodfish.mobiusListing.systems.SolidProcessingSystem.java
com.sgtcodfish.mobiusListing.systems.SpriteRenderingSystem.java
com.sgtcodfish.mobiusListing.systems.TerrainCollisionBoxRenderingDebugSystem.java
com.sgtcodfish.mobiusListing.systems.TerrainCollisionSystem.java
com.sgtcodfish.mobiusListing.systems.TiledRenderingSystem.java