diff --git a/src/Player.java b/src/Player.java new file mode 100644 index 0000000000000000000000000000000000000000..a5a30a986d0e25c3ed06fd3efd2ad76f159fd858 --- /dev/null +++ b/src/Player.java @@ -0,0 +1,52 @@ +import bagel.DrawOptions; +import bagel.Font; +import bagel.Image; + +public class Player { + public int X = 0; + public int Y = 0; + + private final static Image FaceLeftImage = new Image("res/faeLeft.png"); + private final static Image FaceRightImage = new Image("res/faeRight.png"); + + private static int Life = 100; + private static Image Img; + private final Font LifeFont = new Font("res/frostbite.ttf", 30); + private final DrawOptions LifeHighColor = new DrawOptions(); + private final DrawOptions LifeMidColor = new DrawOptions(); + private final DrawOptions LifeLowColor = new DrawOptions(); + + public Player() { + /*Init player image*/ + Img = FaceRightImage; + + /*Init life color*/ + LifeHighColor.setBlendColour(0, 0.8, 0.2); + LifeMidColor.setBlendColour(0.9, 0.6, 0); + LifeLowColor.setBlendColour(1, 0, 0); + } + + public void Update() { + /*Show play image*/ + Img.drawFromTopLeft(X, Y); + + /*Show life text*/ + if (Life >= 65) { + LifeFont.drawString(Life + "%", 20, 25, LifeHighColor); + } else if (Life >= 35) { + LifeFont.drawString(Life + "%", 20, 25, LifeMidColor); + } else { + LifeFont.drawString(Life + "%", 20, 25, LifeLowColor); + } + } + + public void ToLeft() { + /*Changing user orientation to left*/ + Img = FaceLeftImage; + } + + public void ToRight() { + /*Changing user orientation to right*/ + Img = FaceRightImage; + } +}