Android Open Source - acceptableLosses Map Render System






From Project

Back to project page acceptableLosses.

License

The source code is released under:

MIT License

If you think the Android project acceptableLosses 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 acceptableLosses.systems;
/*  ww  w. jav  a 2s.  c  om*/
import acceptableLosses.assets.TileType;
import acceptableLosses.map.Region;
import acceptableLosses.screens.GameScreen;
import com.artemis.systems.VoidEntitySystem;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;

/**
 * This is not a real system, it prints the visible map
 */
public class MapRenderSystem extends VoidEntitySystem {

    private SpriteBatch spriteBatch;
    private Region region;
    private GameScreen gameScreen;


    public MapRenderSystem(GameScreen gameScreen, SpriteBatch spriteBatch, Region region) {
        this.gameScreen = gameScreen;
        this.spriteBatch = spriteBatch;
        this.region = region;
    }

    @Override
    protected void processSystem() {


        // Don't use transparency... yet
        spriteBatch.disableBlending();

        // if we can limit this to what the camera sees, we can speed it up slightly
        for (int x = 0; x < region.xSize; x++) {
            for (int y = 0; y < region.ySize; y++) {

                TileType tileType = region.tiles[x][y][gameScreen.zLevel];


                if (tileType.texture != null) {

                    spriteBatch.setColor(1, 1, 1, 1);
                    spriteBatch.draw(tileType.texture, x, y, 1, 1);

                } else if (gameScreen.zLevel - 1 >= 0 && region.tiles[x][y][gameScreen.zLevel - 1].floor != null) {

                    spriteBatch.setColor(0.5f, 0.5f, 0.5f, 1);
                    spriteBatch.draw(region.tiles[x][y][gameScreen.zLevel - 1].floor, x, y, 1, 1);

                } else if (gameScreen.zLevel - 2 >= 0 && region.tiles[x][y][gameScreen.zLevel - 2].floor != null) {

                    spriteBatch.setColor(0.25f, 0.25f, 0.25f, 1);
                    spriteBatch.draw(region.tiles[x][y][gameScreen.zLevel - 2].floor, x, y, 1, 1);
                }

            }
        }
        spriteBatch.enableBlending();


    }
}




Java Source Code List

acceptableLosses.AcceptableLossesGame.java
acceptableLosses.android.AndroidLauncher.java
acceptableLosses.assets.AssetLoader.java
acceptableLosses.assets.FurnitureType.java
acceptableLosses.assets.TileType.java
acceptableLosses.components.Appearance.java
acceptableLosses.components.Cargo.java
acceptableLosses.components.Citizen.java
acceptableLosses.components.Destination.java
acceptableLosses.components.Health.java
acceptableLosses.components.Path.java
acceptableLosses.components.Position.java
acceptableLosses.components.Resume.java
acceptableLosses.components.Sentience.java
acceptableLosses.components.Task.java
acceptableLosses.controls.GestureDetectorController.java
acceptableLosses.controls.InputManager.java
acceptableLosses.controls.ZoomInputProcessor.java
acceptableLosses.controls.commands.Command.java
acceptableLosses.controls.commands.TapCommand.java
acceptableLosses.desktop.DesktopLauncher.java
acceptableLosses.desktop.ImagePacker.java
acceptableLosses.map.AsteroidGenerator.java
acceptableLosses.map.Chunk.java
acceptableLosses.map.Furniture.java
acceptableLosses.map.MapTools.java
acceptableLosses.map.Region.java
acceptableLosses.map.Spawner.java
acceptableLosses.pathing.FastNonOptimalHeuristic.java
acceptableLosses.screens.GameScreen.java
acceptableLosses.screens.SplashScreen.java
acceptableLosses.systems.AiSystem.java
acceptableLosses.systems.AppearanceRenderSystem.java
acceptableLosses.systems.ElevationSystem.java
acceptableLosses.systems.FurnitureRenderSystem.java
acceptableLosses.systems.JobAssignerSystem.java
acceptableLosses.systems.MapRenderSystem.java
acceptableLosses.systems.MovementSystem.java
acceptableLosses.systems.PathFinderSystem.java
acceptableLosses.work.CivilianMover.java
acceptableLosses.work.jobs.DigJob.java
acceptableLosses.work.jobs.Job.java