/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package Sprites;

import javafx.scene.*;
import javafx.scene.paint.*;
import javafx.scene.shape.*;

/**
 *
 * @author Ruslan
 */
public class HealthBar extends Group {
    
    private double health;
    private Rectangle greenBar, redBar;
    
    public HealthBar(double health) {
        
        super();
        this.health = health;
        this.initRectangles();
        
    }
    
    private void initRectangles() {
        
        this.greenBar = new Rectangle();       
        this.greenBar.setFill(Color.GREEN);
        
        this.redBar = new Rectangle();
        this.redBar.setFill(Color.RED);
        
        // Done in this very specific order for a reason -
        // creates a static red bar. Green bar is overlayed.
        // As green shrinks, red grows withou need for gross math. yay!
        this.getChildren().add(redBar);
        this.getChildren().add(greenBar);
        
    }
    
    // return true if dead
    public boolean decrementHealth(double amount) {
        
        this.health -= amount;
        
        
        if (this.health == 0) {
            
            return true;
            
        }
        
        else {
            
            return false;
            
        }
        
    }
    
    
    
}

@@ -1236,19 +1236,14 @@
     
-%0A        if
+return
  (th
@@ -1261,157 +1261,18 @@
 = 0)
- %7B%0A            %0A            return true;%0A            %0A        %7D%0A        %0A        else %7B%0A            %0A            return false;%0A            %0A        %7D
+;%0A        
 %0A   

fixes a return boolean rookie mistake