Java Code Examples for com.badlogic.gdx.graphics.Color#RED

The following examples show how to use com.badlogic.gdx.graphics.Color#RED . 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: GDXDrawingAdapter.java    From INFDEV02-4 with MIT License 5 votes vote down vote up
private Color convertColor(CustomColor color) {
    switch(color) {
        case WHITE:
            return Color.WHITE;
            
        case BLACK:
            return Color.BLACK;
            
        case BLUE:
            return Color.BLUE;
            
        default:
            return Color.RED;
    }
}
 
Example 2
Source File: GDXDrawingAdapter.java    From INFDEV02-4 with MIT License 5 votes vote down vote up
private Color convertColor(CustomColor color) {
    switch (color) {
        case WHITE:
            return Color.WHITE;

        case BLACK:
            return Color.BLACK;

        case BLUE:
            return Color.BLUE;

        default:
            return Color.RED;
    }
}
 
Example 3
Source File: GDXDrawingAdapter.java    From INFDEV02-4 with MIT License 5 votes vote down vote up
private Color convertColor(CustomColor color) {
    switch (color) {
        case WHITE:
            return Color.WHITE;

        case BLACK:
            return Color.BLACK;

        case BLUE:
            return Color.BLUE;

        default:
            return Color.RED;
    }
}
 
Example 4
Source File: GDXDrawingAdapter.java    From INFDEV02-4 with MIT License 5 votes vote down vote up
private Color convertColor(CustomColor color) {
    switch(color) {
        case WHITE:
            return Color.WHITE;
            
        case BLACK:
            return Color.BLACK;
            
        case BLUE:
            return Color.BLUE;
            
        default:
            return Color.RED;
    }
}
 
Example 5
Source File: Map.java    From riiablo with Apache License 2.0 5 votes vote down vote up
public static Color getColor(int mainIndex) {
  switch (mainIndex) {
    case 8:  return Color.RED;
    case 9:  return Color.ORANGE;
    case 10: return Color.YELLOW;
    case 12: return Color.GREEN;
    case 13: return Color.BLUE;
    case 16: return Color.TEAL;
    case 20: return Color.VIOLET;
    default: return Color.WHITE;
  }
}
 
Example 6
Source File: Unlucky.java    From Unlucky with MIT License 4 votes vote down vote up
public void create() {
       batch = new SpriteBatch();
       rm = new ResourceManager();
       player = new Player("player", rm);

       save = new Save(player, "save.json");
       save.load(rm);

       // debugging
       fps = new Label("", new Label.LabelStyle(rm.pixel10, Color.RED));
       fps.setFontScale(0.5f);
       fps.setVisible(player.settings.showFps);

       inventoryUI = new InventoryUI(this, player, rm);
       menuScreen = new MenuScreen(this, rm);
       gameScreen = new GameScreen(this, rm);
       worldSelectScreen = new WorldSelectScreen(this, rm);
       levelSelectScreen = new LevelSelectScreen(this, rm);
       inventoryScreen = new InventoryScreen(this, rm);
       shopScreen = new ShopScreen(this, rm);
       smoveScreen = new SpecialMoveScreen(this, rm);
       statisticsScreen = new StatisticsScreen(this, rm);
       victoryScreen = new VictoryScreen(this, rm);
       settingsScreen = new SettingsScreen(this, rm);

       // create parallax background
       menuBackground = new Background[3];

       // ordered by depth
       // sky
       menuBackground[0] = new Background(rm.titleScreenBackground[0],
           (OrthographicCamera) menuScreen.getStage().getCamera(), new Vector2(0, 0));
       menuBackground[0].setVector(0, 0);
       // back clouds
       menuBackground[1] = new Background(rm.titleScreenBackground[2],
           (OrthographicCamera) menuScreen.getStage().getCamera(), new Vector2(0.3f, 0));
       menuBackground[1].setVector(20, 0);
       // front clouds
       menuBackground[2] = new Background(rm.titleScreenBackground[1],
           (OrthographicCamera) menuScreen.getStage().getCamera(), new Vector2(0.3f, 0));
       menuBackground[2].setVector(60, 0);

       // profiler
       GLProfiler.enable();

       this.setScreen(menuScreen);
}
 
Example 7
Source File: Hud.java    From Unlucky with MIT License 4 votes vote down vote up
/**
 * Creates the death screen message
 */
