-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpea_bullet.h
59 lines (52 loc) · 1.22 KB
/
pea_bullet.h
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
#pragma once
#include "bullet.h"
#include "animation.h"
extern IMAGE img_pea;
extern Atlas atlas_pea_break;
class PeaBullet:public Bullet
{
public:
PeaBullet() {
size = { 64 ,64 };
damage = 10;
//配置破碎动画
animation_break.set_atlas(&atlas_pea_break);
animation_break.set_interval(100);
animation_break.set_loop(0);
animation_break.set_callback([&]() {can_remove = 1;});
};
~PeaBullet()=default;
void on_collide() {
Bullet::on_collide();
//随机播放豌豆子弹碎裂音效
switch (rand()%3)
{
case 0:
mciSendString(_T("play pea_break_1 from 0"), NULL,0,NULL);
break;
case 1:
mciSendString(_T("play pea_break_2 from 0"), NULL, 0, NULL);
break;
case 2:
mciSendString(_T("play pea_break_3 from 0"), NULL, 0, NULL);
break;
default:
break;
}
}
void on_update(int delta) {
pos += velcity * (float)delta;
if (!valid) animation_break.on_update(delta);//无效子弹更新破碎动画
if (check_exceed_screen())can_remove = 1;
}
void on_draw(const Camera& camera) const {
//根据子弹状态设置渲染
if (valid) puimage_alpha(camera, (int)pos.x,(int)pos.y ,&img_pea);
else
{
animation_break.on_draw(camera, (int)pos.x, (int)pos.y);
}
}
private:
Animation animation_break;//豌豆子弹碎裂动画
};