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:Tabox2D.java

License:Open Source License

private Tabox2D(Vector2 gravity) {
    width = Gdx.graphics.getWidth();/*from   w w w.j a  va2 s  .c om*/
    height = Gdx.graphics.getHeight();
    meterSize = 100;// 1 metter = 100px, default.
    polyInfo = new HashMap<String, Float>();
    rawForces = false;

    // Sides by polygon:
    polyInfo.put("triangle", 3f);
    polyInfo.put("square", 4f);
    polyInfo.put("pentagon", 5f);
    polyInfo.put("hexagon", 6f);
    polyInfo.put("heptagon", 7f);
    polyInfo.put("octagon", 8f);

    // Angle of the sides:
    polyInfo.put("triangle_angle", 120f);
    polyInfo.put("square_angle", 90f);
    polyInfo.put("pentagon_angle", 72f);
    polyInfo.put("hexagon_angle", 60f);
    polyInfo.put("heptagon_angle", 51.428f);
    polyInfo.put("octagon_angle", 45f);

    filterMin = "linear";
    filterMag = "linear";

    renderer = new Box2DDebugRenderer();
    sr = new ShapeRenderer();
    spriteBath = new SpriteBatch();
    adjustCamera();
    tabodies = new ArrayList<Tabody>();
    world = new World(new Vector2(gravity.x, gravity.y), true);

    sr = new ShapeRenderer();
}

From source file:at.therefactory.jewelthief.JewelThief.java

License:Open Source License

@Override
public void create() {
    instance = this;

    FreeTypeFontGenerator generator = new FreeTypeFontGenerator(
            Gdx.files.internal("fonts/amiga4ever pro2.ttf"));
    FreeTypeFontGenerator.FreeTypeFontParameter parameter = new FreeTypeFontGenerator.FreeTypeFontParameter();
    parameter.size = 8;//from  w w  w  .ja v a 2  s .  co m
    parameter.mono = true;
    font = generator.generateFont(parameter);
    generator.dispose();

    batch = new SpriteBatch();
    shapeRenderer = new ShapeRenderer();
    camera = new OrthographicCamera();
    viewport = new FitViewport(WINDOW_WIDTH, WINDOW_HEIGHT, camera);
    camera.position.set(WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2, 0);
    camera.update();

    textureAtlas = new TextureAtlas("textures.pack");
    assetManager = new AssetManager();

    fade = textureAtlas.createSprite("fade");
    fade.setSize(WINDOW_WIDTH, WINDOW_HEIGHT);
    fade.setPosition(0, 0);

    particles = new Particles(textureAtlas);

    loadInitialPreferences();
    loadAssets();
    tryToSubmitLatestHighscores();

    // load and show logo screen
    theRefactoryLogoScreen = new LogoScreen(batch, shapeRenderer, viewport, camera);
    setScreen(theRefactoryLogoScreen);
}

From source file:broken.shotgun.throwthemoon.stages.GameStage.java

License:Open Source License