private void createDeathPrompt() {
    deathGroup = new Group();
    deathGroup.setTransform(false);
    deathGroup.setVisible(false);
    deathGroup.setSize(Unlucky.V_WIDTH, Unlucky.V_HEIGHT);
    deathGroup.setTouchable(Touchable.enabled);

    dark = new Image(rm.shade);
    deathGroup.addActor(dark);

    frame = new Image(rm.skin, "textfield");
    frame.setSize(100, 60);
    frame.setPosition(Unlucky.V_WIDTH / 2 - 50, Unlucky.V_HEIGHT / 2 - 30);
    deathGroup.addActor(frame);

    youDied = new Label("YOU DIED!", new Label.LabelStyle(rm.pixel10, Color.RED));
    youDied.setSize(100, 10);
    youDied.setPosition(50, 75);
    youDied.setAlignment(Align.center);
    youDied.setTouchable(Touchable.disabled);
    deathGroup.addActor(youDied);

    loss = new Label("", new Label.LabelStyle(rm.pixel10, Color.WHITE));
    loss.setFontScale(0.5f);
    loss.setWrap(true);
    loss.setSize(100, 40);
    loss.setAlignment(Align.top);
    loss.setPosition(Unlucky.V_WIDTH / 2 - 50, Unlucky.V_HEIGHT / 2 - 30);
    loss.setTouchable(Touchable.disabled);
    deathGroup.addActor(loss);

    // click to continue
    deathGroup.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            if (!game.player.settings.muteSfx) rm.buttonclick0.play(game.player.settings.sfxVolume);
            backToMenu();
        }
    });

    stage.addActor(deathGroup);
}
 
Example 8
Source File: ServerConnectGUI.java    From Radix with MIT License 4 votes vote down vote up
@Override
public void init() {
    stage = new Stage();

    // TODO memory manage

    background = new Texture(Gdx.files.internal("textures/block/obsidian.png"));
    background.setWrap(TextureWrap.Repeat, TextureWrap.Repeat);

    errorLabel = new Label(null, new LabelStyle(new BitmapFont(), Color.RED));

    TextFieldStyle fieldStyle = new TextFieldStyle();
    fieldStyle.font = new BitmapFont();
    fieldStyle.fontColor = Color.WHITE;
    TextField ipField = new TextField("IP:Port", fieldStyle);

    ImageTextButtonStyle btnStyle = RadixClient.getInstance().getSceneTheme().getButtonStyle();

    TextButton connectButton = new TextButton("Connect", btnStyle);
    connectButton.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            String[] ipPort = ipField.getText().split(":");

            if(ipPort.length != 2) {
                invalidIpSyntax();
                return;
            }

            try {
                RadixClient.getInstance().enterRemoteWorld(ipPort[0], Short.parseShort(ipPort[1]));
            } catch (NumberFormatException ex) {
                invalidPort();
            }
        }
    });

    Table table = new Table();
    table.setFillParent(true);
    table.add(ipField);
    table.row();
    table.add(errorLabel);
    table.row();
    table.add(connectButton);
    stage.addActor(table);
}
 
