-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathP1Mana.java
56 lines (52 loc) · 1.5 KB
/
P1Mana.java
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
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class P1Mana here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class P1Mana extends Player1
{
GreenfootImage img;
private int Counter = 0;
Font ManaDissplay = new Font(16);
/**
* P1Mana Constructor
*
* This Constructors is for update the Mana show on the screen
*/
public P1Mana(int Mana){
img = new GreenfootImage(1000, 100);
img.setColor(Color.RED);
String ManaCount = "Mana: ";
for (int i = 0; i < Mana; i++) {
ManaCount += "○";
}
img.setFont(ManaDissplay);
img.drawString(ManaCount, 500, 100);
setImage(img);
}
/**
* P1Mana Constructor
* This Constructors is for initial value at start(which is 10 Mana for start)
*/
public P1Mana(){
img = new GreenfootImage(1000, 100);
img.setColor(Color.RED);
img.setFont(ManaDissplay);
img.drawString("Mana: ○○○○○○○○○○", 500, 100);
setImage(img);
}
/**
* Act - do whatever the P1Mana wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*
* remove the old P1Mana class when update it
*/
public void act(){
// Add your action code here.
if(isTouching(P1Mana.class)){
getWorld().removeObject(this);
}
}
}