-
Notifications
You must be signed in to change notification settings - Fork 0
/
CountDown.pde
69 lines (56 loc) · 1.17 KB
/
CountDown.pde
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
65
66
67
68
69
class CountDown{
int count_num;
int cur_num;
FrameAnimation ani_per_num;
PImage[] arr_img_num;
boolean finished;
boolean started;
CountDown(int set_num){
ani_per_num=new FrameAnimation(40);
count_num=set_num;
cur_num=0;
arr_img_num=new PImage[count_num];
for(int i=0;i<3;++i){
arr_img_num[i]=loadImage("GAME_B/count_"+nf(i+1,1)+".png");
}
}
void reset(){
started=false;
}
void start(){
cur_num=count_num;
ani_per_num.Restart();
finished=false;
started=true;
}
void update(){
if(!started) return;
ani_per_num.Update();
if(ani_per_num.GetPortion()==1){
if(cur_num>0){
cur_num--;
ani_per_num.Restart();
}else{
finished=true;
// cur_num=count_num;
// ani_per_num.Restart();
}
}
}
boolean isFinished(){
return started && finished;
}
void draw(PGraphics pg,float x,float y){
if(cur_num<1) return;
pg.pushStyle();
pg.imageMode(CENTER);
// pg.blendMode();
pg.pushMatrix();
pg.translate(x,y);
// pg.translate(x,220,map(ani_per_num.GetPortion(),0,1,-800,100));
pg.scale(constrain(ani_per_num.GetPortion(),0,.5)*2);
pg.image(arr_img_num[cur_num-1],0,0);
pg.popMatrix();
pg.popStyle();
}
}