public GameStage(final AssetManager manager) {
    super(new StretchViewport(WIDTH, HEIGHT));

    this.manager = manager;

    loadLevel();//from w  ww.j a  va  2s  .  co  m

    loadSounds();

    loadFont();

    random = new Random(System.currentTimeMillis());
    fadingOut = false;

    background = new Background(manager);
    chain = new MoonChain(manager);
    player = new Player(manager);
    moon = new Moon(manager);

    moonImpactMeter = new MoonImpactMeter(moon);

    screenFadeActor = new Actor();
    screenFadeActor.setBounds(0, 0, WIDTH, HEIGHT);
    screenFadeActor.setColor(Color.CLEAR);

    levelDebugRenderer = new LevelDebugRenderer();
    screenLogger = new StringBuilder();

    uiBatch = new SpriteBatch();
    renderer = new ShapeRenderer();
    renderer.setAutoShapeType(true);

    touchPoint = new Vector2();

    resetLevel();

    debug = isDebug();
    setDebugAll(debug);

    Gdx.input.setInputProcessor(this);

    addListener(new ActorGestureListener() {
        @Override
        public void touchDown(InputEvent event, float x, float y, int pointer, int button) {
            if (pointer == 0 && !(event.getTarget() instanceof Enemy || event.getTarget() instanceof Boss
                    || (boss != null && event.getTarget() instanceof MoonChain))) {
                player.moveTo(touchPoint.set(x, y));
            }

            // FIXME replace String.format with StringBuilder for HTML
            if (isDebug())
                Gdx.app.log("GameStage", String.format("touchDown %s %s", event.getType().toString(),
                        event.getTarget().toString()));
            super.touchDown(event, x, y, pointer, button);
        }

        @Override
        public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
            if (pointer == 0 && player.isWalking()) {
                player.stop();
            }
            super.touchUp(event, x, y, pointer, button);
        }

        @Override
        public void pan(InputEvent event, float x, float y, float deltaX, float deltaY) {
            if (boss == null || (boss != null && !(event.getTarget() instanceof MoonChain))) {
                player.moveTo(touchPoint.set(x, y));
            }

            super.pan(event, x, y, deltaX, deltaY);
        }

        @Override
        public void tap(InputEvent event, float x, float y, int count, int button) {
            player.performAttack(count);

            float deltaX = ((player.getX() + player.getOriginX()) - x);
            player.setFlipX(deltaX > 0);

            // FIXME replace String.format with StringBuilder for HTML
            if (isDebug()) {
                Actor target = event.getTarget();
                Gdx.app.log("GameStage",
                        String.format("tap type:%s target:%s [target x=%.2f y=%.2f] count:%d [x:%.2f, y:%.2f]",
                                event.getType().toString(), target.toString(), target.getX(), target.getY(),
                                count, x, y));
            }
            super.tap(event, x, y, count, button);
        }

        @Override
        public void fling(InputEvent event, float velocityX, float velocityY, int button) {
            Gdx.app.log("GameStage",
                    String.format("fling velocityX:%.2f velocityY:%.2f", velocityX, velocityY));
            if (player.isMoonThrowEnabled() && velocityY < 0 && chain.isAttached()
                    && event.getTarget() instanceof MoonChain) {
                int multiplier = (boss != null && boss.isDefeated()) ? 10 : 2;
                moon.addDistance(velocityY * multiplier);
                chain.animatePull();
            }
            super.fling(event, velocityX, velocityY, button);
        }

    });

    addListener(new InputListener() {
        int attackCounter = 0;

        @Override
        public boolean keyDown(InputEvent event, int keycode) {
            switch (keycode) {
            case Input.Keys.D:
                if (debug && player.isMoonThrowEnabled() && !moon.isFalling()) {
                    moon.startFalling();
                }
                break;
            case Input.Keys.K:
                if (debug) {
                    clearAllEnemies();
                }
                break;
            case Input.Keys.SPACE:
                attackCounter++;
                player.performAttack(attackCounter);
                return true;
            case Input.Keys.LEFT:
                player.velocity.x = -7;
                player.startWalkState();
                return true;
            case Input.Keys.RIGHT:
                player.velocity.x = 7;
                player.startWalkState();
                return true;
            case Input.Keys.UP:
                player.velocity.y = 7;
                player.startWalkState();
                return true;
            case Input.Keys.DOWN:
                player.velocity.y = -7;
                player.startWalkState();
                return true;
            }

            return super.keyDown(event, keycode);
        }

        @Override
        public boolean keyUp(InputEvent event, int keycode) {
            switch (keycode) {
            case Input.Keys.LEFT:
            case Input.Keys.RIGHT:
                player.velocity.x = 0;
                return true;
            case Input.Keys.UP:
            case Input.Keys.DOWN:
                player.velocity.y = 0;
                return true;
            }
            return super.keyUp(event, keycode);
        }
    });
}

From source file:cb.pong.model.Board.java

private void renderBlocks() {
    ShapeRenderer shapeRenderer = new ShapeRenderer();
    shapeRenderer.begin(ShapeRenderer.ShapeType.Filled);
    shapeRenderer.setColor(Color.BLUE);
    for (int x = 0; x < width; x++) {
        for (int y = 0; y < height; y++) {
            if (blocks[x][y]) {
                shapeRenderer.rect(x * 20, y * 20, 18, 18);
            }//from ww w .j av a  2  s  .  c  o  m
        }
    }
    shapeRenderer.end();
}

From source file:cb.pong.model.Pieces.java

private Pieces(boolean[][] shape) {
    this.piece = shape;
    position = new Point(0, 0);
    shapeRenderer = new ShapeRenderer();
}

From source file:ch.coldpixel.game.MapDrawing.java

