List of usage examples for com.badlogic.gdx.graphics Color RED
Color RED
To view the source code for com.badlogic.gdx.graphics Color RED.
Click Source Link
From source file:com.mrlamont.Model.TitleScreen.java
public void render(float delta) { camera = new OrthographicCamera(); viewport = new FitViewport(V_WIDTH, V_HEIGHT, camera); batch = new SpriteBatch(); // clear the screen with black Gdx.gl20.glClearColor(0, 0, 0, 1);/*from www . j a va 2 s .com*/ Gdx.gl20.glClear(GL20.GL_COLOR_BUFFER_BIT); g = new ShapeRenderer(); batch = new SpriteBatch(); g.begin(ShapeRenderer.ShapeType.Filled); g.setColor(Color.PURPLE); g.rect(550, 0, 110, 600); g.setColor(Color.BLUE); g.rect(440, 0, 110, 600); g.setColor(Color.GREEN); g.rect(330, 0, 110, 600); g.setColor(Color.YELLOW); g.rect(220, 0, 110, 600); g.setColor(Color.ORANGE); g.rect(110, 0, 110, 600); g.setColor(Color.RED); g.rect(0, 0, 110, 600); g.end(); //draw different coloured Wheelys on screen batch.begin(); batch.draw(AssetManager.wheelyYellow, 190, -1); batch.draw(AssetManager.wheelyOrange, 90, -1); batch.draw(AssetManager.wheelyRed, -14, -1); batch.draw(AssetManager.wheelyGreenL, 320, -1); batch.draw(AssetManager.wheelyBlueL, 420, -1); batch.draw(AssetManager.wheelyPurpleL, 520, -1); batch.end(); //If a certain colour is left clicked, that colouro of Wheely is selected if (Gdx.input.isButtonPressed(Input.Buttons.LEFT)) { Vector3 mouseClick = new Vector3(Gdx.input.getX(), Gdx.input.getY(), 0); camera.unproject(mouseClick); System.out.println("x: " + mouseClick.x + " y: " + mouseClick.y); //Red if (mouseClick.y >= -1 && mouseClick.y <= 0.991 && mouseClick.x >= -1 && mouseClick.x <= -0.6625) { red = true; } //Green if (mouseClick.y >= -1 && mouseClick.y <= 1 && mouseClick.x >= 0.034374952 && mouseClick.x <= 0.36874998) { green = true; } //Orange if (mouseClick.y >= -1 && mouseClick.y <= 1 && mouseClick.x >= -0.653125 && mouseClick.x <= -0.32187498) { orange = true; } //Yellow if (mouseClick.y >= -1 && mouseClick.y <= 1 && mouseClick.x >= -0.309375 && mouseClick.x <= 0.024999976) { yellow = true; } //Blue if (mouseClick.y >= -1 && mouseClick.y <= 1 && mouseClick.x >= 0.37812495 && mouseClick.x <= 0.7125) { blue = true; } //Purple if (mouseClick.y >= -1 && mouseClick.y <= 1 && mouseClick.x >= 0.71875 && mouseClick.x <= 0.99375) { purple = true; } } }
From source file:com.mygdx.game.CarDrawer.java
@Override public void draw(ShapeRenderer sr, Vehicle vehicle) { sr.setColor(Color.RED); float x = vehicle.getXOnScreen(); float y = vehicle.getYOnScreen(); int widthRect, heightRect; if (!vehicle.isTurned()) { if (vehicle.getStartMotionDirection() == Constants.leftToRight || vehicle.getStartMotionDirection() == Constants.rightToLeft) { widthRect = vehicle.getWidth(); heightRect = vehicle.getHeight(); } else {/* w ww . ja v a 2s . c o m*/ widthRect = vehicle.getHeight(); heightRect = vehicle.getWidth(); } } else { if (vehicle.getFinishMotionDirection() == Constants.leftToRight || vehicle.getFinishMotionDirection() == Constants.rightToLeft) { widthRect = vehicle.getWidth(); heightRect = vehicle.getHeight(); } else { widthRect = vehicle.getHeight(); heightRect = vehicle.getWidth(); } } sr.rect(x, y, widthRect, heightRect); // // sr.setColor(Color.YELLOW); // sr.rect(x, y, 10, 10); }
From source file:com.mygdx.game.debugdrawers.ArmatureDebugDrawer.java
License:Apache License
public void drawArmature(MyShapeRenderer shapeRenderer, GameCharacter character, String rootNodeId) { this.shapeRenderer = shapeRenderer; if (character == null) { return;/*w w w . j a va 2 s. c o m*/ } if (shapeRenderer.isDrawing()) { shapeRenderer.end(); } shapeRenderer.begin(MyShapeRenderer.ShapeType.Line); shapeRenderer.setColor(Color.YELLOW); Node skeleton = character.modelInstance.getNode(rootNodeId); if (skeleton != null) { Vector3 modelPos = TMP_V1; Vector3 rootNodeGlobalPos = TMP_V2; Vector3 debugNodePos = TMP_V3; Quaternion modelRot = TMP_Q; character.modelInstance.transform.getTranslation(modelPos); character.modelInstance.transform.getRotation(modelRot); skeleton.globalTransform.getTranslation(rootNodeGlobalPos); drawArmatureNodes(skeleton, modelPos, modelRot, rootNodeGlobalPos, debugNodePos); } if (character instanceof HumanCharacter) { HumanCharacter human = (HumanCharacter) character; human.getBoneMidpointWorldPosition(HumanCharacter.HumanArmature.RIGHT_HAND.id, TMP_V1); drawVertex(TMP_V1, 0.05f, Color.RED); human.getBoneMidpointWorldPosition(HumanCharacter.HumanArmature.LEFT_HAND.id, TMP_V1); drawVertex(TMP_V1, 0.05f, Color.GREEN); } if (character instanceof DogCharacter) { DogCharacter dog = (DogCharacter) character; dog.getBoneMidpointWorldPosition(DogCharacter.DogArmature.HEAD.id, TMP_V1); drawVertex(TMP_V1, 0.05f, Color.RED); dog.getBoneDirection(DogCharacter.DogArmature.HEAD.id, TMP_V2); drawVertex(TMP_V1.add(TMP_V2.scl(0.5f)), 0.05f, Color.GREEN); } shapeRenderer.end(); }
From source file:com.mygdx.game.debugdrawers.NavMeshDebugDrawer.java
License:Apache License
private void drawPathTriangles(NavMeshGraphPath navMeshGraphPath, Triangle currentTriangle) { shapeRenderer.set(MyShapeRenderer.ShapeType.Filled); if (navMeshGraphPath != null && navMeshGraphPath.getCount() > 0) { for (int i = 0; i < navMeshGraphPath.getCount(); i++) { Edge e = (Edge) navMeshGraphPath.get(i); if (triangleIsVisible(e.fromNode)) { if (currentTriangle.getIndex() == e.fromNode.getIndex()) { drawTriangle(e.fromNode, Color.RED, 0.2f); } else { drawTriangle(e.fromNode, Color.YELLOW, 0.2f); }//from ww w . j ava2 s .c o m } if (i == navMeshGraphPath.getCount() - 1) { if (triangleIsVisible(e.toNode)) { if (currentTriangle.getIndex() == e.toNode.getIndex()) { drawTriangle(e.toNode, Color.RED, 0.2f); } else { drawTriangle(e.toNode, Color.YELLOW, 0.2f); } } } } // Shared triangle edges shapeRenderer.set(MyShapeRenderer.ShapeType.Line); for (Connection<Triangle> connection : navMeshGraphPath) { Edge e = (Edge) connection; if (triangleIsVisible(e.fromNode) || triangleIsVisible(e.toNode)) { shapeRenderer.line(e.rightVertex, e.leftVertex, Color.GREEN, Color.RED); } } } else if (currentTriangle != null) { drawTriangle(currentTriangle, Color.RED, 0.2f); } }
From source file:com.mygdx.game.gameword.touchme.TouchMeRenderer.java
private void dessinerSegments() { shapeRenderer.setProjectionMatrix(batch.getProjectionMatrix()); shapeRenderer.begin(ShapeRenderer.ShapeType.Filled); shapeRenderer.setColor(Color.RED); for (int i = 0; i < gameWorld.getCheckPoints().size() - 1; i++) { CheckPoint cp = gameWorld.getCheckPoints().get(i); CheckPoint cpNext = gameWorld.getCheckPoints().get(i + 1); shapeRenderer.line(cp.getPosition().x + cp.getLargeur() / 2, cp.getPosition().y + cp.getHauteur() / 2, cpNext.getPosition().x + cpNext.getLargeur() / 2, cpNext.getPosition().y + cpNext.getHauteur() / 2); }/*from w w w. j a v a 2 s .c om*/ shapeRenderer.end(); }
From source file:com.mygdx.game.steerers.FollowPathSteerer.java
License:Apache License
@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; }// w ww. j av a 2 s. co m 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; }
From source file:com.mygdx.game.TrafficLightDrawer.java
public void draw() { sr.setColor(Color.BLACK);/* w ww . j a v a 2 s. com*/ float x = trafficLight.getXOnScreen(), y = trafficLight.getYOnScreen(); float width = trafficLight.getWidth() + 8, height = trafficLight.getHeight() + 12; sr.rect(x, y, width, height); if (trafficLight.isYellow()) sr.setColor(Color.YELLOW); else sr.setColor(Color.DARK_GRAY); sr.circle(x + width / 2, y + height / 2, trafficLight.getRadius()); if (trafficLight.isGreen()) sr.setColor(Color.GREEN); else sr.setColor(Color.DARK_GRAY); sr.circle(x + width / 2, y + width / 2 - 1, trafficLight.getRadius()); if (trafficLight.isRed()) sr.setColor(Color.RED); else sr.setColor(Color.DARK_GRAY); sr.circle(x + width / 2, y + 2 * width + 3, trafficLight.getRadius()); }
From source file:com.mygdx.game.world.World.java
public void renderBounds(ShapeRenderer renderer) { //For rendering the collision surfaces. renderer.setColor(Color.RED); for (GameObject obj : object) { renderer.rect(obj.x + obj.x_anchor, obj.y + obj.y_anchor, obj.bounds.width, obj.bounds.height); }/*from w w w. j a va 2 s. c om*/ renderer.rect(player.getPositionX(), player.getPositionY(), 32, 32); renderer.setColor(Color.WHITE); }
From source file:com.mygdx.gui.UpgradeButton.java
@Override public void draw(Batch batch, float parentAlpha) { sprite.setColor(MYGDXGAME.game.moneys >= price ? Color.WHITE : Color.GRAY); if (sprite != null) { sprite.setSize(width, height);/*www. j a v a 2s . c o m*/ sprite.setCenterX(x); sprite.setCenterY(y); sprite.setAlpha(parentAlpha); sprite.draw(batch, parentAlpha); if (mess != null) { MYGDXGAME.game.draw(batch, mess, x - 40, y + getHeight() / 2 - 20, Color.BLACK, Game.fontSizes.STANDART); } } if (desc != null) MYGDXGAME.game.draw(batch, desc, x - getWidth() / 2 + 30, y + getHeight() / 2 - 60, Color.BLACK, Game.fontSizes.STANDART); MYGDXGAME.game.draw(batch, "$" + price, x - getWidth() / 2 + 30, y + getHeight() / 2 - 100, Color.RED, Game.fontSizes.STANDART); }
From source file:com.mygdx.jogo.Humano.java
/**Mtodo utilizado para atualizar os estados do tabuleiro conforme as casas que o jogador escolher, * @param selecionada a casa selecionada pelo jogador. * @param estagio utilizado no mtodo de mover invocado por este mtodo para remover a pea capturada. * @return se a saida for verdadeira o turno do jogador finalizado ,caso for falsa ele continua atualizando. *//*from ww w . j a v a 2 s.c om*/ @Override public boolean update(Casa selecionada, Stage estagio) { if (getSelAreaPeca() != null && getSelAreaPeca().peca != null && getSelAreaPeca().peca.imagem.getActions().size > 0) { } else { if (getSelAreaPeca() != null && getCaminhoEscolhido() != null) { return moverPeca(estagio); } else if (selecionada != null) { if (selecionada.peca != null && selecionada != anterior) {// fazer algo para isso executar uma unica vez if (getPecas().contains(selecionada.peca)) { if (getSelAreaPeca() != null && getSelAreaPeca().peca != null) { getSelAreaPeca().peca.imagem.setColor(getSelAreaPeca().peca.getColorOriginal()); ocultarVizinhos(); } setSelAreaPeca(selecionada); setVizinhosSelAreaPeca(Jogo.getInstance().getTabuleiro().caminhosDisponiveis(selecionada, getQtdJogadas() > 0)); if (getVizinhosSelAreaPeca().size() == 0 && getQtdJogadas() > 0) { return true; } getSelAreaPeca().peca.imagem.setColor(Color.RED); anterior = getSelAreaPeca(); exibirVizinhos(); System.out.println("caminhos: " + getVizinhosSelAreaPeca().size()); } } else if (getVizinhosSelAreaPeca() != null) { casaValida(selecionada); } } } return false; }