Java tutorial
/* * Inmisericordia * Copyright (C) 2014 Ruben Rosado <rrosadoalba@gmail.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package eu.rubenrosado.inmisericordia; import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.glutils.ShapeRenderer; import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType; import eu.rubenrosado.inmisericordia.screens.PlayGame; /** * This class draws the status bar on screen using ShapeRenderer * * @author Ruben Rosado * */ public class StatusBar { private final int SIZEBAR = 205; /** * Draw the status bar * * @param renderer * ShapeRenderer from PlayGame */ public void draw(ShapeRenderer renderer) { renderer.begin(ShapeType.Filled); renderer.setColor(Color.BLACK); renderer.rect(PlayGame.width - SIZEBAR - 5, 25, SIZEBAR, 9); renderer.rect(PlayGame.width - SIZEBAR - 5, 15, SIZEBAR, 9); renderer.rect(PlayGame.width - SIZEBAR - 5, 5, SIZEBAR, 9); renderer.setColor(Color.RED); renderer.rect(PlayGame.width - SIZEBAR - 3, 27, PlayGame.hero.getLifePercentage() * SIZEBAR / 102, 5); renderer.setColor(Color.BLUE); renderer.rect(PlayGame.width - SIZEBAR - 3, 17, PlayGame.hero.getManaPercentage() * SIZEBAR / 102, 5); renderer.setColor(Color.ORANGE); renderer.rect(PlayGame.width - SIZEBAR - 3, 7, PlayGame.hero.getExpPercentage() * SIZEBAR / 102, 5); renderer.end(); } }