Skip to content
Snippets Groups Projects
Commit e70bd79b authored by jiaxi liu's avatar jiaxi liu
Browse files

1. Complete the start screen.

2. Complete the CSV reading.
3. Complete the player display.
parent 3898fcad
No related branches found
No related tags found
No related merge requests found
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;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment