Search in sources :

Example 26 with ShapeRenderer

use of com.badlogic.gdx.graphics.glutils.ShapeRenderer in project libgdx by libgdx.

the class TiledMapObjectLoadingTest method create.

@Override
public void create() {
    float w = Gdx.graphics.getWidth();
    float h = Gdx.graphics.getHeight();
    camera = new OrthographicCamera();
    camera.setToOrtho(false, (w / h) * 100, 100);
    camera.zoom = 2;
    camera.update();
    cameraController = new OrthoCamController(camera);
    Gdx.input.setInputProcessor(cameraController);
    font = new BitmapFont();
    batch = new SpriteBatch();
    map = new TmxMapLoader().load("data/maps/tiled-objects/test-load-mapobjects.tmx");
    MapProperties properties = map.getProperties();
    shapeRenderer = new ShapeRenderer();
}
Also used : TmxMapLoader(com.badlogic.gdx.maps.tiled.TmxMapLoader) OrthographicCamera(com.badlogic.gdx.graphics.OrthographicCamera) OrthoCamController(com.badlogic.gdx.tests.utils.OrthoCamController) MapProperties(com.badlogic.gdx.maps.MapProperties) BitmapFont(com.badlogic.gdx.graphics.g2d.BitmapFont) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch) ShapeRenderer(com.badlogic.gdx.graphics.glutils.ShapeRenderer)

Example 27 with ShapeRenderer

use of com.badlogic.gdx.graphics.glutils.ShapeRenderer in project libgdx by libgdx.

the class SpriteBatchOriginScaleTest method create.

@Override
public void create() {
    region = new TextureRegion(new Texture("data/badlogicsmall.jpg"));
    batch = new SpriteBatch();
    renderer = new ShapeRenderer();
    renderer.setProjectionMatrix(batch.getProjectionMatrix());
}
Also used : TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) Texture(com.badlogic.gdx.graphics.Texture) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch) ShapeRenderer(com.badlogic.gdx.graphics.glutils.ShapeRenderer)

Example 28 with ShapeRenderer

use of com.badlogic.gdx.graphics.glutils.ShapeRenderer in project libgdx by libgdx.

the class PolygonSpriteTest method create.

@Override
public void create() {
    texture = new Texture(Gdx.files.internal("data/tree.png"));
    PolygonRegionLoader loader = new PolygonRegionLoader();
    region = loader.load(new TextureRegion(texture), Gdx.files.internal("data/tree.psh"));
    renderer = new ShapeRenderer();
    camera = new OrthographicCamera(480, 320);
    camera.position.x = 240;
    camera.position.y = 160;
    camera.update();
    batch = new PolygonSpriteBatch();
    for (int i = 0; i < 50; i++) {
        PolygonSprite sprite = new PolygonSprite(region);
        sprite.setPosition(MathUtils.random(-30, 440), MathUtils.random(-30, 290));
        sprite.setColor(MathUtils.random(), MathUtils.random(), MathUtils.random(), 1.0f);
        sprite.setScale(MathUtils.random(0.5f, 1.5f), MathUtils.random(0.5f, 1.5f));
        sprites.add(sprite);
    }
}
Also used : TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) PolygonRegionLoader(com.badlogic.gdx.graphics.g2d.PolygonRegionLoader) OrthographicCamera(com.badlogic.gdx.graphics.OrthographicCamera) PolygonSprite(com.badlogic.gdx.graphics.g2d.PolygonSprite) Texture(com.badlogic.gdx.graphics.Texture) PolygonSpriteBatch(com.badlogic.gdx.graphics.g2d.PolygonSpriteBatch) ShapeRenderer(com.badlogic.gdx.graphics.glutils.ShapeRenderer)

Example 29 with ShapeRenderer

use of com.badlogic.gdx.graphics.glutils.ShapeRenderer in project Catacomb-Snatch by Catacomb-Snatch.

the class Monitoring method render.

public static void render(Batch batch) {
    if (font == null) {
        font = Art.skin.get(Label.LabelStyle.class).font;
    }
    if (renderer == null) {
        renderer = new ShapeRenderer();
    }
    renderer.setProjectionMatrix(batch.getProjectionMatrix());
    renderer.begin(ShapeRenderer.ShapeType.Filled);
    int y = 1, base;
    for (Property property : PROPERTIES.values()) {
        renderer.setColor(property.color);
        base = y;
        for (int x = 64, i = 0; i < SAMPLES; i++) {
            renderer.rectLine(x, y, x += 2, y = Math.max(base, base + Math.round(property.values[i] / property.maximum * 36)), 2);
        }
        y = base + 48;
    }
    renderer.end();
    batch.begin();
    y = 10;
    Property property;
    for (Map.Entry<String, Property> entry : PROPERTIES.entrySet()) {
        property = entry.getValue();
        font.draw(batch, entry.getKey(), 2, y + 30);
        font.draw(batch, "max:", 2, y + 20);
        font.draw(batch, "" + property.maximum, 26, y + 20);
        font.draw(batch, "min:", 2, y + 10);
        font.draw(batch, "" + property.minimum, 26, y + 10);
        font.draw(batch, "val:", 2, y);
        font.draw(batch, "" + property.values[SAMPLES - 1], 26, y);
        y += 48;
    }
    batch.end();
}
Also used : Label(com.badlogic.gdx.scenes.scene2d.ui.Label) Map(java.util.Map) THashMap(gnu.trove.map.hash.THashMap) ShapeRenderer(com.badlogic.gdx.graphics.glutils.ShapeRenderer)