public MapDrawing(int tileWidth, int tileHeight, MapModel mapmodel) {
    //Mapmodel// ww  w  .  j ava2 s  .  c o  m
    this.mapmodel = mapmodel;
    //Textures
    ground = new Texture(Gdx.files.internal("ground.png"));
    groundTop = new Texture(Gdx.files.internal("groundTop.png"));
    //House
    house1Door1LeftBottom = new Texture(Gdx.files.internal("House1/house1Door1LeftBottom.png"));
    house1Door1LeftMid = new Texture(Gdx.files.internal("House1/house1Door1LeftMid.png"));
    house1Door1LeftTop = new Texture(Gdx.files.internal("House1/house1Door1LeftTop.png"));
    house1Door1RightBottom = new Texture(Gdx.files.internal("House1/house1Door1RightBottom.png"));
    house1Door1RightMid = new Texture(Gdx.files.internal("House1/house1Door1RightMid.png"));
    house1Door1RightTop = new Texture(Gdx.files.internal("House1/house1Door1RightTop.png"));
    house1Left1 = new Texture(Gdx.files.internal("House1/house1Left1.png"));
    house1Left2 = new Texture(Gdx.files.internal("House1/house1Left2.png"));
    house1Left3 = new Texture(Gdx.files.internal("House1/house1Left3.png"));
    house1Left4 = new Texture(Gdx.files.internal("House1/house1Left4.png"));
    house1LeftTop = new Texture(Gdx.files.internal("House1/house1LeftTop.png"));
    house1Right1 = new Texture(Gdx.files.internal("House1/house1Right1.png"));
    house1Right2 = new Texture(Gdx.files.internal("House1/house1Right2.png"));
    house1Right3 = new Texture(Gdx.files.internal("House1/house1Right3.png"));
    house1Right4 = new Texture(Gdx.files.internal("House1/house1Right4.png"));
    house1RightTop = new Texture(Gdx.files.internal("House1/house1RightTop.png"));
    house1SmokeStack = new Texture(Gdx.files.internal("House1/house1SmokeStack.png"));
    house1Top1 = new Texture(Gdx.files.internal("House1/house1Top1.png"));
    house1Top2 = new Texture(Gdx.files.internal("House1/house1Top2.png"));
    house1Wall1 = new Texture(Gdx.files.internal("House1/house1Wall1.png"));
    house1Wall2 = new Texture(Gdx.files.internal("House1/house1Wall2.png"));
    house1Wall3 = new Texture(Gdx.files.internal("House1/house1Wall3.png"));
    house1Window2LeftBottom = new Texture(Gdx.files.internal("House1/house1Window2LeftBottom.png"));
    house1Window2LeftTop = new Texture(Gdx.files.internal("House1/house1Window2LeftTop.png"));
    house1Window2RightBottom = new Texture(Gdx.files.internal("House1/house1Window2RightBottom.png"));
    house1Window2RightTop = new Texture(Gdx.files.internal("House1/house1Window2RightTop.png"));
    house1WindowLeftBottom = new Texture(Gdx.files.internal("House1/house1WindowLeftBottom.png"));
    house1WindowLeftTop = new Texture(Gdx.files.internal("House1/house1WindowLeftTop.png"));
    house1WindowRightBottom = new Texture(Gdx.files.internal("House1/house1WindowRightBottom.png"));
    house1WindowRightTop = new Texture(Gdx.files.internal("House1/house1WindowRightTop.png"));
    Spikes1 = new Texture(Gdx.files.internal("Spikes1.png"));
    //ShapeRenderer
    shape = new ShapeRenderer();
}

From source file:ch.p1gu.game.systeme.affichage.DessinerFormes.java

@Override
protected void initialize() {
    rendererFilled = new ShapeRenderer();

}

From source file:ch.p1gu.game.systeme.affichage.DessinerHUD.java

@Override
protected void initialize() {

    rendererFilled = new ShapeRenderer();

}

From source file:com.andgate.pokeadot.PokeADot.java

License:Open Source License

@Override
public void create() {
    batch = new SpriteBatch();
    shape = new ShapeRenderer();

    Gdx.input.setCatchBackKey(true);/*from  w  w w  . ja v  a  2  s  .  co m*/

    screenAdjustments(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());

    skin = new Skin(Gdx.files.internal(Constants.SKIN_LOCATION));

    createPauseBG();
    createFonts();

    hitSound = Gdx.audio.newSound(Gdx.files.internal(Constants.HIT_SOUND_LOCATION));
    missSound = Gdx.audio.newSound(Gdx.files.internal(Constants.MISS_SOUND_LOCATION));
    buttonPressedSound = Gdx.audio.newSound(Gdx.files.internal(Constants.BUTTON_PRESSED_SOUND_LOCATION));

    resetGame();

    setScreen(new MainMenuScreen(this));
}

From source file:com.belocraft.gameworld.GameRenderer.java

public GameRenderer(GameWorld world, int gameHeight, int midPointY) {
    myWorld = world;/*from  w  w w.  ja va 2s.c o m*/

    this.midPointY = midPointY;
    this.menuButtons = ((InputHandler) Gdx.input.getInputProcessor()).getMenuButtons();

    cam = new OrthographicCamera();
    cam.setToOrtho(true, 136, gameHeight);

    batcher = new SpriteBatch();
    batcher.setProjectionMatrix(cam.combined);
    shapeRenderer = new ShapeRenderer();
    shapeRenderer.setProjectionMatrix(cam.combined);

    initGameObjects();
    initAssets();
    setupTweens();

}