com.badlogic.gdx.graphics.Colors Java Examples
The following examples show how to use
com.badlogic.gdx.graphics.Colors.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LoadingScreen.java From xibalba with MIT License | 6 votes |
@Override public void render(float delta) { Gdx.gl.glClearColor( Colors.get("screenBackground").r, Colors.get("screenBackground").g, Colors.get("screenBackground").b, Colors.get("screenBackground").a ); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); if (Main.assets.update()) { Main.asciiAtlas = Main.assets.get("sprites/qbicfeet_10x10.atlas"); Main.soundManager = new SoundManager(); main.setScreen(new MainMenuScreen(main)); } stage.act(delta); stage.draw(); }
Example #2
Source File: Parser.java From typing-label with MIT License | 6 votes |
/** Encloses the given string in brackets to work as a regular color markup tag. */ private static String stringToColorMarkup(String str) { if(str != null) { // Upper case str = str.toUpperCase(); // If color isn't registered by name, try to parse it as an hex code. Color namedColor = Colors.get(str); if(namedColor == null) { boolean isHexWithoutHashChar = str.length() >= 6 && PATTERN_COLOR_HEX_NO_HASH.matches(str); if(isHexWithoutHashChar) { str = "#" + str; } } } // Return color code return "[" + str + "]"; }
Example #3
Source File: Parser.java From typing-label with MIT License | 6 votes |
/** Parses a color from the given string. Returns null if the color couldn't be parsed. */ static Color stringToColor(String str) { if(str != null) { // Try to parse named color Color namedColor = Colors.get(str.toUpperCase()); if(namedColor != null) { return new Color(namedColor); } // Try to parse hex if(str.length() >= 6) { try { return Color.valueOf(str); } catch(NumberFormatException ignored) { } } } return null; }
Example #4
Source File: PauseScreen.java From xibalba with MIT License | 5 votes |
@Override public void render(float delta) { Gdx.gl.glClearColor( Colors.get("screenBackground").r, Colors.get("screenBackground").g, Colors.get("screenBackground").b, Colors.get("screenBackground").a ); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); stage.act(delta); stage.draw(); }
Example #5
Source File: Map.java From xibalba with MIT License | 5 votes |
private void paintForest() { map = new MapCell[width][height]; Array<String> floorTypes = new Array<>(); floorTypes.add("0915"); floorTypes.add("1202"); for (int x = 0; x < geometry.length; x++) { for (int y = 0; y < geometry[x].length; y++) { if (geometry[x][y] == MapCell.Type.FLOOR) { Sprite floor = Main.asciiAtlas.createSprite(floorTypes.random()); floor.setColor(Colors.get("forestFloor")); floor.setFlip(MathUtils.randomBoolean(), false); map[x][y] = new MapCell( floor, MapCell.Type.FLOOR, "the forest floor" ); } else { Sprite wall = Main.asciiAtlas.createSprite("0" + MathUtils.random(5, 6) + "00"); Color color = Colors.get("forestTree-" + MathUtils.random(1, 3)); wall.setColor(color); map[x][y] = new MapCell(wall, MapCell.Type.WALL, "a tree"); } map[x][y].sprite.setPosition(x * Main.SPRITE_WIDTH, y * Main.SPRITE_HEIGHT); } } if (MathUtils.random() > .5f) { createWater(); createBridge(); } }
Example #6
Source File: Map.java From xibalba with MIT License | 5 votes |
private void paintCave() { map = new MapCell[width][height]; for (int x = 0; x < geometry.length; x++) { for (int y = 0; y < geometry[x].length; y++) { if (geometry[x][y] == MapCell.Type.FLOOR) { Sprite floor = Main.asciiAtlas.createSprite("0915"); Color color = Colors.get("caveFloor-" + +MathUtils.random(1, 3)); floor.setColor(color); map[x][y] = new MapCell(floor, MapCell.Type.FLOOR, "a cave floor"); } else { int neighbours = getGroundNeighbours(x, y); if (neighbours > 0) { Sprite wall = Main.asciiAtlas.createSprite("1113"); wall.setColor(Colors.get("caveWall")); map[x][y] = new MapCell(wall, MapCell.Type.WALL, "a cave wall"); } else { Sprite nothing = Main.asciiAtlas.createSprite("0000"); map[x][y] = new MapCell(nothing, MapCell.Type.NOTHING, "nothing"); } } map[x][y].sprite.setPosition(x * Main.SPRITE_WIDTH, y * Main.SPRITE_HEIGHT); } } if (MathUtils.random() > .75f) { createWater(); createBridge(); } }
Example #7
Source File: CraftScreen.java From xibalba with MIT License | 5 votes |
@Override public void render(float delta) { Gdx.gl.glClearColor( Colors.get("screenBackground").r, Colors.get("screenBackground").g, Colors.get("screenBackground").b, Colors.get("screenBackground").a ); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); stage.act(delta); stage.draw(); }
Example #8
Source File: NameScreen.java From xibalba with MIT License | 5 votes |
@Override public void render(float delta) { Gdx.gl.glClearColor( Colors.get("screenBackground").r, Colors.get("screenBackground").g, Colors.get("screenBackground").b, Colors.get("screenBackground").a ); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); stage.act(delta); stage.draw(); }
Example #9
Source File: GodScreen.java From xibalba with MIT License | 5 votes |
@Override public void render(float delta) { Gdx.gl.glClearColor( Colors.get("screenBackground").r, Colors.get("screenBackground").g, Colors.get("screenBackground").b, Colors.get("screenBackground").a ); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); if (Gdx.input.isKeyJustPressed(Input.Keys.UP)) { if (godSelected > 0) { godSelected -= 1; } updateGodsGroup(); updateAbilitiesGroup(); } if (Gdx.input.isKeyJustPressed(Input.Keys.DOWN)) { if (godSelected < godDataList.size() - 1) { godSelected += 1; } updateGodsGroup(); updateAbilitiesGroup(); } stage.act(delta); stage.draw(); }
Example #10
Source File: DepthScreen.java From xibalba with MIT License | 5 votes |
@Override public void render(float delta) { Gdx.gl.glClearColor( Colors.get("screenBackground").r, Colors.get("screenBackground").g, Colors.get("screenBackground").b, Colors.get("screenBackground").a ); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); stage.act(delta); stage.draw(); }
Example #11
Source File: AbilitiesScreen.java From xibalba with MIT License | 5 votes |
@Override public void render(float delta) { Gdx.gl.glClearColor( Colors.get("screenBackground").r, Colors.get("screenBackground").g, Colors.get("screenBackground").b, Colors.get("screenBackground").a ); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); stage.act(delta); stage.draw(); }
Example #12
Source File: GeneratingWorldScreen.java From xibalba with MIT License | 5 votes |
@Override public void render(float delta) { Gdx.gl.glClearColor( Colors.get("screenBackground").r, Colors.get("screenBackground").g, Colors.get("screenBackground").b, Colors.get("screenBackground").a ); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); stage.act(delta); stage.draw(); }
Example #13
Source File: HelpScreen.java From xibalba with MIT License | 5 votes |
@Override public void render(float delta) { Gdx.gl.glClearColor( Colors.get("screenBackground").r, Colors.get("screenBackground").g, Colors.get("screenBackground").b, Colors.get("screenBackground").a ); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); stage.act(delta); stage.draw(); }
Example #14
Source File: MainMenuScreen.java From xibalba with MIT License | 5 votes |
@Override public void render(float delta) { Gdx.gl.glClearColor( Colors.get("screenBackground").r, Colors.get("screenBackground").g, Colors.get("screenBackground").b, Colors.get("screenBackground").a ); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); stage.act(delta); stage.draw(); }
Example #15
Source File: MapWeather.java From xibalba with MIT License | 5 votes |
/** * Rainfall in the forest. * * <p>Generate 250 rain drops in random positions on the map. * * @param mapIndex The map we're working on */ public MapWeather(int mapIndex) { for (int i = 0; i < 250; i++) { Entity drop = WorldManager.entityFactory.createRainDrop(); WorldManager.world.entities.get(mapIndex).add(drop); } rainDrops = WorldManager.engine.getEntitiesFor(Family.all(RainDropComponent.class).get()); falling = Main.asciiAtlas.createSprite("1502"); falling.setColor(Colors.get("CYAN")); splash = Main.asciiAtlas.createSprite("0700"); splash.setColor(Colors.get("CYAN")); fading = Main.asciiAtlas.createSprite("0900"); }
Example #16
Source File: EntityFactory.java From xibalba with MIT License | 5 votes |
/** * Create rain drop. * * @return The rain drop */ public Entity createRainDrop() { Entity entity = new Entity(); Vector2 position = new Vector2(0, 0); entity.add(new DecorationComponent(false)); entity.add(new RainDropComponent()); entity.add(new PositionComponent(position)); entity.add(new VisualComponent( Main.asciiAtlas.createSprite("1502"), position, Colors.get("CYAN") )); return entity; }
Example #17
Source File: MapHelpers.java From xibalba with MIT License | 5 votes |
/** * Change floor to wet color. * * @param position Cell to make wet */ public void makeFloorWet(Vector2 position) { MapCell cell = getCell(position.x, position.y); if (Objects.equals(cell.description, "bridge")) { return; } cell.covered = MapCell.Covered.WATER; cell.sprite.setColor(Colors.get(WorldManager.world.getCurrentMap().type + "FloorWet")); }
Example #18
Source File: Map.java From xibalba with MIT License | 5 votes |
private void makeCellBridge(MapCell cell, Sprite bridge) { cell.sprite.setRegion( bridge.getRegionX(), bridge.getRegionY(), bridge.getRegionWidth(), bridge.getRegionHeight() ); cell.sprite.setColor(Colors.get("bridge")); cell.type = MapCell.Type.FLOOR; cell.description = "a bridge"; cell.tween.kill(); }
Example #19
Source File: Map.java From xibalba with MIT License | 4 votes |
private void createWater() { hasWater = true; flooded = new MapCell.Type[width][height]; for (MapCell.Type[] row : flooded) { Arrays.fill(row, MapCell.Type.WALL); } int floodStartX; int floodStartY; do { floodStartX = MathUtils.random(0, width - 1); floodStartY = MathUtils.random(0, height - 1); } while (!map[floodStartX][floodStartY].isFloor()); flood(floodStartX, floodStartY); for (int x = 0; x < flooded.length; x++) { for (int y = 0; y < flooded[0].length; y++) { if (flooded[x][y] == MapCell.Type.FLOOR) { Sprite water = Main.asciiAtlas.createSprite("0715"); water.setPosition(x * Main.SPRITE_WIDTH, y * Main.SPRITE_HEIGHT); MapCell.Type waterType; Color lightColor; Color darkColor; if (getGroundNeighbours(x, y) < 8) { waterType = MapCell.Type.SHALLOW_WATER; lightColor = Colors.get( Objects.equals(type, "forest") ? "waterShallowLightBlue" : "waterShallowLightGreen" ); darkColor = Colors.get( Objects.equals(type, "forest") ? "waterShallowDarkBlue" : "waterShallowDarkGreen" ); } else { waterType = MapCell.Type.DEEP_WATER; lightColor = Colors.get( Objects.equals(type, "forest") ? "waterDeepLightBlue" : "waterDeepLightGreen" ); darkColor = Colors.get( Objects.equals(type, "forest") ? "waterDeepDarkBlue" : "waterDeepDarkGreen" ); } water.setColor(lightColor); Tween tween = Tween.to(water, SpriteAccessor.COLOR, .5f).target( darkColor.r, darkColor.g, darkColor.b ).repeatYoyo(Tween.INFINITY, MathUtils.random()); map[x][y] = new MapCell(water, waterType, "water", tween); } } } }
Example #20
Source File: WorldRenderer.java From xibalba with MIT License | 4 votes |
private void renderShadows() { Map map = WorldManager.world.getCurrentMap(); for (int x = 0; x < map.width; x++) { for (int y = 0; y < map.height; y++) { MapCell cell = WorldManager.mapHelpers.getCell(x, y); if (cell.hidden) { continue; } if (god.hasWrath && cell.forgotten) { continue; } Entity enemy = WorldManager.mapHelpers.getEnemyAt(x, y); boolean canHearEnemy = WorldManager.entityHelpers.hasTrait( WorldManager.player, "Perceptive" ) && enemy != null && WorldManager.entityHelpers.canHear(WorldManager.player, enemy); if (canHearEnemy) { continue; } float alpha = playerAttributes.visionMap[x][y]; if (map.light.hasLights() && alpha > 0) { if (alpha + map.light.lightMap[x][y] > 1) { alpha = 0.9f; } else { alpha += map.light.lightMap[x][y]; } } alpha = alpha <= .15f ? .15f : alpha; if (god.hasWrath) { shadow.setColor(Color.BLACK); } else { shadow.setColor(Colors.get(WorldManager.world.getCurrentMap().type + "Background")); } shadow.setAlpha(-alpha); shadow.setPosition(x * Main.SPRITE_WIDTH, y * Main.SPRITE_HEIGHT); shadow.draw(batch); } } }
Example #21
Source File: Main.java From xibalba with MIT License | 4 votes |
/** * Setup & load the main menu. */ public void create() { // Debug shit debug = new Debug(); // Load custom font assets = new AssetManager(); FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal("ui/Aller_Rg.ttf")); FreeTypeFontGenerator.FreeTypeFontParameter parameter = new FreeTypeFontGenerator.FreeTypeFontParameter(); parameter.size = 12; BitmapFont font = generator.generateFont(parameter); generator.dispose(); // Create UI skin skin = new Skin(); skin.add("Aller", font, BitmapFont.class); skin.addRegions(new TextureAtlas(Gdx.files.internal("ui/uiskin.atlas"))); skin.load(Gdx.files.internal("ui/uiskin.json")); skin.getFont("default-font").getData().markupEnabled = true; // Setup text colors Colors.put("LIGHT_GRAY", parseColor("c2c2c2")); Colors.put("DARK_GRAY", parseColor("666666")); Colors.put("CYAN", parseColor("67C8CF")); Colors.put("RED", parseColor("D67474")); Colors.put("YELLOW", parseColor("E0DFB1")); Colors.put("GREEN", parseColor("67CF8B")); // Environment colors Colors.put("forestFloor", parseColor("78AD8A")); Colors.put("forestFloorWet", parseColor("70BBAD")); Colors.put("forestTree-1", parseColor("67CF8B")); Colors.put("forestTree-2", parseColor("77E09B")); Colors.put("forestTree-3", parseColor("4AC775")); Colors.put("caveFloor-1", parseColor("7A7971")); Colors.put("caveFloor-2", parseColor("8C8B82")); Colors.put("caveFloor-3", parseColor("696862")); Colors.put("caveFloorWet", parseColor("71A48E")); Colors.put("caveWall", parseColor("66655C")); Colors.put("waterShallowLightBlue", parseColor("67C8CF")); Colors.put("waterShallowDarkBlue", parseColor("139EA8")); Colors.put("waterDeepLightBlue", parseColor("139EA8")); Colors.put("waterDeepDarkBlue", parseColor("0B7880")); Colors.put("waterShallowLightGreen", parseColor("67CFAB")); Colors.put("waterShallowDarkGreen", parseColor("13A88F")); Colors.put("waterDeepLightGreen", parseColor("13A88F")); Colors.put("waterDeepDarkGreen", parseColor("0B8074")); Colors.put("fire-1", parseColor("ED6161")); Colors.put("fire-2", parseColor("EDBE61")); Colors.put("fire-3", parseColor("ED9661")); // Decoration colors Colors.put("stone", Colors.get("LIGHT_GRAY")); Colors.put("bridge", parseColor("969482")); // Background colors Colors.put("screenBackground", parseColor("293033")); Colors.put("forestBackground", parseColor("29332F")); Colors.put("caveBackground", parseColor("293033")); // Tween manager tweenManager = new TweenManager(); Tween.setCombinedAttributesLimit(4); Tween.registerAccessor(Sprite.class, new SpriteAccessor()); // Cameras handheldCamera = new HandheldCamera(); cameraShake = new CameraShake(); // Start the main menu setScreen(new LoadingScreen(this)); }
Example #22
Source File: MapHelpers.java From xibalba with MIT License | 4 votes |
/** * Make the floor sprite full of vomit. * * @param position Position of map cell */ public void makeFloorVomit(Vector2 position) { MapCell cell = getCell(position.x, position.y); cell.covered = MapCell.Covered.VOMIT; cell.sprite.setColor(Colors.get("YELLOW")); }
Example #23
Source File: MapHelpers.java From xibalba with MIT License | 4 votes |
/** * Make the floor sprite bloody. * * @param position Position of map cell */ public void makeFloorBloody(Vector2 position) { MapCell cell = getCell(position.x, position.y); cell.covered = MapCell.Covered.BLOOD; cell.sprite.setColor(Colors.get("RED")); }
Example #24
Source File: CharacterScreen.java From xibalba with MIT License | 4 votes |
@Override public void render(float delta) { Gdx.gl.glClearColor( Colors.get("screenBackground").r, Colors.get("screenBackground").g, Colors.get("screenBackground").b, Colors.get("screenBackground").a ); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); if (Gdx.input.isKeyJustPressed(Input.Keys.UP)) { dismembering = false; applyingItem = null; switch (sectionSelected) { case INVENTORY: if (itemSelected > 0) { ItemComponent nextItem = ComponentMappers.item.get(inventory.items.get(itemSelected - 1)); if (stackedItems.get(nextItem.name) == null) { itemSelected -= 1; } else { itemSelected -= stackedItems.get(nextItem.name); } updateInventoryGroup(); updateItemDetailsGroup(); } break; default: } } if (Gdx.input.isKeyJustPressed(Input.Keys.DOWN)) { dismembering = false; applyingItem = null; switch (sectionSelected) { case INVENTORY: if (itemSelected < inventory.items.size() - 1) { ItemComponent thisItem = ComponentMappers.item.get(inventory.items.get(itemSelected)); if (stackedItems.get(thisItem.name) == null) { itemSelected += 1; } else { itemSelected += stackedItems.get(thisItem.name); } updateInventoryGroup(); updateItemDetailsGroup(); } break; default: } } stage.act(delta); stage.draw(); }
Example #25
Source File: MapFire.java From xibalba with MIT License | 4 votes |
/** * Update FIRES. * * @param delta Time since last frame * @param flood Keep spreading? */ public void update(float delta, boolean flood) { animCounter += delta; if (floodedCount < MathUtils.random(100, 300)) { if (flood) { flood(lastX + MathUtils.random(0, 2), lastY); flood(lastX - MathUtils.random(0, 2), lastY); flood(lastX, lastY + MathUtils.random(0, 2)); flood(lastX, lastY - MathUtils.random(0, 2)); } } if (animCounter >= .5f) { animCounter = 0; for (int x = 0; x < flooded.length; x++) { for (int y = 0; y < flooded[0].length; y++) { if (flooded[x][y] == MapCell.Type.FLOOR) { MapCell cell = map.getCellMap()[x][y]; cell.description = "fire"; String spriteKey = MathUtils.random() > 0.5 ? "1405" : "1407"; Sprite sprite = Main.asciiAtlas.createSprite(spriteKey); sprite.setColor(Colors.get("fire-" + MathUtils.random(1, 3))); cell.sprite.set(sprite); cell.sprite.setPosition(x * Main.SPRITE_WIDTH, y * Main.SPRITE_HEIGHT); if (!cell.onFire) { ArrayList<Color> fireColors = new ArrayList<>(); fireColors.add(Colors.get("fire-1")); fireColors.add(Colors.get("fire-2")); fireColors.add(Colors.get("fire-3")); Entity fireLight = new Entity(); fireLight.add( new LightComponent(MathUtils.random(1, 3), true, fireColors) ); fireLight.add(new PositionComponent(x, y)); WorldManager.world.addEntity(fireLight); } cell.onFire = true; } } } } }