Example usage for com.badlogic.gdx.graphics.glutils ShapeRenderer ShapeRenderer

List of usage examples for com.badlogic.gdx.graphics.glutils ShapeRenderer ShapeRenderer

Introduction

In this page you can find the example usage for com.badlogic.gdx.graphics.glutils ShapeRenderer ShapeRenderer.

Prototype

public ShapeRenderer() 

Source Link

Usage

From source file:GameWorld.Main.MainRenderer.java

public MainRenderer(MainWorld world, Interface ui) {
    super();/*from w ww . ja v a  2s.c  om*/
    this.world = world;
    this.ui = ui;
    shapeRenderer = new ShapeRenderer();
    shapeRenderer.setProjectionMatrix(cam.combined);
}

From source file:GameWorld.Maps.MapsRenderer.java

public MapsRenderer(MapsWorld world, Interface ui) {
    super();/*from   www  .  j  a va  2 s .  c  om*/
    this.world = world;
    this.ui = ui;
    shapeRenderer = new ShapeRenderer();
    shapeRenderer.setProjectionMatrix(cam.combined);
}

From source file:GameWorld.Settings.SettingsRenderer.java

public SettingsRenderer(SettingsWorld world, Interface ui) {
    super();/*from  w  w w.  j  a v  a2 s .c  om*/
    this.world = world;
    this.ui = ui;
    shapeRenderer = new ShapeRenderer();
    shapeRenderer.setProjectionMatrix(cam.combined);
}

From source file:gameWorld.WorldRenderer.java

License:Apache License

public WorldRenderer(SpriteBatch batch, GameWorld world) {
    this.rotation = GameScreen.rotation;
    this.world = world;
    this.cam = new OrthographicCamera(FRUSTUM_WIDTH, FRUSTUM_HEIGHT);
    this.cam.position.set(FRUSTUM_WIDTH / 2, FRUSTUM_HEIGHT / 2, 0);
    this.batch = batch;
    renderer = new OrthogonalTiledMapRenderer(world.map, 1 / 70f); // the 70
    // is//  w  w  w  .  j a v a2 s  . c  o m
    // because
    // each
    // tile
    // is
    // 70px
    followX = 0f;
    followY = 0f;
    shapeRender = new ShapeRenderer();

    ghostTexture = new Texture("data/ghost_fixed.png");
    ghostRegion = new TextureRegion(ghostTexture, 0, 0, 64, 64);
    originX = 1 / 48f * ghostTexture.getWidth() / 2f;
    originY = 1 / 48f * ghostTexture.getHeight() / 2f;
    textureWidth = 1 / 48f * 64; // texture is 64 pixels big.
    textureHeight = 1 / 48f * 64;

    dampingCounter = 0;
    velocity = new Vector2();

    // Light setup ---------------------------
    RayHandler.useDiffuseLight(true);
    handler = new RayHandler(world.world2);
    handler.setAmbientLight(.1f, .1f, .1f, 1f);
    // handler.setAmbientLight(.06f, .06f, .06f, .05f);
    handler.setShadows(true);
    handler.setCulling(true);
    // handler.setBlur(true);

    // Renders shadows
    pointLight = new PointLight(handler, 290, new Color(1, 1, .8f, .6f), 15, 10, 110);
    pointLight.setSoft(true);
    pointLight.setSoftnessLenght(.3f);

    // lights up the tiles around the player (no shadows)
    pointLight2 = new PointLight(handler, 200, new Color(1, 1, .8f, .6f), 6, 10, 110);
    pointLight2.setSoftnessLenght(1.5f);
    pointLight2.setXray(true);

    // for debugging---------
    // Box2D debug renderer. renders wireframes of the objects we create.
    debugRenderer = new Box2DDebugRenderer();
    bitmapFont = new BitmapFont();
    bitmapFont.setUseIntegerPositions(false);
    bitmapFont.getRegion().getTexture().setFilter(TextureFilter.Linear, TextureFilter.Linear);
    bitmapFont.setColor(Color.WHITE);
    bitmapFont.setScale(1.0f / 48.0f);
}

