-
Notifications
You must be signed in to change notification settings - Fork 6
/
Progress.java
64 lines (57 loc) · 2.64 KB
/
Progress.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
57
58
59
60
61
62
63
64
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Progress here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Progress extends Actor
{
/**
* Act - do whatever the Progress wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
//428, 14
public long currentFrame = System.currentTimeMillis();
public long lastFrame = System.currentTimeMillis();
public long deltaTime = System.currentTimeMillis();
public WaveManager level;
public GreenfootImage bar = new GreenfootImage(428, 14);
public Progress(WaveManager level) {
this.level = level;
}
public void addedToWorld(World world) {
for (int i : level.hugeWaves) {
if (i == level.level.length-1) {
getWorld().addObject(new Flag(), 290, 21);
} else {
int x = 700-(int)((double)(i+1)/(level.level.length)*428);
getWorld().addObject(new Flag(), x, 21);
}
}
}
public void act()
{
currentFrame = System.currentTimeMillis();
deltaTime = (currentFrame - lastFrame);
if (level.wave != -1) {
if (deltaTime > 2000L) {
bar.setColor(new Color(240, 240, 128));
bar.fillRect((int)(428-428*((double)(level.wave+1)/level.level.length)), 0, (int)(428*((double)(level.wave+1)/level.level.length)), 14);
getImage().drawImage(bar, 14, 14);
bar.setColor(new Color(192, 224, 96));
bar.fillRect((int)(428-428*((double)(level.wave+1)/level.level.length)), 5, (int)(428*((double)(level.wave+1)/level.level.length)), 14);
getImage().drawImage(bar, 14, 14);
bar.setColor(new Color(152, 200, 80));
bar.fillRect((int)(428-428*((double)(level.wave+1)/level.level.length)), 7, (int)(428*((double)(level.wave+1)/level.level.length)), 14);
getImage().drawImage(bar, 14, 14);
bar.setColor(new Color(128, 184, 64));
bar.fillRect((int)(428-428*((double)(level.wave+1)/level.level.length)), 9, (int)(428*((double)(level.wave+1)/level.level.length)), 14);
getImage().drawImage(bar, 14, 14);
bar.setColor(new Color(80, 160, 32));
bar.fillRect((int)(428-428*((double)(level.wave+1)/level.level.length)), 11, (int)(428*((double)(level.wave+1)/level.level.length)), 14);
getImage().drawImage(bar, 14, 14);
}
}
}
}