Example 9
Source File: FollowPathSteerer.java    From GdxDemo3D with Apache License 2.0 4 votes vote down vote up
@Override
public boolean processSteering(SteeringAcceleration<Vector3> steering) {

	// Check if steering target path segment changed.
	LinePathParam pathParam = followPathSB.getPathParam();
	int traversedSegment = pathParam.getSegmentIndex();
	if (traversedSegment > currentSegmentIndex) {
		currentSegmentIndex = traversedSegment;
	}

	if (prioritySteering.getSelectedBehaviorIndex() == 0) {
		/*
		 * Collision avoidance management
		 */
		float pr = proximity.getRadius() * 1.5f;
		if (linePath.getEndPoint().dst2(steerableBody.getPosition()) <= pr * pr) {
			// Disable collision avoidance near the end of the path since the obstacle
			// will likely prevent the entity from reaching the target.
			collisionAvoidanceSB.setEnabled(false);
			deadlockDetectionStartTime = Float.POSITIVE_INFINITY;
		} else if (deadlockDetection) {
			// Accumulate collision time during deadlock detection
			collisionDuration += GdxAI.getTimepiece().getDeltaTime();

			if (GdxAI.getTimepiece().getTime() - deadlockDetectionStartTime > DEADLOCK_TIME && collisionDuration > DEADLOCK_TIME * .6f) {
				// Disable collision avoidance since most of the deadlock detection period has been spent on collision avoidance
				collisionAvoidanceSB.setEnabled(false);
			}
		} else {
			// Start deadlock detection
			deadlockDetectionStartTime = GdxAI.getTimepiece().getTime();
			collisionDuration = 0;
			deadlockDetection = true;
		}
		return true;
	}

	/*
	 * Path following management
	 */
	float dst2FromPathEnd = steerableBody.getPosition().dst2(linePath.getEndPoint());

	// Check to see if the entity has reached the end of the path
	if (steering.isZero() && dst2FromPathEnd < followPathSB.getArrivalTolerance() * followPathSB.getArrivalTolerance()) {
		return false;
	}

	// Check if collision avoidance must be re-enabled
	if (deadlockDetection && !collisionAvoidanceSB.isEnabled() && GdxAI.getTimepiece().getTime() - deadlockDetectionStartTime > MAX_NO_COLLISION_TIME) {
			collisionAvoidanceSB.setEnabled(true);
			deadlockDetection = false;
	}
	
	// If linear speed is very low and the entity is colliding something at his feet, like a step of the stairs
	// for instance, we have to increase the acceleration to make him go upstairs. 
	float minVel = .2f;
	if (steerableBody.getLinearVelocity().len2() > minVel * minVel) {
		stationarityRayColor = null;
	} else {
		steerableBody.getGroundPosition(stationarityRayLow.origin).add(0, 0.05f, 0);
		steerableBody.getDirection(stationarityRayLow.direction).scl(1f, 0f, 1f).nor();
		stationarityRayLength = steerableBody.getBoundingRadius() + 0.4f;
		Entity hitEntityLow = GameScreen.screen.engine.rayTest(stationarityRayLow, null, GameEngine.ALL_FLAG, GameEngine.PC_FLAG, stationarityRayLength, null);
		if (hitEntityLow instanceof GameObject) {
			stationarityRayColor = Color.RED;
			stationarityRayHigh.set(stationarityRayLow);
			stationarityRayHigh.origin.add(0, .8f, 0);
			Entity hitEntityHigh = GameScreen.screen.engine.rayTest(stationarityRayHigh, null, GameEngine.ALL_FLAG, GameEngine.PC_FLAG, stationarityRayLength, null);
			if (hitEntityHigh == null) {
				// The entity is touching a small obstacle with his feet like a step of the stairs.
				// Increase the acceleration to make him go upstairs.
				steering.linear.scl(8);
			}
			else if (hitEntityHigh instanceof GameObject) {
				// The entity is touching a higher obstacle like a tree, a column or something.
				// Here we should invent something to circumvent this kind of obstacles :)
				//steering.linear.rotateRad(Constants.V3_UP, Constants.PI0_25);
			}
		} else {
			stationarityRayColor = Color.BLUE;
		}
	}

	return true;
}
 
Example 10
Source File: RetroSceneScreen.java    From bladecoder-adventure-engine with Apache License 2.0 4 votes vote down vote up
private void drawDebugText(SpriteBatch batch) {
	World w = ui.getWorld();

	w.getSceneCamera().getInputUnProject(worldViewport, unprojectTmp);

	Color color;

	sbTmp.setLength(0);

	if (EngineLogger.lastError != null) {
		sbTmp.append(EngineLogger.lastError);

		color = Color.RED;
	} else {

		sbTmp.append("( ");
		sbTmp.append((int) unprojectTmp.x);
		sbTmp.append(", ");
		sbTmp.append((int) unprojectTmp.y);
		sbTmp.append(") FPS:");
		sbTmp.append(Gdx.graphics.getFramesPerSecond());
		// sbTmp.append(" Density:");
		// sbTmp.append(Gdx.graphics.getDensity());
		// sbTmp.append(" UI Multiplier:");
		// sbTmp.append(DPIUtils.getSizeMultiplier());

		if (w.getCurrentScene().getPlayer() != null) {
			sbTmp.append(" Depth Scl: ");
			sbTmp.append(w.getCurrentScene().getFakeDepthScale(unprojectTmp.y));
		}

		color = Color.WHITE;
	}

	String strDebug = sbTmp.toString();

	textLayout.setText(ui.getSkin().getFont("debug"), strDebug, color, worldViewport.getScreenWidth(), Align.left,
			true);

	RectangleRenderer.draw(batch, 0, worldViewport.getScreenHeight() - textLayout.height - 10, textLayout.width,
			textLayout.height + 10, Color.BLACK);
	ui.getSkin().getFont("debug").draw(batch, textLayout, 0, worldViewport.getScreenHeight() - 5);

	// Draw actor states when debug
	if (EngineLogger.getDebugLevel() == EngineLogger.DEBUG1) {

		for (BaseActor a : w.getCurrentScene().getActors().values()) {
			Rectangle r = a.getBBox().getBoundingRectangle();
			sbTmp.setLength(0);
			sbTmp.append(a.getId());
			if (a instanceof InteractiveActor && ((InteractiveActor) a).getState() != null)
				sbTmp.append(".").append(((InteractiveActor) a).getState());

			unprojectTmp.set(r.getX(), r.getY(), 0);
			w.getSceneCamera().scene2screen(worldViewport, unprojectTmp);

			if (w.getInventory().isVisible()) {
				// unprojectTmp.y += verbUI.getHeight();
			}

			ui.getSkin().getFont("debug").draw(batch, sbTmp.toString(), unprojectTmp.x, unprojectTmp.y);
		}

	}
}
 