From source file:group04.core.MenuHandler.java

public MenuHandler() {
    sr = new ShapeRenderer();
    batch = new SpriteBatch();
    addEnvironment();
}

From source file:group04.core.Renderer.java

public Renderer(GameData gameData) {
    text = new BitmapFont();
    batch = new SpriteBatch();
    sr = new ShapeRenderer();

    loadPNGImages("Enemy", "Player", "pill", "gun", "bullet", "base", "sky", "grass", "back1", "back2", "back3",
            "back4", "sword", "rocket", "brain_jar", "Enemy_Beer", "Enemy_joint", "Enemy_LSD", "Enemy_narko",
            "Enemy_rave", "pupil", "Middleground", "lightSource", "level_01_back", "level_01_front", "level_02",
            "level_03_back", "level_03_front", "Eye_withoutpupil", "foreground_layer1", "foreground_layer2",
            "Background_layer1", "Background_layer2", "Halo");

    /*        loadPNGAnimation("player_run", 75, 80);
    loadPNGAnimation("player_idle", 75, 80);
    loadPNGAnimation("player_jump", 75, 80);*/
    loadPNGAnimation("Enemy_Beer_Run", 142, 122);
    loadPNGAnimation("currency_gold", 44, 45);
}

From source file:headmade.arttag.screens.ArtTagScreen.java

License:Apache License

public ArtTagScreen(DirectedGame game, String map) {
    super(game);// , new Stage(new ExtendViewport(MIN_WORLD_WIDTH, MIN_WORLD_HEIGHT), game.getBatch()));

    fpsLogger = new FPSLogger();

    Player.instance.inventory.clear();/*from   w  w  w .j  a v  a 2  s  .  c o  m*/
    Player.instance.setControlArtCount(0);
    Player.instance.setArtScanCount(0);
    Player.instance.setArtViewCount(0);
    Player.instance.isMoveDown = false;
    Player.instance.isMoveUp = false;
    Player.instance.isMoveLeft = false;
    Player.instance.isMoveRight = false;

    camera = new OrthographicCamera(MIN_WORLD_WIDTH, MIN_WORLD_HEIGHT);
    ((OrthographicCamera) camera).zoom = 0.5f;

    // perspectiveCam = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    // perspectiveCam.position.set(300f, 3000f, 1000f);
    // perspectiveCam.lookAt(300, 300, 0);
    // perspectiveCam.near = 0.1f;
    // perspectiveCam.far = 10000f;
    // perspectiveCam.update();

    contactListener = new ArtTagContactListener(this);

    this.world = new World(new Vector2(0f, 0f), true);
    world.setContactListener(contactListener);
    world.setDestructionListener(new DestructionListener() {

    });

    /** BOX2D LIGHT STUFF BEGIN */
    rayHandler = new RayHandler(world);
    rayHandler.setAmbientLight(0.08f, 0.08f, 0.16f, 0.1f);
    rayHandler.setBlurNum(ArtTag.gameSettings.blur);
    rayHandler.diffuseBlendFunc.set(GL20.GL_DST_COLOR, GL20.GL_SRC_COLOR);
    // RayHandler.setGammaCorrection(true);
    RayHandler.useDiffuseLight(true);
    // rayHandler.setBlur(false);
    /** BOX2D LIGHT STUFF END */

    shapeRenderer = new ShapeRenderer();
    box2dDebugRenderer = new Box2DDebugRenderer();
    inputController = new ArtTagInputController(game, this);

    jobDescActor = new Label("", Assets.instance.skin, "jobDesc");
    imageActor = new Image(Assets.assetsManager.get(AssetTextures.animal4, Texture.class));
    jobDescActor.setWrap(true);
    instructionsActor = new Label("Instructions", Assets.instance.skin, "info");
    instructionsActor.setWrap(true);
    instructionsActor.setVisible(false);
    resultActor = new Label("Result", Assets.instance.skin, "scanner");
    resultActor.setVisible(false);
    resultActor.setAlignment(Align.center);
    final Label scoreLabel = new Label("Your Score", Assets.instance.skin, "white");
    final Label highscoreLabel = new Label("Highscore", Assets.instance.skin, "white");
    final Label scoreActor = new Label("$" + Player.instance.getCash(), Assets.instance.skin, "dollar");
    final Label highscoreActor = new Label("$" + ArtTag.highScore, Assets.instance.skin, "dollar");

    Gdx.app.log(TAG, "camera.viewportWidth " + camera.viewportWidth + " Gdx.graphics.getWidth(): "
            + Gdx.graphics.getWidth());
    rootTable = new Table(Assets.instance.skin);
    rootTable.setFillParent(true);
    rootTable.add(jobDescActor).pad(10f).width(camera.viewportWidth / ArtTag.UNIT_SCALE / 4);
    rootTable.add(imageActor).center().expand();
    rootTable.add(instructionsActor).top().right().pad(10f).width(camera.viewportWidth / ArtTag.UNIT_SCALE / 4);
    rootTable.row();
    rootTable.add(scoreLabel).left();
    rootTable.add();
    rootTable.add(highscoreLabel).right();
    rootTable.row();
    rootTable.add(scoreActor).left();
    rootTable.add(resultActor).center().width(camera.viewportWidth / ArtTag.UNIT_SCALE / 4);
    rootTable.add(highscoreActor).right();

    stage.addActor(rootTable);

    newJob();
    MapUtils.loadMap(this, map != null ? map : AssetMaps.map1);

    final Loader<Sprite> loader = Assets.instance.getSpriterLoader();
    drawer = new LibGdxDrawer(loader, game.getBatch(), shapeRenderer);
    final headmade.arttag.spriter.Player player = new headmade.arttag.spriter.Player(
            Assets.instance.getMaggieSpriterData());
    player.setAnimation("run");
    player.setScale(ArtTag.UNIT_SCALE * 0.8f);
    players.add(player);

    smokeEffect = new ParticleEffect();
    smokeEffect.load(Gdx.files.internal(AssetParticles.smoke), Assets.instance.atlas);
    smokeEffect.scaleEffect(ArtTag.UNIT_SCALE);
    smokeEffectPool = new ParticleEffectPool(smokeEffect, 2, 4);

}

