List of usage examples for com.badlogic.gdx.graphics Color WHITE
Color WHITE
To view the source code for com.badlogic.gdx.graphics Color WHITE.
Click Source Link
From source file:com.gdx.game.scenes.Hud.java
public Hud(SpriteBatch sb) { this.worldTimer = 300; this.timeCount = 0; this.score = 0; this.viewPort = new FitViewport(GdxGame.V_WIDTH, GdxGame.V_HEIGHT, new OrthographicCamera()); this.stage = new Stage(this.viewPort, sb); Table table = new Table(); table.top();/* w w w. j av a 2s . com*/ table.setFillParent(true); this.countDownLabel = new Label(String.format("%03d", this.worldTimer), new Label.LabelStyle(new BitmapFont(), Color.WHITE)); this.scoreLabel = new Label(String.format("%06d", this.score), new Label.LabelStyle(new BitmapFont(), Color.WHITE)); this.timeLabel = new Label("TIME", new Label.LabelStyle(new BitmapFont(), Color.WHITE)); this.levelLabel = new Label("1-1", new Label.LabelStyle(new BitmapFont(), Color.WHITE)); this.worldLabel = new Label("WORLD", new Label.LabelStyle(new BitmapFont(), Color.WHITE)); this.charLabel = new Label("char", new Label.LabelStyle(new BitmapFont(), Color.WHITE)); table.add(this.charLabel).expandX().padTop(10); table.add(this.worldLabel).expandX().padTop(10); table.add(this.timeLabel).expandX().padTop(10); table.row(); table.add(this.scoreLabel).expandX(); table.add(this.levelLabel).expandX(); table.add(this.countDownLabel).expandX(); stage.addActor(table); }
From source file:com.gemserk.libgdx.test.HelloWorld.java
License:Apache License
@Override public void render() { int centerX = Gdx.graphics.getWidth() / 2; int centerY = Gdx.graphics.getHeight() / 2; Gdx.graphics.getGL10().glClear(GL10.GL_COLOR_BUFFER_BIT); // more fun but confusing :) //textPosition.add(textDirection.tmp().mul(Gdx.graphics.getDeltaTime()).mul(60)); textPosition.x += textDirection.x * Gdx.graphics.getDeltaTime() * 60; textPosition.y += textDirection.y * Gdx.graphics.getDeltaTime() * 60; if (textPosition.x < 0) { textDirection.x = -textDirection.x; textPosition.x = 0;// ww w. j ava 2 s . c om } if (textPosition.x > Gdx.graphics.getWidth()) { textDirection.x = -textDirection.x; textPosition.x = Gdx.graphics.getWidth(); } if (textPosition.y < 0) { textDirection.y = -textDirection.y; textPosition.y = 0; } if (textPosition.y > Gdx.graphics.getHeight()) { textDirection.y = -textDirection.y; textPosition.y = Gdx.graphics.getHeight(); } spriteBatch.begin(); spriteBatch.setColor(Color.WHITE); spriteBatch.draw(texture, centerX - texture.getWidth() / 2, centerY - texture.getHeight() / 2, 0, 0, texture.getWidth(), texture.getHeight()); font.draw(spriteBatch, "Hello World!", (int) textPosition.x, (int) textPosition.y); spriteBatch.end(); }
From source file:com.github.fauu.helix.core.MapRegion.java
License:Open Source License
public void create(Vector2 size, Tile[] tiles, Array<Object> objects, TextureAtlas textureAtlas, GeometrySet geometrySet) {//from ww w . j a va 2s .c o m this.size = size; this.textureAtlas = textureAtlas; this.geometrySet = geometrySet; this.objects = objects; if (tiles != null) { this.tiles = tiles; } else { final int tilesLength = (int) (size.x * size.y); tiles = new Tile[tilesLength]; for (int i = 0; i < tilesLength; i++) { final Tile.Builder tileBuilder = new Tile.Builder(); final int tileX = i % (int) size.x; final int tileY = (int) Math.floor(i / (tilesLength / size.y)); tiles[i] = tileBuilder.setNo(i).setPosition(new Vector2(tileX, tileY)).setElevation(0) .setTextureId(0).setGeometryId(0).setFacing(Direction.SOUTH).build(); } } this.tiles = tiles; mesh = new MapRegionMesh(tiles, geometrySet, textureAtlas); renderable = new Renderable(); renderable.mesh = mesh; renderable.material = new Material(new ColorAttribute(ColorAttribute.Diffuse, Color.WHITE), new TextureAttribute(TextureAttribute.Diffuse, textureAtlas.getTextures().first())); renderable.meshPartOffset = 0; renderable.meshPartSize = mesh.getNumVertices(); renderable.primitiveType = GL20.GL_TRIANGLES; renderable.worldTransform.idt(); }
From source file:com.github.fauu.helix.core.Object.java
License:Open Source License
public Object(Vector2 position, String modelName, Model model, int elevation, Direction facing) { this.position = position; this.elevation = elevation; this.modelInstance = new ModelInstance(model); this.modelName = modelName; this.facing = facing; modelInstance.transform.setToTranslation(position.x, elevation, position.y + 1).rotate(new Vector3(0, 1, 0), -90);// w ww. j a v a 2s .c o m final TextureAttribute textureAttribute = (TextureAttribute) modelInstance.materials.first() .get(TextureAttribute.Diffuse); textureAttribute.textureDescription.magFilter = Texture.TextureFilter.Nearest; textureAttribute.textureDescription.minFilter = Texture.TextureFilter.Nearest; modelInstance.materials.first().set(textureAttribute); modelInstance.materials.first().set(new ColorAttribute(ColorAttribute.createDiffuse(Color.WHITE))); modelInstance.materials.first().set(new BlendingAttribute(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA)); //modelInstance.materials.first().set(new FloatAttribute(FloatAttribute.AlphaTest, 0.14f)); }
From source file:com.github.fauu.helix.displayable.AreaDisplayable.java
License:Open Source License
public AreaDisplayable(Model model) { instance = new ModelInstance(model); animationController = new AnimationController(instance); instance.transform.rotate(new Vector3(1, 0, 0), 90); for (Material material : instance.materials) { TextureAttribute ta = (TextureAttribute) material.get(TextureAttribute.Diffuse); ta.textureDescription.magFilter = Texture.TextureFilter.Nearest; ta.textureDescription.minFilter = Texture.TextureFilter.Nearest; material.set(ta);/*from w w w . j ava 2 s.c o m*/ material.set(ColorAttribute.createDiffuse(Color.WHITE)); BlendingAttribute ba = new BlendingAttribute(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA); material.set(ba); } }
From source file:com.github.fauu.helix.editor.World.java
License:Open Source License
public void handleInput() { final Tile newMatchedTile = matchHoveredTile(Gdx.input.getX(), Gdx.input.getY()); Object newMatchedObject;/*from w w w.j av a 2 s . c o m*/ if (((EditorMode) editorFrame.getSidebar().getEditorModePicker().getSelectedItem()) .getType() == EditorMode.Type.OBJECT) { newMatchedObject = matchHoveredObject(Gdx.input.getX(), Gdx.input.getY()); if (newMatchedObject != matchedObject) { if (matchedObject != null) { mapRegion.setObjectColor(matchedObject, Color.WHITE); } if (newMatchedObject != null) { mapRegion.setObjectColor(newMatchedObject, new Color(0.5f, 0.5f, 0.5f, 1)); } matchedObject = newMatchedObject; } if (newMatchedObject != null) { if (Gdx.input.isButtonPressed(Input.Buttons.MIDDLE)) { mapRegion.deleteObject(newMatchedObject); } } } if (Gdx.input.isTouched()) { final EditorMode.Type editorMode = ((EditorMode) editorFrame.getSidebar().getEditorModePicker() .getSelectedItem()).getType(); if (Gdx.input.isButtonPressed(Input.Buttons.LEFT)) { if (!currentTilePainted) { switch (editorMode) { case TILE_GENERAL: paintTile(newMatchedTile); break; case TILE_TYPE: paintTileType(newMatchedTile); break; case OBJECT: paintObject(newMatchedTile); break; default: } currentTilePainted = true; } } else if (Gdx.input.isButtonPressed(Input.Buttons.RIGHT)) { final int deltaX = Gdx.input.getDeltaX(); final int deltaY = Gdx.input.getDeltaY(); camera.move(new Vector3(-CAMERA_DRAG_FACTOR * deltaX, 0, -CAMERA_DRAG_FACTOR * deltaY)); } } if (matchedTile != newMatchedTile) { if (matchedTile != null) { matchedTile.setHighlighted(false); mapRegion.getMesh().updateTileColor(matchedTile); } if (newMatchedTile != null) { newMatchedTile.setHighlighted(true); mapRegion.getMesh().updateTileColor(newMatchedTile); // TODO: Add more info to the status bar editorFrame.getStatusBar().setTileInfoText("Position: " + newMatchedTile.getPosition()); } else { editorFrame.getStatusBar().setTileInfoText(StatusBar.TILE_INFO_DEFAULT_TEXT); } matchedTile = newMatchedTile; currentTilePainted = false; } if (Gdx.input.isKeyPressed(Input.Keys.A)) { camera.rotateYAround( new Vector2(mapRegion.getCenterCoordinates().x, mapRegion.getCenterCoordinates().y), -2); } else if (Gdx.input.isKeyPressed(Input.Keys.D)) { camera.rotateYAround( new Vector2(mapRegion.getCenterCoordinates().x, mapRegion.getCenterCoordinates().y), 2); } else if (Gdx.input.isKeyPressed(Input.Keys.S)) { camera.resetYRotationAround( new Vector2(mapRegion.getCenterCoordinates().x, mapRegion.getCenterCoordinates().y)); } final EditorMode.Type editorMode = ((EditorMode) editorFrame.getSidebar().getEditorModePicker() .getSelectedItem()).getType(); if (editorMode == EditorMode.Type.TILE_GENERAL || editorMode == EditorMode.Type.TILE_TYPE) { if (Gdx.input.isKeyPressed(Input.Keys.SPACE)) { if (!mapRegion.areObjectsHidden()) { mapRegion.hideObjects(); } } else { if (mapRegion.areObjectsHidden()) { mapRegion.showObjects(); } } } }
From source file:com.github.fauu.helix.game.Game.java
License:Open Source License
@Override public void create() { camera = new Camera(new Vector3(32, 32, 0)); cameraInputController = new CameraInputController(camera); // Gdx.input.setInputProcessor(cameraInputController); assets = new AssetManager(); assets.setLoader(GeometrySet.class, new GeometrySetLoader(new InternalFileHandleResolver())); assets.setLoader(MapRegion.class, new MapRegionLoader(new InternalFileHandleResolver())); assets.load("assets/mapregions/0.hmr", MapRegion.class); assets.finishLoading();//from w ww . ja va 2 s . c o m mapRegion = assets.get("assets/mapregions/0.hmr", MapRegion.class); spriteBatch = new SpriteBatch(); renderer = new Renderer(); player = new Player(new Vector2(8, 17), new Texture(Gdx.files.internal("assets/sprites/player.png"))); camera.move(player.getRealPosition()); final ModelBuilder modelBuilder = new ModelBuilder(); waterTexture = new Texture("assets/textures/water.png"); final MeshPartBuilder.VertexInfo corner00 = new MeshPartBuilder.VertexInfo(); corner00.hasPosition = true; corner00.hasNormal = true; corner00.hasUV = true; corner00.setPos(0, 0, 0); corner00.setNor(0, 1, 0); corner00.setUV(0, 0); final MeshPartBuilder.VertexInfo corner10 = new MeshPartBuilder.VertexInfo(); corner10.hasPosition = true; corner10.hasNormal = true; corner10.hasUV = true; corner10.setPos(4, 0, 0); corner10.setNor(0, 1, 0); corner10.setUV(0, 1); final MeshPartBuilder.VertexInfo corner11 = new MeshPartBuilder.VertexInfo(); corner11.hasPosition = true; corner11.hasNormal = true; corner11.hasUV = true; corner11.setPos(4, 0, 14); corner11.setNor(0, 1, 0); corner11.setUV(1, 1); final MeshPartBuilder.VertexInfo corner01 = new MeshPartBuilder.VertexInfo(); corner01.hasPosition = true; corner01.hasNormal = true; corner01.hasUV = true; corner01.setPos(0, 0, 14); corner01.setNor(0, 1, 0); corner01.setUV(1, 0); modelBuilder.begin(); modelBuilder.node(); MeshPartBuilder meshPartBuilder = modelBuilder.part("water1", GL20.GL_TRIANGLES, VertexAttributes.Usage.Position | VertexAttributes.Usage.TextureCoordinates, new Material(TextureAttribute.createDiffuse(waterTexture), ColorAttribute.createDiffuse(Color.WHITE), new BlendingAttribute(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA))); meshPartBuilder.rect(corner00, corner10, corner11, corner01); waterModel = modelBuilder.end(); waterModelInstance = new ModelInstance(waterModel); WaterData waterData = new WaterData(); waterData.waveAmplitude = 0.02f; waterData.waveAngle = 0; waterData.waveFrequency = 0.5f; waterModelInstance.userData = waterData; // waterModelInstance.userData = new float[2]; // ((float[]) waterModelInstance.userData)[0] = 0; // waveAngle // ((float[]) waterModelInstance.userData)[1] = 0.1f; // waveAmplitude waterModelInstance.transform.translate(8, -0.1f, 19).rotate(0, 1, 0, -90).scale(1, 1, -1); // ((float[]) waterModelInstance.userData)[2] = 8; // startX // ((float[]) waterModelInstance.userData)[3] = 7; // sizeX // ((float[]) waterModelInstance.userData)[4] = 19; // startZ // ((float[]) waterModelInstance.userData)[5] = 5; // sizeZ }
From source file:com.github.skittishSloth.openSkies.maps.terrains.TerrainTile.java
private static Color buildInterpolatedElevationColor(final float elevVal, final Elevation elevation) { final int elevationOrd = elevation.ordinal(); final Elevation[] elevations = Elevation.values(); final int numElevations = elevations.length; final Color prevColor; if (elevationOrd == 0) { prevColor = null;/* w ww. j ava 2s. c o m*/ } else { prevColor = elevations[elevationOrd - 1].getColor(); } final Color nextColor; if (elevationOrd == (numElevations - 1)) { nextColor = null; } else { nextColor = elevations[elevationOrd + 1].getColor(); } final Color baseColor = elevation.getColor().cpy(); final Color target; final float diff; if (elevVal < 0.5f) { diff = 1.0f - (2 * elevVal); if (prevColor != null) { target = prevColor; } else { target = Color.BLACK; } } else { diff = elevVal; if (nextColor != null) { target = nextColor; } else { target = Color.WHITE; } } baseColor.lerp(target, diff); return baseColor; }
From source file:com.github.skittishSloth.openSkies.maps.terrains.TerrainTile.java
private static Color buildLatitudeColor(final Latitude latitude) { final Color baseColor; switch (latitude) { case POLAR:/* w w w . j ava 2 s . c om*/ baseColor = Color.WHITE; break; case TEMPERATE: baseColor = Color.GREEN; break; case TROPICAL: baseColor = Color.GREEN.cpy().sub(0.5f, 0.5f, 0.5f, 0); break; default: throw new UnsupportedOperationException("Unknown latitude: " + latitude); } return baseColor; }
From source file:com.github.skittishSloth.openSkies.maps.VoronoiTestScreen.java
public VoronoiTestScreen() { final int tileSize = 1; final int width = Gdx.graphics.getWidth() / tileSize; final int height = Gdx.graphics.getHeight() / tileSize; final int numSites = 2000; map = VoronoiMap.generateRandom(numSites, width, height); final Collection<Site> sites = map.getSites(); bfMap = new BruteForceVoronoiMap(width, height, tileSize, sites); final float[][] landProbability = PerlinNoiseGenerator.generatePerlinNoise(width, height, 2); final Pixmap pm = new Pixmap(width, height, Pixmap.Format.RGBA8888); pm.setColor(Color.BLACK);//from ww w .j av a 2 s. c o m pm.fill(); final Map<Site, Cell> cells = bfMap.buildCells(landProbability); for (final Site site : sites) { final Cell cell = cells.get(site); if (cell == null) { System.err.println("Cell was null for site " + site.getX() + ", " + site.getY()); continue; } final boolean landCell = cell.isLand(); final Color cellColor; if (landCell) { cellColor = Elevation.PLAINS.getColor(); } else { cellColor = Elevation.WATER.getColor(); } pm.setColor(cellColor); final List<VoronoiTile> tiles = cell.getTiles(); for (final VoronoiTile tile : tiles) { final int x = tile.getX(); final int y = tile.getY(); pm.drawPixel(x, y); } } pm.setColor(Color.BLACK); for (final Site site : sites) { final Cell cell = cells.get(site); if (cell == null) { System.err.println("Cell was null for site " + site.getX() + ", " + site.getY()); continue; } final Polygon polygon = cell.calculateConvexHull(); final float[] vertices = polygon.getVertices(); final boolean hasCornerPoint = cell.hasCornerPoint(); final List<Point> verticesPoints = new ArrayList<Point>(); for (int i = 0; i < vertices.length - 1;) { final int x = Math.round(vertices[i++]); final int y = Math.round(vertices[i++]); if ((x == 0) && (y == 0)) { if (!hasCornerPoint) { continue; } } final Point p = new Point(x, y); verticesPoints.add(p); } final int numPoints = verticesPoints.size(); for (int i = 0; i < numPoints - 1;) { final Point p1 = verticesPoints.get(i++); final Point p2 = verticesPoints.get(i++); pm.drawLine(p1.x, p1.y, p2.x, p2.y); } } pm.setColor(Color.WHITE); for (final Site site : sites) { final int x = site.getX(); final int y = site.getY(); pm.drawPixel(x, y); } mapTexture = new Texture(pm); pm.dispose(); batch = new SpriteBatch(); }