-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFaithBar.java
More file actions
62 lines (57 loc) · 1.28 KB
/
FaithBar.java
File metadata and controls
62 lines (57 loc) · 1.28 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import greenfoot.*;
/**
* Write a description of class FaithBar here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class FaithBar extends Actor
{
GreenfootImage bar;
public FaithBar(Character player)
{
super();
setFaithImage(player);
bar = new GreenfootImage(getFaithPath(player));
bar.scale(150, 40);
setImage(bar);
}
/**
* Adjust the faithbar image for the player.
*/
public void setFaithImage(Character player)
{
bar = new GreenfootImage(getFaithPath(player));
bar.scale(150, 40);
setImage(bar);
}
/**
* Get path for new faith bar image.
*/
public String getFaithPath(Character player)
{
int faith = player.getFaithPercent();
int barNum = -1;
int temp;
String newPath = "";
temp = faith % 4;
if (temp == 0)
{
barNum = faith;
}
else if (temp == 1)
{
barNum = faith + 3;
}
else if (temp == 2)
{
barNum = faith + 2;
}
else
{
barNum = faith + 1;
}
newPath = "images/mpbar/mp_" + barNum + "%.png";
return newPath;
}
}