From source file:io.github.deathsbreedgames.spacerun.screens.GameScreen.java

public GameScreen(AssetManager manager) {
    super("Splash", manager);

    // Create buttons
    mainStage = new Stage(new StretchViewport(GlobalVars.width, GlobalVars.height));
    buttonAtlas = manager.get("gfx/ui/buttons.pack", TextureAtlas.class);
    buttonSkin = new Skin(buttonAtlas);
    Gdx.input.setInputProcessor(mainStage);

    ImageButtonStyle imgBtnStyle = new ImageButtonStyle();
    imgBtnStyle.imageUp = buttonSkin.getDrawable("ExitButton");

    ImageButton exitButton = new ImageButton(imgBtnStyle);
    exitButton.setPosition(GlobalVars.width - (exitButton.getWidth() + 5f),
            GlobalVars.height - (exitButton.getHeight() + 5f));
    mainStage.addActor(exitButton);//from w w w.  j  av a2  s  .c  o  m
    exitButton.addListener(new ChangeListener() {
        public void changed(ChangeEvent e, Actor a) {
            setNextScreen("MainMenu");
            setDone(true);
        }
    });

    // Setup draw stuff
    camera = new OrthographicCamera(GlobalVars.width, GlobalVars.height);
    camera.position.set(GlobalVars.width / 2, GlobalVars.height / 2, 0f);
    camera.update();

    batch = new SpriteBatch();
    spaceshipAtlas = manager.get("gfx/sprites/spaceships.pack", TextureAtlas.class);
    bulletAtlas = manager.get("gfx/sprites/bullets.pack", TextureAtlas.class);
    pickupAtlas = manager.get("gfx/sprites/pickups.pack", TextureAtlas.class);
    font = new BitmapFont();
    font.scale(0.01f);

    // Create ship
    if (GlobalVars.ship == 0) {
        player = new Player(spaceshipAtlas.findRegion("bluedestroyer"), 160, 50, 1, 1000, 250, 0.5f);
    } else if (GlobalVars.ship == 1) {
        player = new Player(spaceshipAtlas.findRegion("bluecarrier"), 160, 50, 0, 2000, 250, 0.5f);
    } else {
        player = new Player(spaceshipAtlas.findRegion("bluecruiser"), 160, 50, 0, 1000, 500, 0.5f);
    }
    // Setup enemies
    enemies = new Enemy[NUM_ENEMIES];
    for (int i = 0; i < NUM_ENEMIES; i++) {
        enemies[i] = null;
    }
    currentMaxEnemies = 1;
    currentEnemies = 0;
    // Setup bullets
    bullets = new Bullet[NUM_BULLETS];
    for (int i = 0; i < NUM_BULLETS; i++) {
        bullets[i] = null;
    }

    // Setup pickups
    pickup = null;
    pickupTimer = 0;

    rapidTimer = 0;
    speed = false;
    speedTimer = 0;
    invTimer = 0;

    // Setup Particle Effects
    ParticleEffect explosionEffect = new ParticleEffect();
    explosionEffect.load(Gdx.files.internal("gfx/particles/Explosion.p"), Gdx.files.internal("gfx/particles/"));
    explosionEffectPool = new ParticleEffectPool(explosionEffect, 1, 2);

    // Setup stars
    stars = new Star[NUM_STARS];
    for (int i = 0; i < NUM_STARS; i++) {
        RandomXS128 rand = new RandomXS128();
        stars[i] = new Star(rand.nextFloat() * GlobalVars.width, rand.nextFloat() * GlobalVars.height);
    }
    shapeRenderer = new ShapeRenderer();

    // Setup sound
    laserShot = Gdx.audio.newSound(Gdx.files.internal("sfx/laser5.mp3"));
    explode = Gdx.audio.newSound(Gdx.files.internal("sfx/explosion.mp3"));
}