Example 30 with ShapeRenderer

use of com.badlogic.gdx.graphics.glutils.ShapeRenderer in project Alkahest-Coffee by AlkahestDev.

the class MainGame method create.

@Override
public void create() {
    Gdx.graphics.setCursor(Gdx.graphics.newCursor(new Pixmap(Gdx.files.internal("mouseCursorTemp.png")), 0, 0));
    assetManager = new AssetManager();
    queueLoading();
    camera = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    camera.translate(Gdx.graphics.getWidth() / 2, Gdx.graphics.getHeight() / 2);
    camera.update();
    //viewport = new FitViewport(1920, 1080, camera);
    fontCaches = new Array<BitmapFontCache>();
    BitmapFont dagger20 = new BitmapFont(Gdx.files.internal("fonts/dagger20.fnt"));
    BitmapFont dagger30 = new BitmapFont(Gdx.files.internal("fonts/dagger30.fnt"));
    BitmapFont dagger40 = new BitmapFont(Gdx.files.internal("fonts/dagger40.fnt"));
    BitmapFont dagger50 = new BitmapFont(Gdx.files.internal("fonts/dagger50.fnt"));
    dagger20.getData().markupEnabled = true;
    dagger30.getData().markupEnabled = true;
    dagger40.getData().markupEnabled = true;
    dagger50.getData().markupEnabled = true;
    fontCaches.add(new BitmapFontCache(dagger20));
    fontCaches.add(new BitmapFontCache(dagger30));
    fontCaches.add(new BitmapFontCache(dagger40));
    fontCaches.add(new BitmapFontCache(dagger50));
    shapeRenderer = new ShapeRenderer();
    gameMain = new MainMenu(fontCaches, assetManager, camera);
    loadingMenu = new LoadingMenu(fontCaches, assetManager, camera);
    connectingMenu = new ConnectingMenu(fontCaches, assetManager, camera);
    serverBrowser = new ServerBrowser(fontCaches, assetManager, camera);
    settingsMenu = new SettingsMenu(fontCaches, assetManager, camera);
    pickingInfoMenu = new ClientPickingInfoMenu(fontCaches, assetManager, camera);
    lobbyMenu = new ClientLobbyMenu(fontCaches, assetManager, camera);
    // loadingmenu is the only one that is setup before anything else is loaded, background frames are loaded and added to it here
    setupLoadingMenu();
    scW = Gdx.graphics.getWidth();
    scH = Gdx.graphics.getHeight();
    //System.out.println(new Pixmap(Gdx.files.internal("pixmapTest.png")).getPixel(0,0)>>8);//since gimp doesn't do alpha in a friendly way, I'll bitshift right 8 bits to ignore alpha
    state = GameState.State.LOADINGGAME;
    batch = new SpriteBatch();
    client = new MultiplayerClient();
    clientSoldier = new PlayerSoldier(new Rectangle(0, 0, 1, 2), 0, "");
    client.startClient();
    shapeRenderer.setProjectionMatrix(camera.combined);
    batch.setProjectionMatrix(camera.combined);
    menu = new UniversalClientMenu(fontCaches, assetManager, camera);
    Gdx.input.setInputProcessor(this);
}
Also used : MultiplayerClient(me.dumfing.multiplayerTools.MultiplayerClient) AssetManager(com.badlogic.gdx.assets.AssetManager) Rectangle(com.badlogic.gdx.math.Rectangle) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch) BitmapFontCache(com.badlogic.gdx.graphics.g2d.BitmapFontCache) ShapeRenderer(com.badlogic.gdx.graphics.glutils.ShapeRenderer) PlayerSoldier(me.dumfing.multiplayerTools.PlayerSoldier) BitmapFont(com.badlogic.gdx.graphics.g2d.BitmapFont)

Aggregations

ShapeRenderer (com.badlogic.gdx.graphics.glutils.ShapeRenderer)31 SpriteBatch (com.badlogic.gdx.graphics.g2d.SpriteBatch)16 BitmapFont (com.badlogic.gdx.graphics.g2d.BitmapFont)12 OrthographicCamera (com.badlogic.gdx.graphics.OrthographicCamera)10 Texture (com.badlogic.gdx.graphics.Texture)8 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)7 Stage (com.badlogic.gdx.scenes.scene2d.Stage)5 Label (com.badlogic.gdx.scenes.scene2d.ui.Label)5 ScreenViewport (com.badlogic.gdx.utils.viewport.ScreenViewport)5 InputAdapter (com.badlogic.gdx.InputAdapter)4 AssetManager (com.badlogic.gdx.assets.AssetManager)4 PerspectiveCamera (com.badlogic.gdx.graphics.PerspectiveCamera)3 TextureAtlas (com.badlogic.gdx.graphics.g2d.TextureAtlas)3 Model (com.badlogic.gdx.graphics.g3d.Model)3 TmxMapLoader (com.badlogic.gdx.maps.tiled.TmxMapLoader)3 Animation (com.badlogic.gdx.graphics.g2d.Animation)2 BitmapFontCache (com.badlogic.gdx.graphics.g2d.BitmapFontCache)2 FreeTypeFontGenerator (com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator)2 FreeTypeFontParameter (com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator.FreeTypeFontParameter)2 OrthogonalTiledMapRenderer (com.badlogic.gdx.maps.tiled.renderers.OrthogonalTiledMapRenderer)2