-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCounter.java
More file actions
37 lines (34 loc) · 1.18 KB
/
Counter.java
File metadata and controls
37 lines (34 loc) · 1.18 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
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* This Actor is a general actor to store all properties that Counters
* hold such as stat bar variables or food actors which have been found.
*
* @author Isaac Chan
* @version January 28, 2022
*/
public class Counter extends Actor
{
//StatBar variables
int maxVal = 80, currVal = 80;
int width = 80, height = 10, offset = -GameWorld.getGrid()/2;
Color filledColor = new Color (0, 255, 0);
Color missingColor = new Color (255, 0, 0);
boolean hideAtMax = true;
SuperStatBar statBar;
//variables for general usage
Actor findFoodObject;
Food foundFoodObject;
boolean qWasPressed = false, setZero = false;
public boolean touchingPlayer() //method for when the player is interacting with a counter
{
return getObjectsInRange(GameWorld.getGrid(), Player.class).size() > 0;
}
public boolean touchingFood() //method for finding whetherthe counter is touching a food object
{
return isTouching(Food.class);
}
public int getCurrVal() //used for returning the current value of the stat bar
{
return currVal;
}
}