List of usage examples for com.badlogic.gdx.graphics.glutils ShapeRenderer ShapeRenderer
public ShapeRenderer()
From source file:org.illarion.engine.backend.gdx.GdxGraphics.java
License:Open Source License
/** * Create a new instance of the graphics engine that is using libGDX to render. * * @param gdxGraphics the libGDX graphics instance that is used *///from w w w .j a va 2s . com GdxGraphics(@Nonnull final GdxEngine engine, @Nonnull final com.badlogic.gdx.Graphics gdxGraphics) { this.gdxGraphics = gdxGraphics; this.engine = engine; shapeRenderer = new ShapeRenderer(); spriteBatch = new SpriteBatch(1000, 10); tempColor1 = new com.badlogic.gdx.graphics.Color(); tempColor2 = new com.badlogic.gdx.graphics.Color(); tempColor3 = new com.badlogic.gdx.graphics.Color(); tempColor4 = new com.badlogic.gdx.graphics.Color(); tempRegion = new TextureRegion(); tempEngineRectangle = new Rectangle(); camera = new OrthographicCamera(); camera.zoom = 1.f; camera.setToOrtho(true); }
From source file:org.saltosion.pixelprophecy.gui.GUIManager.java
License:Open Source License
public GUIManager() { guiCamera = new OrthographicCamera(); spriteBatch = new SpriteBatch(); guiDebugRenderer = new ShapeRenderer(); guiDebugRenderer.setAutoShapeType(true); }
From source file:pl.kotcrab.jdialogue.editor.Renderer.java
License:Open Source License
@Override public void create() { Assets.load();/* ww w . j av a 2 s . c om*/ prefs = Gdx.app.getPreferences("pl.kotcrab.dialoguelib.editorprefs"); App.setPrefs(prefs); App.loadPrefs(); camera = new OrthographicCamera(1280, 720); camera.position.x = 1280 / 2; camera.position.y = 720 / 2; Touch.setCamera(camera); cameraRect = CameraUtils.calcCameraBoundingRectangle(camera); shapeRenderer = new ShapeRenderer(); batch = new SpriteBatch(); rectangularSelection = new RectangularSelection(new RectangularSelectionListener() { @Override public void finishedDrawing(ArrayList<DComponent> matchingComponents) { selectedComponentsList = matchingComponents; } }, componentList); InputMultiplexer mul = new InputMultiplexer(); mul.addProcessor(this); mul.addProcessor(new GestureDetector(this)); mul.addProcessor(rectangularSelection); Gdx.input.setInputProcessor(mul); connectionRenderer = new ConnectionRenderer(); infoText = new KotcrabText(Assets.consolasFont, "Load or create new project to begin!", false, 0, 0); infoText.setScale(1.4f); }
From source file:pl.kotcrab.libgdx.util.RectangleDrawer.java
License:Apache License
public RectangleDrawer() { shapeRenderer = new ShapeRenderer(); matrix = new Matrix4(); matrix.setToOrtho2D(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); shapeRenderer.setProjectionMatrix(matrix); shapeRenderer.setColor(Color.GREEN); }
From source file:releasethekraken.ui.renderer.GameRenderer.java
/** * Constructs a new GameRenderer/* w w w .j a v a2 s. c o m*/ * @param rtk The ReleaseTheKraken instance. This is final so that the * anonymous inner classes can access it. * @param world The world to be rendered */ public GameRenderer(final ReleaseTheKraken rtk, GameWorld world) { super(); this.world = world; //Populate the list of connected paths this.world.getFirstPath().getAllConnectedPaths(this.seaCreaturePaths); //Create the camera to view the world this.camera = new OrthographicCamera(); float cameraWidth = 80.0F; float cameraHeight = (Gdx.graphics.getHeight() * 1F / Gdx.graphics.getWidth()) * cameraWidth; this.camera.setToOrtho(false, cameraWidth, cameraHeight); Gdx.app.log("GameRenderer", "Calculated camera dimensions: " + cameraWidth + " x " + cameraHeight); this.worldSpriteBatch = new SpriteBatch(); this.worldShapeRenderer = new ShapeRenderer(); //Set the world renderers to render to the camera's projection matrix this.worldSpriteBatch.setProjectionMatrix(this.camera.combined); this.worldShapeRenderer.setProjectionMatrix(this.camera.combined); //Create the Box2D debug renderer this.box2DDebugRenderer = new Box2DDebugRenderer(); this.box2DDebugRenderer.setDrawVelocities(true); //Create the tile map renderer this.tiledMapRenderer = new OrthogonalTiledMapRenderer(world.getTiledMap(), 1 / (world.getTiledMapUnitScale())); //this.tiledMapRenderer.getBatch().setShader(GameAssets.tilemapShader); //Set the shader //Don't use the shader for now this.debugOverlay = new DebugOverlay(this); this.uiObjects.add(this.debugOverlay); UiButton pauseButton = new UiButton(this, Gdx.graphics.getWidth() - 0.075F * Gdx.graphics.getWidth(), Gdx.graphics.getHeight() - 0.05F * Gdx.graphics.getHeight(), 0.075F, 0.05F, "Pause", Color.GRAY.cpy().sub(0.1F, 0.1F, 0.1F, 0)) { @Override public void onClick(int mouseButton) { super.onClick(mouseButton); //Take a screenshot of the game Pixmap pixmap = Screenshots.getScreenshot(true); //Push a new pause screen onto the screen stack rtk.pushScreen(new PauseScreen(rtk, pixmap)); } }; pauseButton.setToolTip(new TextToolTip(this, "Pause the game")); this.uiObjects.add(pauseButton); UiButton debugMenuButton = new UiButton(this, Gdx.graphics.getWidth() - 0.2323F * Gdx.graphics.getWidth(), Gdx.graphics.getHeight() - 0.05F * Gdx.graphics.getHeight(), 0.157F, 0.05F, "Debug Screen", Color.GRAY.cpy().sub(0.1F, 0.1F, 0.1F, 0)) { @Override public void onClick(int mouseButton) { super.onClick(mouseButton); if (this.renderer instanceof GameRenderer) { ((GameRenderer) this.renderer).debugScreenVisible = !((GameRenderer) this.renderer).debugScreenVisible; //Toggle visibility Gdx.app.log("Debug Menu Button", "Debug screen " + (((GameRenderer) this.renderer).debugScreenVisible ? "ON" : "OFF")); } } }; debugMenuButton.setToolTip(new TextToolTip(this, "Show/Hide Debug Screen")); this.uiObjects.add(debugMenuButton); this.uiObjects.add(new Sidebar(this)); //Add the sidebar this.uiObjects.sort(); //Sort the UI objects so that they render in the order of their render depths //Generate path pixmap and texture Pixmap.setBlending(Pixmap.Blending.None); //Disable Pixmap blending, because it causes weird lines this.pathPixmap = new Pixmap((int) (this.world.getWidth() * this.world.getTiledMapUnitScale()), (int) (this.world.getHeight() * this.world.getTiledMapUnitScale()), Pixmap.Format.RGBA8888); //Make sure the pixmap is clear this.pathPixmap.setColor(new Color(0, 0, 0, 0)); //Completely clear this.pathPixmap.fill(); this.pathPixmap.setColor(Color.valueOf("61B5FF66")); //Partial transparency with color //Draw the path for every path for (SeaCreaturePath path : this.seaCreaturePaths) { CatmullRomSpline smoothPath = path.getSmoothPath(); Vector2 pathPoint = new Vector2(); //Move across the path from 0 to 1, drawing circles along the way for (float f = -0.1F; f < 1.1F; f += 0.001F) { smoothPath.valueAt(pathPoint, f); //Stores the value of the path at the point in the vector this.pathPixmap.fillCircle((int) (pathPoint.x * this.world.getTiledMapUnitScale()), (int) (this.world.getHeight() * this.world.getTiledMapUnitScale() - (pathPoint.y * this.world.getTiledMapUnitScale())), (int) this.world.getTiledMapUnitScale()); } } //Create texture to hold pixmap data this.pathTexture = new Texture(this.pathPixmap); this.pathTexture.draw(this.pathPixmap, 0, 0); //Draw the pixmap to the texture this.pathTexture.bind(1); //Bind the texture to texture unit 1 Gdx.gl.glActiveTexture(GL20.GL_TEXTURE0); //Set the active texture back to the normal one }
From source file:releasethekraken.ui.renderer.UiRenderer.java
/** * Constructor/*from w ww . java 2 s .c o m*/ */ public UiRenderer() { this.uiSpriteBatch = new SpriteBatch(); this.uiShapeRenderer = new ShapeRenderer(); this.uiObjects = new Array<UiObject>(); }
From source file:rosthouse.rosty.systems.debug.ShapeRenderSystem.java
/** * Creates a new ShapeRenderSystem./*from w w w.ja v a 2 s . c o m*/ * * @param processing Wheter the system should be processed. */ public ShapeRenderSystem(Boolean processing) { super(Family.all(OrthographicCameraComponent.class).get()); shapeRenderer = new ShapeRenderer(); shapeRenderer.setAutoShapeType(true); setProcessing(false); }
From source file:scenes.Background.java
@Override public void create() { sr = new ShapeRenderer(); sr.setAutoShapeType(true);//w w w . ja v a2s . c om debris = new ArrayList<Debris>(); for (int i = 0; i < 50; i++) { debris.add(new Debris(Gdx.graphics.getWidth(), Gdx.graphics.getHeight())); } }
From source file:scenes.GameCreate.java
@Override public void create() { playerLimitIndex = 0;/* w w w . ja v a 2s .co m*/ shapeRenderer = new ShapeRenderer(); shapeRenderer.setAutoShapeType(true); batch = new SpriteBatch(); availableMaps = GameMaps.getMaps(); availableGameModeMap = GameMapsDomination.getMaps(); availableGamemodes = new GameMode[] { new NormalMatch("Normal Game"), new TutorialMatch("Tutorial"), new DominationMatch("Domination") }; stage = new Stage(); Gdx.input.setInputProcessor(stage); atlas = new TextureAtlas("ui/buttonPack.pack"); skin = new Skin(atlas); table = new Table(skin); table.setBounds(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); //initialize fonts FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal("fonts/MunroSmall.ttf")); FreeTypeFontGenerator.FreeTypeFontParameter parameter = new FreeTypeFontGenerator.FreeTypeFontParameter(); parameter.size = 60; font60 = generator.generateFont(parameter); // font size 12 pixels font60.setColor(Color.BLACK); parameter.size = 40; font30 = generator.generateFont(parameter); // font size 12 pixels font30.setColor(0.5f, 0.5f, 0.5f, 255); generator.dispose(); // don't forget to dispose to avoid memory leaks! final TextButtonStyle textButtonStyle = new TextButtonStyle(); textButtonStyle.downFontColor = new Color(0f, 0.57f, 0.92f, 1f); textButtonStyle.overFontColor = new Color(0f, 0.57f, 1f, 1f); textButtonStyle.font = font30; textButtonStyle.fontColor = Color.BLACK; buttonPlay = new TextButton("Start Game", textButtonStyle); buttonPlay.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { if ("Domination".equals(availableGamemodes[selectedGameMode].getName())) { Config.page = new SearchGame(availableGameModeMap[selectedMap].getName(), availableGamemodes[selectedGameMode].getName(), playerLimit[playerLimitIndex]); } else { Config.page = new SearchGame(availableMaps[selectedMap].getName(), availableGamemodes[selectedGameMode].getName(), playerLimit[playerLimitIndex]); } } }); buttonExit = new TextButton("Back", textButtonStyle); buttonExit.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { Config.page = new MainMenu(); } }); buttonExit.pad(20); LabelStyle headingStyle = new LabelStyle(font60, Color.BLACK); final TextButton toggleGameMode = new TextButton( "GameMode: " + availableGamemodes[selectedGameMode].getName(), textButtonStyle); toggleGameMode.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { selectedGameMode++; if (selectedGameMode >= availableGamemodes.length) { selectedGameMode = 0; } toggleGameMode.setText("GameMode: " + availableGamemodes[selectedGameMode].getName()); } }); final TextButton toggleLevel = new TextButton("Map: " + availableMaps[selectedMap].getName(), textButtonStyle); toggleLevel.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { selectedMap++; if (selectedMap >= availableMaps.length) { selectedMap = 0; } toggleLevel.setText("Map: " + availableMaps[selectedMap].getName()); } }); final TextButton togglePlayeLimit = new TextButton("players: " + playerLimit[playerLimitIndex], textButtonStyle); togglePlayeLimit.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { playerLimitIndex++; if (playerLimitIndex >= playerLimit.length) { playerLimitIndex = 0; } togglePlayeLimit.setText("players: " + playerLimit[playerLimitIndex]); } }); heading = new Label("Game modes", headingStyle); table.add(heading); table.row(); table.padBottom(100); table.add(toggleGameMode); table.row(); table.padBottom(50); table.add(toggleLevel); table.row(); table.padBottom(50); table.add(togglePlayeLimit); table.row(); table.padBottom(50); table.add(buttonPlay); table.row(); table.padBottom(50); table.add(buttonExit); //table.debug(); stage.addActor(table); //xOffset = (Gdx.graphics.getWidth() / 100 * 65); xOffset = (int) table.getX() + (int) toggleLevel.getRight() + (Gdx.graphics.getWidth() / 2); yOffset = Gdx.graphics.getHeight() / 2 - (availableMaps[selectedMap].getHeight() / 5); }
From source file:scenes.GameModeSelect.java
@Override public void create() { playerLimitIndex = 0;//w w w . j a v a 2 s . co m shapeRenderer = new ShapeRenderer(); shapeRenderer.setAutoShapeType(true); batch = new SpriteBatch(); availableMaps = GameMaps.getMaps(); stage = new Stage(); Gdx.input.setInputProcessor(stage); atlas = new TextureAtlas("ui/buttonPack.pack"); skin = new Skin(atlas); table = new Table(skin); table.setBounds(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); //initialize fonts FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal("fonts/MunroSmall.ttf")); FreeTypeFontGenerator.FreeTypeFontParameter parameter = new FreeTypeFontGenerator.FreeTypeFontParameter(); parameter.size = 60; font60 = generator.generateFont(parameter); // font size 12 pixels font60.setColor(Color.BLACK); parameter.size = 40; font30 = generator.generateFont(parameter); // font size 12 pixels font30.setColor(0.5f, 0.5f, 0.5f, 255); generator.dispose(); // don't forget to dispose to avoid memory leaks! final TextButtonStyle textButtonStyle = new TextButtonStyle(); textButtonStyle.downFontColor = new Color(0f, 0.57f, 0.92f, 1f); textButtonStyle.overFontColor = new Color(0f, 0.57f, 1f, 1f); textButtonStyle.font = font30; textButtonStyle.fontColor = Color.BLACK; buttonTut = new TextButton("Tutorial", textButtonStyle); buttonTut.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { Config.page = new SearchGame(availableMaps[selectedMap].getName(), "Tutorial", playerLimit[playerLimitIndex]); } }); buttonTut.pad(20); buttonPlay = new TextButton("Normal Game", textButtonStyle); buttonPlay.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { Config.page = new SearchGame(availableMaps[selectedMap].getName(), "Normal Game", playerLimit[playerLimitIndex]); } }); buttonPlay.pad(20); buttonExit = new TextButton("Back", textButtonStyle); buttonExit.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { Config.page = new MainMenu(); } }); buttonExit.pad(20); LabelStyle headingStyle = new LabelStyle(font60, Color.BLACK); final TextButton toggleLevel = new TextButton("Map: " + availableMaps[selectedMap].getName(), textButtonStyle); toggleLevel.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { selectedMap++; if (selectedMap >= availableMaps.length) selectedMap = 0; toggleLevel.setText("Map: " + availableMaps[selectedMap].getName()); } }); final TextButton togglePlayeLimit = new TextButton("players: " + playerLimit[playerLimitIndex], textButtonStyle); togglePlayeLimit.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { playerLimitIndex++; if (playerLimitIndex >= playerLimit.length) playerLimitIndex = 0; togglePlayeLimit.setText("players: " + playerLimit[playerLimitIndex]); } }); heading = new Label("Game modes", headingStyle); table.add(heading); table.row(); table.padBottom(50); table.add(buttonTut); table.row(); table.padBottom(50); table.add(buttonPlay); table.row(); table.padBottom(50); table.add(toggleLevel); table.row(); table.padBottom(50); table.add(togglePlayeLimit); table.row(); table.padBottom(50); table.add(buttonExit); //table.debug(); stage.addActor(table); //xOffset = (Gdx.graphics.getWidth() / 100 * 65); xOffset = (int) table.getX() + (int) toggleLevel.getRight() + (Gdx.graphics.getWidth() / 2); yOffset = Gdx.graphics.getHeight() / 2 - (availableMaps[selectedMap].getHeight() / 5); }