From source file:io.lonelyrobot.empires.cl.gl.CoreClient.java

License:Open Source License

@Override
public void create() {

    /** Initialise the logger */
    Logger.setup((msg, lvl) -> System.out.println("[" + lvl + "]: " + msg));
    Logger.validate();//from   ww  w  .j a va  2 s.  com

    /** Create GameFramework objects */
    Star s = new Star(Types.Stars.RED_DWARF);
    s.setSolPos(new Vector2D(0, 0));

    Planet p = new Planet(s, 150, new Vector2D(150, 0));
    p.getOrbit().setRadius(150);
    p.getOrbit().setStepSpeed(0.025f);

    Planet p2 = new Planet(s, 250, new Vector2D(250, 0));
    p2.getOrbit().setRadius(250);
    p2.getOrbit().setStepSpeed(0.0075f);

    Set<BaseObject> children = new HashSet<>();
    children.add(p);
    children.add(p2);
    s.getOrbit().setChildren(children);

    system = new SolarSystem(s, new MapCoordinate(0, 0));

    // TODO: Add a nicer way to do this (we only do this a few times so it's fine
    system.getCelestials().insert(p, new Vector2D(150, 0));

    camera = new OrthographicCamera(1280, 720);
    // camera.position.x -= 150;
    // camera.position.y -= 150;
    renderer = new ShapeRenderer();

    star = new SolObject(s);
    planet = new SolObject(p);
    pl2 = new SolObject(p2);
}

From source file:io.lonelyrobot.empires.client.graphics.R2Overlay.java

License:Open Source License

/**
 * Preferred constructor for an overlay. It initialises itself with a stage and also a default UI skin to be used for
 * the table parent.//from  w  w w .  ja v  a2  s.co  m
 * 
 * @param stage
 *          Stage to hold children. Can be passed down from Screen.
 * @param uiskin
 *          Default UI skin for {@link #main} Table to hold.
 */
public R2Overlay(Stage stage, Skin uiskin) {
    this.stage = stage;
    main = new Table(uiskin);
    main.setFillParent(true); // Just check this. It makes sense in 99% of cases.
    stage.addActor(main);
    renderer = new ShapeRenderer();
    this.camera = (OrthographicCamera) stage.getCamera();
}