Example 11
Source File: DefaultSceneScreen.java    From bladecoder-adventure-engine with Apache License 2.0 4 votes vote down vote up
private void drawDebugText(SpriteBatch batch) {
	World w = getWorld();

	w.getSceneCamera().getInputUnProject(viewport, unprojectTmp);

	Color color;

	sbTmp.setLength(0);

	if (EngineLogger.lastError != null) {
		// sbTmp.append(EngineLogger.lastError);
		sbTmp.append(EngineLogger.errorBuffer);

		color = Color.RED;
	} else {

		// sbTmp.append(" Density:");
		// sbTmp.append(Gdx.graphics.getDensity());
		// sbTmp.append(" UI Multiplier:");
		// sbTmp.append(DPIUtils.getSizeMultiplier());
		sbTmp.append(" ");

		long millis = w.getTimeOfGame();
		long second = (millis / 1000) % 60;
		long minute = (millis / (1000 * 60)) % 60;
		long hour = (millis / (1000 * 60 * 60));

		String time = String.format("%02d:%02d:%02d", hour, minute, second);

		sbTmp.append(time);

		if (EngineLogger.getDebugLevel() == EngineLogger.DEBUG1) {
			if (w.inCutMode()) {
				sbTmp.append(" CUT_MODE ");
			} else if (w.hasDialogOptions()) {
				sbTmp.append(" DIALOG_MODE ");
			} else if (w.isPaused()) {
				sbTmp.append(" PAUSED ");
			}

			sbTmp.append(" ( ");
			sbTmp.append((int) unprojectTmp.x);
			sbTmp.append(", ");
			sbTmp.append((int) unprojectTmp.y);
			sbTmp.append(") FPS:");
			sbTmp.append(Gdx.graphics.getFramesPerSecond());

			if (w.getCurrentScene().getState() != null) {
				sbTmp.append(" Scn State: ");
				sbTmp.append(w.getCurrentScene().getState());
			}

			if (w.getCurrentScene().getPlayer() != null) {
				sbTmp.append(" Depth Scl: ");
				sbTmp.append(w.getCurrentScene().getFakeDepthScale(unprojectTmp.y));
			}
		}

		color = Color.WHITE;
	}

	String strDebug = sbTmp.toString();

	textLayout.setText(ui.getSkin().getFont("debug"), strDebug, color, viewport.getScreenWidth(), Align.left, true);
	RectangleRenderer.draw(batch, 0, viewport.getScreenHeight() - textLayout.height - 10, textLayout.width,
			textLayout.height + 10, Color.BLACK);
	ui.getSkin().getFont("debug").draw(batch, textLayout, 0, viewport.getScreenHeight() - 5);

	// Draw actor states when debug
	if (EngineLogger.getDebugLevel() == EngineLogger.DEBUG1) {

		for (BaseActor a : w.getCurrentScene().getActors().values()) {

			if (a instanceof AnchorActor)
				continue;

			Rectangle r = a.getBBox().getBoundingRectangle();
			sbTmp.setLength(0);
			sbTmp.append(a.getId());
			if (a instanceof InteractiveActor && ((InteractiveActor) a).getState() != null)
				sbTmp.append(".").append(((InteractiveActor) a).getState());

			unprojectTmp.set(r.getX(), r.getY(), 0);
			w.getSceneCamera().scene2screen(viewport, unprojectTmp);
			ui.getSkin().getFont("debug").draw(batch, sbTmp.toString(), unprojectTmp.x, unprojectTmp.y);
		}

	}
}
 
Example 12
Source File: InputPanel.java    From bladecoder-adventure-engine with Apache License 2.0 4 votes vote down vote up
public void setError(boolean value) {
	if (value)
		title.getStyle().fontColor = Color.RED;
	else
		title.getStyle().fontColor = Color.WHITE;
}