aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/net/sowgro/npehero/gameplay/Block.java
blob: 9d68ab6389860e3d5f9a3d0d429aeba5c0df0d41 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//glowing block of color c (jfx node)

package net.sowgro.npehero.gameplay;

import javafx.scene.effect.BlurType;
import javafx.scene.effect.DropShadow;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import net.sowgro.npehero.levelapi.Note;

/**
 * A block is a visual representation of a note on the screen. This is used both in the editor and in during the game play.
 */
public class Block extends Rectangle
{
    public Color color;
    public Note note;

    public Block(Color color, double width, double height, int cornerRadius, boolean useDropShadow, Note note)
    {
        this.note = note;
        this.color = color;
       
        super.setFill(color);
        super.setWidth(width);
        super.setHeight(height);
        super.setArcHeight(cornerRadius);
        super.setArcWidth(cornerRadius);

        if (useDropShadow) {
            enableDropShadow();
        }
    }

    public Block(Color color, double width, double height, int cornerRadius) {
        this(color, width, height, cornerRadius, true, null);
    }

    public void enableDropShadow() {
        DropShadow dropShadow = new DropShadow();
        dropShadow.setRadius(200.0);
        dropShadow.setColor(color);
        dropShadow.setBlurType(BlurType.GAUSSIAN);
        super.setEffect(dropShadow);
    }
}