List of usage examples for com.badlogic.gdx.graphics Color BLACK
Color BLACK
To view the source code for com.badlogic.gdx.graphics Color BLACK.
Click Source Link
From source file:com.codefiddler.libgdx.tetris.WorldRenderer.java
License:Apache License
private void renderBoarder() { shapeRenderer.begin(ShapeType.Rectangle); shapeRenderer.setColor(Color.BLACK); shapeRenderer.rect(0, 0, BLOCK_WIDTH * Constants.BOARD_BLOCK_WIDTH, BLOCK_WIDTH * Constants.BOARD_BLOCK_HEIGHT); shapeRenderer.rect(BLOCK_WIDTH * Constants.BOARD_BLOCK_WIDTH, 0, BLOCK_WIDTH * Constants.BOARD_BLOCK_WIDTH, BLOCK_WIDTH * Constants.BOARD_BLOCK_HEIGHT); shapeRenderer.end();/*from www . jav a2 s . c om*/ }
From source file:com.codefiddler.libgdx.tetris.WorldRenderer.java
License:Apache License
private void render(float x, float y, Color color) { shapeRenderer.begin(ShapeType.FilledRectangle); shapeRenderer.setColor(color);// ww w . jav a 2s .c om float xPos = x * BLOCK_WIDTH; float yPos = y * BLOCK_WIDTH; shapeRenderer.filledRect(xPos, yPos, BLOCK_WIDTH, BLOCK_WIDTH); // System.out.println("x:" + xPos + " y:" + yPos); shapeRenderer.end(); shapeRenderer.begin(ShapeType.Rectangle); shapeRenderer.setColor(Color.BLACK); shapeRenderer.rect(xPos, yPos, BLOCK_WIDTH, BLOCK_WIDTH); shapeRenderer.end(); }
From source file:com.coder5560.game.ui.MyDialog.java
License:Apache License
/** * Adds a label to the content table. The dialog must have been constructed * with a skin to use this method.//from ww w . ja va 2s .c om */ public MyDialog text(String text) { return text(text, new LabelStyle(Assets.instance.fontFactory.getFont(20), Color.BLACK)); }
From source file:com.commons.color.CustomColorPicker.java
License:Apache License
public CustomColorPicker(String styleName, String title, ColorPickerListener listener) { super(title != null ? title : ""); this.listener = listener; this.style = VisUI.getSkin().get(styleName, ColorPickerStyle.class); this.sizes = VisUI.getSizes(); this.bundle = VisUI.getColorPickerBundle(); if (title == null) getTitleLabel().setText(getText(TITLE)); setModal(true);//from w w w.j a va 2 s. c om setMovable(true); addCloseButton(); closeOnEscape(); oldColor = new Color(Color.BLACK); color = new Color(Color.BLACK); tmpColor = new Color(Color.BLACK); createColorWidgets(); createUI(); createListeners(); updatePixmaps(); pack(); centerWindow(); setStyle(VisUI.getSkin().get("box", WindowStyle.class)); getTitleLabel().setAlignment(Align.left); pickerCreated = true; }
From source file:com.cyphercove.doublehelix.MainRenderer.java
License:Apache License
@Override public void create() { if (settingsAdapter != null) settingsAdapter.updateAllSettings(); fader = new FullScreenFader(0, 1.5f); disposables.add(fader);/*from www . jav a 2s .c o m*/ GaussianBlurShaderProvider gaussianBlurShaderProvider = new GaussianBlurShaderProvider(); bloom = new GaussianBlur(8f, false, true, gaussianBlurShaderProvider); bloom.setClearColor(Color.BLACK); bloom.setDepthTestingToScene(false); bloom.setBlending(true, GL20.GL_ONE, GL20.GL_ONE_MINUS_SRC_ALPHA); disposables.add(bloom); rearDOFBlur = new GaussianBlur(8f, true, true, gaussianBlurShaderProvider); rearDOFBlur.setDepthTestingToScene(true); rearDOFBlur.setBlending(false, 0, 0); disposables.add(rearDOFBlur); cam = new DepthOfFieldCamera(0.10f, 3.5f, 1f, 28f); needFinishCreate = true; firstFrameDrawn = false; //Enable point rendering for use when flake particles setting is off. Gdx.gl.glEnable(GL20.GL_VERTEX_PROGRAM_POINT_SIZE); if (Gdx.app.getType() == Application.ApplicationType.Desktop) { Gdx.gl.glEnable(0x8861); // GL_POINT_OES } }
From source file:com.cyphercove.lwptools.core.FullScreenFader.java
License:Apache License
public FullScreenFader(float delay, float fadeTime) { this(delay, fadeTime, new Color(Color.BLACK)); }
From source file:com.eightpuzzle.game.EightPuzzle.java
License:Apache License
@Override public void create() { gameFont = new BitmapFont(); solvedFont = new BitmapFont(); batch = new SpriteBatch(); aspectRatio = (float) Gdx.graphics.getHeight() / (float) Gdx.graphics.getWidth(); OrthographicCamera camera = new OrthographicCamera(GAME_WIDTH * aspectRatio, GAME_HEIGHT * aspectRatio); //camera.position.set(GAME_WIDTH/2, GAME_HEIGHT/2, 0) camera.setToOrtho(false, GAME_WIDTH * aspectRatio, GAME_HEIGHT * aspectRatio); //camera.setToOrtho(false,GAME_WIDTH,GAME_HEIGHT); stage = new Stage(new ExtendViewport(GAME_WIDTH * aspectRatio, GAME_HEIGHT * aspectRatio, camera));//Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), camera)); Gdx.input.setInputProcessor(stage);//from ww w .j a v a2 s . com // A skin can be loaded via JSON or defined programmatically, either is fine. Using a skin is optional but strongly // recommended solely for the convenience of getting a texture, region, etc as a drawable, tinted drawable, etc. skin = new Skin(); // Generate a 1x1 white texture and store it in the skin named "white". Pixmap pixmap = new Pixmap(1, 1, Format.RGBA8888); pixmap.setColor(Color.WHITE); pixmap.fill(); skin.add("white", new Texture(pixmap)); // Store the default libgdx font under the name "default". skin.add("default", new BitmapFont()); // Configure a TextButtonStyle and name it "default". Skin resources are stored by type, so this doesn't overwrite the font. TextButtonStyle textButtonStyle = new TextButtonStyle(); textButtonStyle.up = skin.newDrawable("white", Color.DARK_GRAY); textButtonStyle.down = skin.newDrawable("white", Color.DARK_GRAY); //textButtonStyle.checked = skin.newDrawable("white", Color.BLUE); textButtonStyle.over = skin.newDrawable("white", Color.LIGHT_GRAY); textButtonStyle.font = skin.getFont("default"); skin.add("default", textButtonStyle); Label.LabelStyle labelSty = new Label.LabelStyle(); labelSty.font = skin.getFont("default"); //labelSty.fontColor = Color.GREEN; skin.add("default", labelSty); WindowStyle ws = new Window.WindowStyle(); ws.titleFont = new BitmapFont(); ws.background = skin.newDrawable("white", Color.BLACK); skin.add("default", ws); FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal("fonts/Zig.ttf")); FreeTypeFontParameter parameter = new FreeTypeFontParameter(); parameter.size = 25; gameFont = generator.generateFont(parameter); FreeTypeFontParameter parameter2 = new FreeTypeFontParameter(); parameter2.size = 100; parameter2.color = Color.GREEN; solvedFont = generator.generateFont(parameter2); generator.dispose(); FileHandle blue, n1, n2, n3, n4, n5, n6, n7, n8, solveUp, solveDown; if (Gdx.app.getType() == ApplicationType.Desktop) { blue = Gdx.files.internal("icons64px/blue-square.png"); n1 = Gdx.files.internal("icons64px/Number-1-icon.png"); n2 = Gdx.files.internal("icons64px/Number-2-icon.png"); n3 = Gdx.files.internal("icons64px/Number-3-icon.png"); n4 = Gdx.files.internal("icons64px/Number-4-icon.png"); n5 = Gdx.files.internal("icons64px/Number-5-icon.png"); n6 = Gdx.files.internal("icons64px/Number-6-icon.png"); n7 = Gdx.files.internal("icons64px/Number-7-icon.png"); n8 = Gdx.files.internal("icons64px/Number-8-icon.png"); solveUp = blue; solveDown = blue; } else { blue = Gdx.files.internal("icons256px/blue-circle.png"); n1 = Gdx.files.internal("icons256px/Number-1-icon.png"); n2 = Gdx.files.internal("icons256px/Number-2-icon.png"); n3 = Gdx.files.internal("icons256px/Number-3-icon.png"); n4 = Gdx.files.internal("icons256px/Number-4-icon.png"); n5 = Gdx.files.internal("icons256px/Number-5-icon.png"); n6 = Gdx.files.internal("icons256px/Number-6-icon.png"); n7 = Gdx.files.internal("icons256px/Number-7-icon.png"); n8 = Gdx.files.internal("icons256px/Number-8-icon.png"); solveUp = Gdx.files.internal("icons256px/Box_Green.png"); solveDown = Gdx.files.internal("icons256px/rectangle_green.png"); } Texture bSquare = new Texture(blue); Texture n1T = new Texture(n1); Texture n2T = new Texture(n2); Texture n3T = new Texture(n3); Texture n4T = new Texture(n4); Texture n5T = new Texture(n5); Texture n6T = new Texture(n6); Texture n7T = new Texture(n7); Texture n8T = new Texture(n8); TextureRegion bSquareReg = new TextureRegion(bSquare); TextureRegion n1Reg = new TextureRegion(n1T); TextureRegion n2Reg = new TextureRegion(n2T); TextureRegion n3Reg = new TextureRegion(n3T); TextureRegion n4Reg = new TextureRegion(n4T); TextureRegion n5Reg = new TextureRegion(n5T); TextureRegion n6Reg = new TextureRegion(n6T); TextureRegion n7Reg = new TextureRegion(n7T); TextureRegion n8Reg = new TextureRegion(n8T); TextureRegionDrawable solveDUp = new TextureRegionDrawable(new TextureRegion(new Texture(solveUp))); TextureRegionDrawable solveDDown = new TextureRegionDrawable(new TextureRegion(new Texture(solveDown))); ImageTextButton.ImageTextButtonStyle tbSty = new ImageTextButton.ImageTextButtonStyle(solveDUp, solveDDown, solveDUp, gameFont); skin.add("default", tbSty); ImageButtonStyle bSquareSty = new ImageButtonStyle(); bSquareSty.imageUp = new TextureRegionDrawable(bSquareReg); bSquareSty.imageDown = new TextureRegionDrawable(bSquareReg); ImageButtonStyle n1Sty = new ImageButtonStyle(); n1Sty.imageUp = new TextureRegionDrawable(n1Reg); n1Sty.imageDown = new TextureRegionDrawable(n1Reg); ImageButtonStyle n2Sty = new ImageButtonStyle(); n2Sty.imageUp = new TextureRegionDrawable(n2Reg); n2Sty.imageDown = new TextureRegionDrawable(n2Reg); ImageButtonStyle n3Sty = new ImageButtonStyle(); n3Sty.imageUp = new TextureRegionDrawable(n3Reg); n3Sty.imageDown = new TextureRegionDrawable(n3Reg); ImageButtonStyle n4Sty = new ImageButtonStyle(); n4Sty.imageUp = new TextureRegionDrawable(n4Reg); n4Sty.imageDown = new TextureRegionDrawable(n4Reg); ImageButtonStyle n5Sty = new ImageButtonStyle(); n5Sty.imageUp = new TextureRegionDrawable(n5Reg); n5Sty.imageDown = new TextureRegionDrawable(n5Reg); ImageButtonStyle n6Sty = new ImageButtonStyle(); n6Sty.imageUp = new TextureRegionDrawable(n6Reg); n6Sty.imageDown = new TextureRegionDrawable(n6Reg); ImageButtonStyle n7Sty = new ImageButtonStyle(); n7Sty.imageUp = new TextureRegionDrawable(n7Reg); n7Sty.imageDown = new TextureRegionDrawable(n7Reg); ImageButtonStyle n8Sty = new ImageButtonStyle(); n8Sty.imageUp = new TextureRegionDrawable(n8Reg); n8Sty.imageDown = new TextureRegionDrawable(n8Reg); ImageButton b1 = new ImageButton(n1Sty); b1.addListener(new MyChangeListener(1)); map.put(1, b1); ImageButton holeB = new ImageButton(bSquareSty); map.put(0, holeB); ImageButton ib = new ImageButton(n2Sty); ib.addListener(new MyChangeListener(2)); map.put(2, ib); ImageButton b4 = new ImageButton(n3Sty); b4.addListener(new MyChangeListener(3)); ImageButton b5 = new ImageButton(n4Sty); b5.addListener(new MyChangeListener(4)); ImageButton b6 = new ImageButton(n5Sty); b6.addListener(new MyChangeListener(5)); map.put(3, b4); map.put(4, b5); map.put(5, b6); ImageButton b7 = new ImageButton(n6Sty); b7.addListener(new MyChangeListener(6)); ImageButton b8 = new ImageButton(n7Sty); b8.addListener(new MyChangeListener(7)); ImageButton b9 = new ImageButton(n8Sty); b9.addListener(new MyChangeListener(8)); map.put(6, b7); map.put(7, b8); map.put(8, b9); newGameB = new ImageTextButton("New Game", skin); newGameB.addListener(new NewGameListener()); solveB = new ImageTextButton("Solve", skin); solveB.addListener(new MySolveListener()); newGameBoard(); //table.padTop(50); //table.padBottom(20); VerticalGroup vg = new VerticalGroup(); //vg.padTop(50); vg.setFillParent(true); vg.addActor(newGameB); vg.addActor(table); vg.addActor(solveB); stage.addActor(vg); }
From source file:com.entermoor.blackandwhiteforest.BlackAndWhiteForest.java
License:Creative Commons License
@Override public void create() { try {//from ww w . j a v a 2 s. co m Gdx.graphics.setFullscreenMode(Gdx.graphics.getDisplayMode()); welcome = new ScreenWelcome(); main = new ScreenMain(); settings = new ScreenSettings(); gaming = new ScreenGaming(); skin = new Skin(); while (!assetManager.update()) ; WindowStyle windowStyle = new WindowStyle(new BitmapFont(), Color.BLACK, new TextureRegionDrawable( new TextureRegion((Texture) assetManager.get("textures/dialogBackground.png", Texture.class)))); skin.add("default", windowStyle); LabelStyle labelStyle = new LabelStyle(new BitmapFont(), Color.WHITE); skin.add("default", labelStyle); for (IBAWFPlugin plugin : toInitList) plugin.init(); addProcessor(stage); addProcessor(new InputProcessor() { @Override public boolean touchUp(int screenX, int screenY, int pointer, int button) { return false; } @Override public boolean touchDragged(int screenX, int screenY, int pointer) { return false; } @Override public boolean touchDown(int screenX, int screenY, int pointer, int button) { return false; } @Override public boolean scrolled(int amount) { return false; } @Override public boolean mouseMoved(int screenX, int screenY) { return false; } @Override public boolean keyUp(int keycode) { if (keycode == Keys.ESCAPE) { Gdx.app.exit(); } return false; } @Override public boolean keyTyped(char character) { return false; } @Override public boolean keyDown(int keycode) { return false; } }); } catch (Throwable t) { BAWFCrashHandler.handleCrash(t); } currentBGM = bgm[new Random().nextInt(bgm.length)]; currentBGM.play(); setScreen(welcome); }
From source file:com.evoluzion.MenuInicio.java
License:Open Source License
public void controles() { if (stage == null) { //stage maneja elementos que reciben entradas como botones o eventos //en este caso se us apara los botones stage = new Stage(ancho, alto, true); stage.clear();// w ww .j av a 2s . c om Gdx.input.setInputProcessor(stage); //instansia los elemrntos de un boton //la posocion up y down usando imagenes y el texto que tiene cada uno TextButtonStyle estilo = new TextButtonStyle(); estilo.up = sk_skin.getDrawable("BotonUP"); estilo.down = sk_skin.getDrawable("BotonDown"); estilo.font = fu_fuente; //instancia los botones b_comenzar = new TextButton(tx.comenzar, estilo); b_comenzar.setWidth(200); b_comenzar.setHeight(30); b_comenzar.setX((ancho / 2) - b_comenzar.getWidth() / 2 + orX); b_comenzar.setY(50 + orY); b_Informacion = new TextButton(tx.sobreEvolizion, estilo); b_Informacion.setWidth(120); b_Informacion.setHeight(30); b_Informacion.setX(ancho - b_Informacion.getWidth() - 5); b_Informacion.setY(alto - b_Informacion.getHeight() - 5); b_Idioma = new TextButton(tx.idioma, estilo); b_Idioma.setWidth(120); b_Idioma.setHeight(30); b_Idioma.setX(ancho - b_Informacion.getWidth() - 125); b_Idioma.setY(alto - b_Informacion.getHeight() - 5); b_GuardarEn = new TextButton(tx.directorioTrabajo2, estilo); b_GuardarEn.setWidth(200); b_GuardarEn.setHeight(30); b_GuardarEn.setX((ancho / 2) - b_comenzar.getWidth() / 2 + orX); b_GuardarEn.setY(150 + orY); b_CargarP = new TextButton(tx.cargaPoblacion, estilo); b_CargarP.setWidth(200); b_CargarP.setHeight(30); b_CargarP.setX((ancho / 2) - b_comenzar.getWidth() / 2); b_CargarP.setY(100 + orY); b_salir = new TextButton(tx.salir, estilo); b_salir.setWidth(200); b_salir.setHeight(30); b_salir.setX((ancho / 2) - b_salir.getWidth() / 2 + orX); b_salir.setY(5 + orY); CheckBoxStyle checkBoxStyle = new CheckBoxStyle(); checkBoxStyle.checkboxOff = sk_skin2.getDrawable("boxN0"); checkBoxStyle.checkboxOn = sk_skin2.getDrawable("boxYES"); checkBoxStyle.font = fu_fuente; tfs_text = new TextFieldStyle(); tfs_text.background = sk_skin2.getDrawable("boxN0"); tfs_text.font = fu_fuente; tfs_text.fontColor = Color.BLACK; text = new TextField(tx.nombre, tfs_text); text.setSize(180, 25); text.setCursorPosition(0); text.setPosition(20 + orX, 450 + orY); text2 = new TextField("" + 60, tfs_text); text2.setSize(38, 20); text2.setCursorPosition(0); text2.setPosition(660 + orX, 310 + orY); text3 = new TextField("" + 0, tfs_text); text3.setSize(38, 20); text3.setCursorPosition(0); text3.setPosition(660 + orX, 280 + orY); tf_ATB = new TextField("" + 0, tfs_text); tf_ATB.setSize(38, 20); tf_ATB.setCursorPosition(0); tf_ATB.setPosition(660 + orX, 250 + orY); text4 = new TextField("" + 0, tfs_text); text4.setSize(38, 20); text4.setCursorPosition(0); text4.setPosition(660 + orX, 220 + orY); tf_energia = new TextField("20", tfs_text); tf_energia.setSize(30, 20); tf_energia.setCursorPosition(0); tf_energia.setPosition(420 + orX, 310 + orY); tf_biomasa = new TextField("20", tfs_text); tf_biomasa.setSize(30, 20); tf_biomasa.setCursorPosition(0); tf_biomasa.setPosition(420 + orX, 280 + orY); tf_Numenergia = new TextField("800", tfs_text); tf_Numenergia.setSize(40, 20); tf_Numenergia.setCursorPosition(0); tf_Numenergia.setPosition(420 + orX, 250 + orY); tf_Numbiomasa = new TextField("800", tfs_text); tf_Numbiomasa.setSize(40, 20); tf_Numbiomasa.setCursorPosition(0); tf_Numbiomasa.setPosition(420 + orX, 220 + orY); tf_Cantidad = new TextField("1", tfs_text); tf_Cantidad.setSize(38, 20); tf_Cantidad.setCursorPosition(0); tf_Cantidad.setPosition(660 + orX, 190 + orY); tf_CantidadMax = new TextField("1000", tfs_text); tf_CantidadMax.setSize(38, 20); tf_CantidadMax.setCursorPosition(0); tf_CantidadMax.setPosition(660 + orX, 160 + orY); cb_moverMasa = new CheckBox(tx.moverLaMasa, checkBoxStyle); cb_moverMasa.getCells().get(0).size(20, 20); cb_moverMasa.setChecked(true); cb_moverMasa.setPosition(637 + orX, 105 + orY); tf_Temperatura = new TextField("25", tfs_text); tf_Temperatura.setSize(38, 20); tf_Temperatura.setCursorPosition(0); tf_Temperatura.setPosition(660 + orX, 90 + orY); tf_Start1 = new TextField("0", tfs_text); tf_Start1.setSize(60, 20); tf_Start1.setCursorPosition(0); tf_Start1.setPosition(675 + orX, 10 + orY); tf_TempFinal1 = new TextField("0", tfs_text); tf_TempFinal1.setSize(60, 20); tf_TempFinal1.setCursorPosition(0); tf_TempFinal1.setPosition(780 + orX, 10 + orY); tf_DeltaTiempo1 = new TextField("0", tfs_text); tf_DeltaTiempo1.setSize(60, 20); tf_DeltaTiempo1.setCursorPosition(0); tf_DeltaTiempo1.setPosition(895 + orX, 10 + orY); tf_Start2 = new TextField("0", tfs_text); tf_Start2.setSize(60, 20); tf_Start2.setCursorPosition(0); tf_Start2.setPosition(675 + orX, -20 + orY); tf_TempFinal2 = new TextField("0", tfs_text); tf_TempFinal2.setSize(60, 20); tf_TempFinal2.setCursorPosition(0); tf_TempFinal2.setPosition(780 + orX, -20 + orY); tf_DeltaTiempo2 = new TextField("0", tfs_text); tf_DeltaTiempo2.setSize(60, 20); tf_DeltaTiempo2.setCursorPosition(0); tf_DeltaTiempo2.setPosition(895 + orX, -20 + orY); cb_leerPoblacion = new CheckBox(tx.cargarArchivo, checkBoxStyle); cb_leerPoblacion.getCells().get(0).size(15, 15); cb_leerPoblacion.setChecked(false); cb_leerPoblacion.setPosition(0 + orX, 380 + orY); cb_mutar = new CheckBox(tx.color, checkBoxStyle); cb_mutar.getCells().get(0).size(20, 20); cb_mutar.setChecked(true); cb_mutar.setPosition(20 + orX, 305 + orY); cb_mutarSize = new CheckBox(tx.tamano, checkBoxStyle); cb_mutarSize.getCells().get(0).size(20, 20); cb_mutarSize.setChecked(true); cb_mutarSize.setPosition(20 + orX, 280 + orY); cb_mutarSpeed = new CheckBox(tx.velocidad, checkBoxStyle); cb_mutarSpeed.getCells().get(0).size(20, 20); cb_mutarSpeed.setChecked(true); cb_mutarSpeed.setPosition(20 + orX, 255 + orY); cb_mutarSentir = new CheckBox(tx.sentidos, checkBoxStyle); cb_mutarSentir.getCells().get(0).size(20, 20); cb_mutarSentir.setChecked(true); cb_mutarSentir.setPosition(20 + orX, 230 + orY); cb_mutarCazar = new CheckBox(tx.buscarComida, checkBoxStyle); cb_mutarCazar.getCells().get(0).size(20, 20); cb_mutarCazar.setChecked(true); cb_mutarCazar.setPosition(200 + orX, 305 + orY); cb_mutarEscapar = new CheckBox(tx.escapar, checkBoxStyle); cb_mutarEscapar.getCells().get(0).size(20, 20); cb_mutarEscapar.setChecked(true); cb_mutarEscapar.setPosition(200 + orX, 280 + orY); cb_mutarRadioCon = new CheckBox(tx.alcanceVisual, checkBoxStyle); cb_mutarRadioCon.getCells().get(0).size(20, 20); cb_mutarRadioCon.setChecked(true); cb_mutarRadioCon.setPosition(200 + orX, 255 + orY); cb_mutarPredador = new CheckBox(tx.genPredador, checkBoxStyle); cb_mutarPredador.getCells().get(0).size(20, 20); cb_mutarPredador.setChecked(true); cb_mutarPredador.setPosition(200 + orX, 230 + orY); cb_mutarTasaMut = new CheckBox("Fidelidad ADNpol", checkBoxStyle); cb_mutarTasaMut.getCells().get(0).size(20, 20); cb_mutarTasaMut.setChecked(true); cb_mutarTasaMut.setPosition(20 + orX, 205 + orY); cb_mutarLongevidad = new CheckBox(tx.longevidad, checkBoxStyle); cb_mutarLongevidad.getCells().get(0).size(20, 20); cb_mutarLongevidad.setChecked(true); cb_mutarLongevidad.setPosition(200 + orX, 205 + orY); cb_mutartolerancia = new CheckBox(tx.temOptima, checkBoxStyle); cb_mutartolerancia.getCells().get(0).size(20, 20); cb_mutartolerancia.setChecked(true); cb_mutartolerancia.setPosition(20 + orX, 180 + orY); cb_mutarResistencia = new CheckBox(tx.ResATB, checkBoxStyle); cb_mutarResistencia.getCells().get(0).size(20, 20); cb_mutarResistencia.setChecked(true); cb_mutarResistencia.setPosition(200 + orX, 180 + orY); cb_colectarColor = new CheckBox(tx.color, checkBoxStyle); cb_colectarColor.getCells().get(0).size(20, 20); cb_colectarColor.setChecked(true); cb_colectarColor.setPosition(20 + orX, 125 + orY); cb_colectarSize = new CheckBox(tx.tamano, checkBoxStyle); cb_colectarSize.getCells().get(0).size(20, 20); cb_colectarSize.setChecked(true); cb_colectarSize.setPosition(20 + orX, 100 + orY); cb_colectarSpeed = new CheckBox(tx.velocidad, checkBoxStyle); cb_colectarSpeed.getCells().get(0).size(20, 20); cb_colectarSpeed.setChecked(false); cb_colectarSpeed.setPosition(20 + orX, 75 + orY); cb_colectarSentir = new CheckBox(tx.sentidos, checkBoxStyle); cb_colectarSentir.getCells().get(0).size(20, 20); cb_colectarSentir.setChecked(false); cb_colectarSentir.setPosition(20 + orX, 50 + orY); cb_colectarCazar = new CheckBox(tx.buscarComida, checkBoxStyle); cb_colectarCazar.getCells().get(0).size(20, 20); cb_colectarCazar.setChecked(false); cb_colectarCazar.setPosition(200 + orX, 125 + orY); cb_colectarEscapar = new CheckBox(tx.escapar, checkBoxStyle); cb_colectarEscapar.getCells().get(0).size(20, 20); cb_colectarEscapar.setChecked(false); cb_colectarEscapar.setPosition(200 + orX, 100 + orY); cb_colectarRadioCon = new CheckBox(tx.alcanceVisual, checkBoxStyle); cb_colectarRadioCon.getCells().get(0).size(20, 20); cb_colectarRadioCon.setChecked(false); cb_colectarRadioCon.setPosition(200 + orX, 75 + orY); cb_colectarPredador = new CheckBox(tx.genPredador, checkBoxStyle); cb_colectarPredador.getCells().get(0).size(20, 20); cb_colectarPredador.setChecked(false); cb_colectarPredador.setPosition(200 + orX, 50 + orY); cb_colectarTasaMut = new CheckBox(tx.fidelidadADNpol, checkBoxStyle); cb_colectarTasaMut.getCells().get(0).size(20, 20); cb_colectarTasaMut.setChecked(false); cb_colectarTasaMut.setPosition(20 + orX, 25 + orY); cb_colectarLongevidad = new CheckBox(tx.longevidad, checkBoxStyle); cb_colectarLongevidad.getCells().get(0).size(20, 20); cb_colectarLongevidad.setChecked(false); cb_colectarLongevidad.setPosition(200 + orX, 25 + orY); cb_colectarTolerancia = new CheckBox(tx.temOptima, checkBoxStyle); cb_colectarTolerancia.getCells().get(0).size(20, 20); cb_colectarTolerancia.setChecked(false); cb_colectarTolerancia.setPosition(20 + orX, 0 + orY); cb_colectarResistencia = new CheckBox(tx.ResATB, checkBoxStyle); cb_colectarResistencia.getCells().get(0).size(20, 20); cb_colectarResistencia.setChecked(false); cb_colectarResistencia.setPosition(200 + orX, 0 + orY); tf_MultiploPol = new TextField("1.0", tfs_text); tf_MultiploPol.setSize(40, 20); tf_MultiploPol.setCursorPosition(0); tf_MultiploPol.setPosition(20 + orX, -30 + orY); tf_HorizontalTransfer = new TextField("500000", tfs_text); tf_HorizontalTransfer.setSize(80, 20); tf_HorizontalTransfer.setCursorPosition(0); tf_HorizontalTransfer.setPosition(35 + orX, -60 + orY); //se agregan los listener para los botones stage.addActor(b_Informacion); stage.addActor(b_Idioma); stage.addActor(b_salir); stage.addActor(b_GuardarEn); stage.addActor(b_comenzar); stage.addActor(b_CargarP); stage.addActor(cb_mutar); stage.addActor(cb_mutarSize); stage.addActor(cb_mutarSpeed); stage.addActor(cb_mutarSentir); stage.addActor(cb_mutarPredador); stage.addActor(cb_mutarCazar); stage.addActor(cb_mutarEscapar); stage.addActor(cb_mutarRadioCon); stage.addActor(cb_mutarPredador); stage.addActor(cb_mutarLongevidad); stage.addActor(cb_mutarTasaMut); stage.addActor(cb_mutartolerancia); stage.addActor(cb_mutarResistencia); stage.addActor(cb_colectarColor); stage.addActor(cb_colectarSize); stage.addActor(cb_colectarSpeed); stage.addActor(cb_colectarSentir); stage.addActor(cb_colectarCazar); stage.addActor(cb_colectarEscapar); stage.addActor(cb_colectarRadioCon); stage.addActor(cb_colectarPredador); stage.addActor(cb_colectarTasaMut); stage.addActor(cb_colectarLongevidad); stage.addActor(cb_colectarTolerancia); stage.addActor(cb_colectarResistencia); stage.addActor(cb_leerPoblacion); stage.addActor(cb_moverMasa); stage.addActor(text); stage.addActor(text2); stage.addActor(text3); stage.addActor(text4); stage.addActor(tf_ATB); stage.addActor(tf_energia); stage.addActor(tf_biomasa); stage.addActor(tf_Numenergia); stage.addActor(tf_Numbiomasa); stage.addActor(tf_Cantidad); stage.addActor(tf_CantidadMax); stage.addActor(tf_Temperatura); stage.addActor(tf_Start1); stage.addActor(tf_Start2); stage.addActor(tf_TempFinal1); stage.addActor(tf_TempFinal2); stage.addActor(tf_DeltaTiempo1); stage.addActor(tf_DeltaTiempo2); stage.addActor(tf_MultiploPol); stage.addActor(tf_HorizontalTransfer); b_Informacion.addListener(new InputListener() { public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { // JFrame jf = new JFrame(); // jf.setVisible(true); // jf.setLocation(500, 500); // jf.setAlwaysOnTop(true); JOptionPane.showMessageDialog(null, tx.mensajeSobre); //jf.dispose(); return true; } public void touchUp(InputEvent event, float x, float y, int pointer, int button) { } }); b_Idioma.addListener(new InputListener() { public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { ingles = ingles * (-1); if (ingles == 1) { tx.setIngles(); } if (ingles == -1) { tx.setEspanol(); } JOptionPane.showMessageDialog(null, tx.losCambiosReiniciar); escribirIdioma(); return true; } public void touchUp(InputEvent event, float x, float y, int pointer, int button) { } }); b_GuardarEn.addListener(new InputListener() { public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { //Agrega Filtro para ver tipos de archivo JFileChooser fc = new JFileChooser(); fc.setCurrentDirectory(new File("./")); fc.setDialogTitle(tx.agregarDespues); fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); int returnVal = fc.showSaveDialog(null); if (returnVal == JFileChooser.APPROVE_OPTION) { ruta = fc.getCurrentDirectory().getAbsolutePath() + "/"; } escribirRuta(); return true; } public void touchUp(InputEvent event, float x, float y, int pointer, int button) { } }); b_CargarP.addListener(new InputListener() { public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { //Agrega Filtro para ver tipos de archivo JFileChooser fc = new JFileChooser(); fc.setCurrentDirectory(new File("ruta")); FileNameExtensionFilter filter = new FileNameExtensionFilter(tx.poblacion + " (pob)", "pob"); fc.setFileFilter(filter); fc.setDialogTitle(tx.directorio); fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); int returnVal = fc.showOpenDialog(null); if (returnVal == JFileChooser.APPROVE_OPTION) { poblacion = fc.getSelectedFile().getAbsolutePath(); cb_leerPoblacion.setChecked(true); } return true; } public void touchUp(InputEvent event, float x, float y, int pointer, int button) { } }); b_salir.addListener(new InputListener() { public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { return true; } public void touchUp(InputEvent event, float x, float y, int pointer, int button) { // JFrame jf = new JFrame(); // jf.setVisible(true); // jf.setLocation(500, 500); // jf.setAlwaysOnTop(true); Object[] options = { tx.si, tx.no }; int n = JOptionPane.showOptionDialog(null, tx.deseaSalir, "", JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE, null, options, options[1]); if (n == JOptionPane.YES_OPTION) { System.exit(0); } //jf.dispose(); } }); b_comenzar.addListener(new InputListener() { private int tiempoCatastrofe; int tiempoATB; private int tiempoMaximo; private int numOrgMax; private float Temperatura; private int Start1; private int Start2; private float TempFinal1; private float TempFinal2; private int DeltaTiempo1; private int DeltaTiempo2; private float eficiencia; private int horizontalTransferRate; public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { guardarMenuInicio(); try { Senergia = Integer.parseInt(tf_energia.getText()); Qbiomasa = Integer.parseInt(tf_biomasa.getText()); numSen = Integer.parseInt(tf_Numenergia.getText()); numQen = Integer.parseInt(tf_Numbiomasa.getText()); tiempoMuestreo = Integer.parseInt(text2.getText()); tiempoCatastrofe = Integer.parseInt(text3.getText()); tiempoATB = Integer.parseInt(tf_ATB.getText()); tiempoMaximo = Integer.parseInt(text4.getText()); numOrg = Integer.parseInt(tf_Cantidad.getText()); numOrgMax = Integer.parseInt(tf_CantidadMax.getText()); Temperatura = Float.parseFloat(tf_Temperatura.getText()); Start1 = Integer.parseInt(tf_Start1.getText()); Start2 = Integer.parseInt(tf_Start2.getText()); TempFinal1 = Float.parseFloat(tf_TempFinal1.getText()); TempFinal2 = Float.parseFloat(tf_TempFinal2.getText()); DeltaTiempo1 = Integer.parseInt(tf_DeltaTiempo1.getText()); DeltaTiempo2 = Integer.parseInt(tf_DeltaTiempo2.getText()); eficiencia = Float.parseFloat(tf_MultiploPol.getText()); horizontalTransferRate = Integer.parseInt(tf_HorizontalTransfer.getText()); } catch (NumberFormatException e) { Senergia = 20; Qbiomasa = 20; numSen = 800; numQen = 800; tiempoMuestreo = 60; tiempoCatastrofe = 0; tiempoATB = 0; tiempoMaximo = 0; numOrg = 1; numOrgMax = 1000; Temperatura = 0; Start1 = 0; Start2 = 0; TempFinal1 = 0; TempFinal2 = 0; DeltaTiempo1 = 0; DeltaTiempo2 = 0; eficiencia = 1; horizontalTransferRate = 5000000; e.printStackTrace(); } m = new Mundo(ev, ruta, text.getText(), poblacion, numOrg, numSen, numQen, Senergia, Qbiomasa, cb_leerPoblacion.isChecked(), cb_moverMasa.isChecked(), genesPedidos().toString(), ingles); m.tiempoMuestreo = tiempoMuestreo; m.tiempoCatastrofe = tiempoCatastrofe; m.tiempoATB = tiempoATB; m.tiempoMaximo = tiempoMaximo; m.maximo = numOrgMax; m.temperatura = Temperatura; m.minStar1 = Start1; m.minStar2 = Start2; m.deltaTime1 = DeltaTiempo1; m.deltaTime2 = DeltaTiempo2; m.TempFinal1 = TempFinal1; m.TempFinal2 = TempFinal2; m.eficiencia = eficiencia; m.horizontalTransferRate = horizontalTransferRate; if (DeltaTiempo1 != 0) { m.tempXSecond1 = (TempFinal1 - Temperatura) / (DeltaTiempo1 * 60); } if (DeltaTiempo2 != 0) { m.tempXSecond2 = (TempFinal2 - TempFinal1) / (DeltaTiempo2 * 60); } m.colectarancho = cb_colectarSize.isChecked(); m.colectaralto = cb_colectarSize.isChecked(); m.colectSpeed = cb_colectarSpeed.isChecked(); m.colectColor = cb_colectarColor.isChecked(); m.colectSentir = cb_colectarSentir.isChecked(); m.colectCazar = cb_colectarCazar.isChecked(); m.colectEscapar = cb_colectarEscapar.isChecked(); m.colectPredador = cb_colectarPredador.isChecked(); m.colectarLongevidad = cb_colectarLongevidad.isChecked(); m.colectarTasaMut = cb_colectarTasaMut.isChecked(); m.colectarTemp = cb_colectarTolerancia.isChecked(); m.colectarResistencia = cb_colectarResistencia.isChecked(); m.mutarColor = cb_mutar.isChecked(); m.mutarSize = cb_mutarSize.isChecked(); m.mutarSpeed = cb_mutarSpeed.isChecked(); m.mutarSentir = cb_mutarSentir.isChecked(); m.mutarPredador = cb_mutarPredador.isChecked(); m.mutarCazar = cb_mutarCazar.isChecked(); m.mutarEscapar = cb_mutarEscapar.isChecked(); m.mutarRadioconsiente = cb_mutarRadioCon.isChecked(); m.mutarLongevidad = cb_mutarLongevidad.isChecked(); m.mutarTasaMut = cb_mutarTasaMut.isChecked(); m.mutarTemp = cb_mutartolerancia.isChecked(); m.mutarResistencia = cb_mutarResistencia.isChecked(); if (cb_leerPoblacion.isChecked() == false) { m.agregarPrimerosOrg(numOrg); } if (cb_leerPoblacion.isChecked() == true) { m.leerArchivoPoblacion(); } m.setDelta(); m.setDelta2(); m.setDelta3(); m.setTiempo(); m.segundos = 0; m.segundos2 = 0; m.segundos3 = 0; m.segundos4 = 0; m.segundos5 = 0; m.colectorEspesiesTotales(); m.f_genes.creararchivo(ruta + m.nombre + tx.genomasTXT); m.f_genes.escribirArchivo(tx.cuandoEstenPresentes + genesPedidos().toString() + "\n"); m.f_datos.creararchivo(ruta + m.nombre + tx.datosXls); m.f_datos.escribirArchivo(tx.datosOrdenados); m.f_proteoma.creararchivo(ruta + m.nombre + tx.proteomaTXT); m.f_proteoma.escribirArchivo(tx.cuandoEstenPresntesProt + genesPedidos().toString() + "\n"); m.f_mutantes.creararchivo(ruta + m.nombre + tx.mutantesXLS); StringBuffer linea = new StringBuffer(tx.tiempo + "," + tx.nombre + "," + tx.cantidad + ""); if (cb_colectarSize.isChecked()) { linea.append(", " + tx.alto); } if (cb_colectarSize.isChecked()) { linea.append(", " + tx.ancho); } if (cb_colectarSpeed.isChecked()) { linea.append(", " + tx.velocidad); } if (cb_colectarColor.isChecked()) { linea.append(", " + tx.color); } if (cb_colectarTasaMut.isChecked()) { linea.append(", " + tx.fidelidadADNpol); } if (cb_colectarTolerancia.isChecked()) { linea.append(", " + tx.temOptima); } if (cb_colectarLongevidad.isChecked()) { linea.append(", " + tx.longevidad); } if (cb_colectarRadioCon.isChecked()) { linea.append(", " + tx.alcanceVisual); } if (cb_colectarPredador.isChecked()) { linea.append(", " + tx.genPredador); } if (cb_colectarSentir.isChecked()) { linea.append(", " + tx.sentidos); } if (cb_colectarCazar.isChecked()) { linea.append(", " + tx.buscarComida); } if (cb_colectarEscapar.isChecked()) { linea.append(", " + tx.escapar); } if (cb_colectarResistencia.isChecked()) { linea.append(", " + tx.resistensiaATB); } linea.append("\n"); m.f_mutantes.escribirArchivo(linea.toString()); m.f_arbol.creararchivo(ruta + m.nombre + tx.arbolTXT); // System.out.println(m.segundos); m.colectorEspesies(); m.guardarDatos(); m.archivarGenoma(); m.archivarFenotipo(); m.archivarProteoma(); ev.setScreen(new Pantalla(ev, m)); dispose(); return true; } public void touchUp(InputEvent event, float x, float y, int pointer, int button) { } }); } //leerMenuIncio(); }
From source file:com.evoluzion.Pantalla.java
License:Open Source License
@Override public void render(float delta) { //Game loop/*from w w w . j a v a 2s.co m*/ Gdx.gl.glClearColor(0, 0, 0, 1); Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT); camara.update(); stage.act(delta); if (verBotones1 == 1) { b_colectar.setVisible(false); b_colectarP.setVisible(false); b_colectarPM.setVisible(false); b_colectarPnM.setVisible(false); verBotones1 = verBotones1 * 2; } if (verBotones1 == -1) { b_colectar.setVisible(true); b_colectarP.setVisible(true); b_colectarPM.setVisible(true); b_colectarPnM.setVisible(true); verBotones1 = verBotones1 * 2; } if (m.pausaGame == 1) { //1=play -1=pausa m.update();//actualiza los datos que maneja el Mundo // System.out.println("rendering"); } batch.setProjectionMatrix(camara.combined); //comienzo a graficar // //dibuja Senergia if (cb_verEnergia.isChecked() == true) { cantidad = m.ase.size; for (cont = cantidad - 1; cont >= 0; cont--) { se = m.ase.get(cont); se.verObjeto(batch); } } //dibujamos Qenergia if (cb_verMasa.isChecked() == true) { cantidad2 = m.aqe.size; for (cont2 = cantidad2 - 1; cont2 >= 0; cont2--) { qe = m.aqe.get(cont2); qe.verObjeto(batch); } } // for(Qenergia qe :m.aqe){qe.verObjeto(batch);} //dibujamos los organismos if (cb_verOrganismos.isChecked() == true) { cantidad3 = m.aorg.size; for (cont3 = cantidad3 - 1; cont3 >= 0; cont3--) { or = m.aorg.get(cont3); or.verOrganismo(batch); } // verl los organismos marcados cantidad3 = m.aorg.size; for (cont3 = cantidad3 - 1; cont3 >= 0; cont3--) { or = m.aorg.get(cont3); or.verMarcado(borde, batch, fuente); } } //dibujar rectangulos en modo debug if (debugin == true) { for (Organismo or : m.aorg) { or.verBorde(borde); } //for(Senergia se: m.ase){ se.verBorde(borde);} for (Qenergia qe : m.aqe) { qe.verBorde(borde); } } caja.begin(ShapeType.FilledRectangle); caja.setColor(Color.BLACK); caja.filledRect(0, m.alto - 30, m.ancho, 30); caja.end(); batch.begin(); fuente.draw(batch, "d: " + m.dias + " |h: " + m.horas + " |m: " + m.minutos + " |s: " + m.segundos, 400, m.alto - 30); batch.end(); if (verPanel == 1) { caja.begin(ShapeType.FilledRectangle); caja.setColor(Color.BLUE); caja.filledRect(0, m.alto - 400, 170, 400); caja.end(); batch.begin(); fuente.setColor(Color.WHITE); fuente.draw(batch, tx.Organismos + m.aorg.size, 5, m.alto - 30); fuente.draw(batch, tx.mutantes + m.aEspesies.size, 5, m.alto - 50); int masatotal = (int) (m.BiomasaTotal() + m.MateriaLibre()); fuente.draw(batch, tx.masaTotal + masatotal, 5, m.alto - 70); fuente.draw(batch, tx.masa + m.MateriaLibre(), 5, m.alto - 90); fuente.draw(batch, tx.biomasa + m.BiomasaTotal(), 5, m.alto - 110); fuente.draw(batch, tx.velocidadMedia + format.format(m.velocidadMedia()), 5, m.alto - 130); fuente.draw(batch, tx.tamanoMedi + format.format(m.tamanoMedio()), 5, m.alto - 150); fuente.draw(batch, tx.tasaMutacionMedia + m.tasaMutMedio(), 5, m.alto - 170); fuente.draw(batch, tx.vidaMdia + format.format(m.longevidadMedio()) + " (s)", 5, m.alto - 190); fuente.draw(batch, tx.resistensiaATB + m.cantidadResistentes(), 5, m.alto - 210); fuente.draw(batch, tx.temperatura + format.format(m.temperatura), 5, m.alto - 230); fuente.draw(batch, tx.temOptimaMedia + format.format(m.temOptimaMedia()), 5, m.alto - 250); if (m.antibiotico == 1) { fuente.draw(batch, tx.antibioticoON, 5, m.alto - 370); } else { fuente.draw(batch, tx.antibioticoOFF, 5, m.alto - 370); } ; batch.end(); cb_verEnergia.setVisible(true); cb_verMasa.setVisible(true); cb_verOrganismos.setVisible(true); } if (verPanel == -1) { cb_verEnergia.setVisible(false); cb_verMasa.setVisible(false); cb_verOrganismos.setVisible(false); } //botones batch.begin(); stage.draw(); batch.end(); if (Gdx.input.justTouched()) { Vector3 touchPos = new Vector3(); touchPos.set(Gdx.input.getX(), Gdx.input.getY(), 0); camara.unproject(touchPos); // System.out.println(touchPos.x + " "+ touchPos.y); cantidad3 = m.aorg.size; for (cont3 = cantidad3 - 1; cont3 >= 0; cont3--) { or = m.aorg.get(cont3); if (touchPos.x > or.posicion.x && touchPos.x < or.posicion.x + or.ancho && touchPos.y > or.posicion.y && touchPos.y < or.posicion.y + or.alto) { or.marcado = or.marcado * (-1); } } } if (Gdx.input.isButtonPressed(Input.Buttons.LEFT)) { Vector3 touchPos = new Vector3(); touchPos.set(Gdx.input.getX(), Gdx.input.getY(), 0); camara.unproject(touchPos); cantidad3 = m.aorg.size; for (cont3 = cantidad3 - 1; cont3 >= 0; cont3--) { or = m.aorg.get(cont3); if (or.marcado == -1 && touchPos.x > or.posicion.x - or.ancho && touchPos.x < or.posicion.x + or.ancho * 2 && touchPos.y > or.posicion.y - or.alto && touchPos.y < or.posicion.y + or.alto * 2) { or.posicion.x = touchPos.x - or.ancho / 2; or.posicion.y = touchPos.y - or.alto / 2; or.update(); } } } }