Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /** Starts the health bar **/
- /** Shields is equal to Current health - Maximum Health **/
- /** Shields is equal to Current Health - 100 (The total of the health bar) **/
- player.shields = player.health - player.maxHealth;
- /** Makes sure shields don't go below 0 **/
- if(player.shields < 0)
- {
- player.shields = 0;
- }
- /** Makes sure the player's health doesn't go negative **/
- if(player.health <= 0)
- {
- player.visibleHealth = 0;
- player.health = 0;
- }
- /** Makes sure that the health shown doesn't exceed 100 when showing shields **/
- if(player.health >100)
- {
- player.visibleHealth = 100;
- }
- else if(player.health <= 100)
- {
- player.visibleHealth = player.health;
- }
- if(player.health >100)
- {
- /** The text for when shields appear **/
- /** Used as an outside object to allow for barrier.length(); **/
- String barrier = "Cacophony Barrier: " + player.shields;
- ** Checks to see if shields are at least 1 **/
- if(player.shields >= 1)/
- {
- d.DrawStringWithShadow(g, "" + player.visibleHealth, screenSize.width / 2 - 7, screenSize.height / 2 - 55, 0, 0, 0, 0, 0, 200);
- g.setColor(new Color(255, 45, 178));
- g.fillRect(screenSize.width / 2 - 47, screenSize.height /2 - 46, (int) player.shields, 7);
- g.setColor(new Color(0, 209, 255));
- g.fillRect(screenSize.width / 2 - 47, screenSize.height /2 - 46, (int) player.health, 7);
- g.setFont(d.arial);
- d.DrawStringWithFullDrop(g, barrier, screenSize.width / 2 - (barrier.length() *3), screenSize.height / 2 - 69, 0, 0, 0, 255, 255, 255);
- }
- else if(player.shields > 100) /** If shields are more than 100 **/
- {
- d.DrawStringWithShadow(g, "" + player.visibleHealth, screenSize.width / 2 - 7, screenSize.height / 2 - 55, 0, 0, 0, 0, 0, 200);
- g.setColor(new Color(255, 45, 178));
- g.fillRect(screenSize.width / 2 - 47, screenSize.height /2 - 46, (int) player.health - (int)player.maxHealth, 7);
- g.setColor(new Color(0, 209, 255));
- g.fillRect(screenSize.width / 2 - 47, screenSize.height /2 - 46, (int) player.health, 7);
- g.setFont(d.arial);
- d.DrawStringWithFullDrop(g, barrier, screenSize.width / 2 - (barrier.length() *3), screenSize.height / 2 - 69, 0, 0, 0, 255, 255, 255);
- }
- }
- else if(player.health >=75) /** Checks if the player's health is between 75 and 100 **/
- {
- d.DrawStringWithShadow(g, "" + player.visibleHealth, screenSize.width / 2 - 7, screenSize.height / 2 - 55, 0, 0, 0, 0, 0, 200);
- g.setColor(new Color(0, 209, 255));
- g.fillRect(screenSize.width / 2 - 47, screenSize.height /2 - 46, (int) player.health, 7);
- }
- else if(player.health >= 50) /** Check to see if health is between 50 and 74 **/
- {
- d.DrawStringWithShadow(g, "" + player.visibleHealth, screenSize.width / 2 - 7, screenSize.height / 2 - 55, 0, 0, 0, 0, 255, 0);
- g.setColor(new Color(0, 255, 0));
- g.fillRect(screenSize.width / 2 - 47, screenSize.height /2 - 46, (int) player.health, 7);
- }
- else if(player.health >= 25) /** Checks to see if health is between 25 and 49 **/
- {
- d.DrawStringWithShadow(g, "" + player.visibleHealth, screenSize.width / 2 - 7, screenSize.height / 2 - 55, 0, 0, 0, 255, 178, 0);
- g.setColor(new Color(255, 178, 0));
- g.fillRect(screenSize.width / 2 - 47, screenSize.height /2 - 46, (int) player.health, 7);
- }
- else if(player.health >= 1)/** Checks to see if health is between 1 and 24 **/
- {
- d.DrawStringWithShadow(g, "" + player.visibleHealth, screenSize.width / 2 - 7, screenSize.height / 2 - 55, 0, 0, 0, 255, 0, 0);
- g.setColor(new Color(255, 0, 0));
- g.fillRect(screenSize.width / 2 - 47, screenSize.height /2 - 46, (int) player.health, 7);
- }
Advertisement
Add Comment
Please, Sign In to add comment