-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfx.js
62 lines (54 loc) · 1.22 KB
/
fx.js
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
/* exported spaceMine */
/* global drawAt,engine,Animation,drawnEntity,mergeObject,circleOverlap */
"use strict";
var fx = function(settings) {
//*
var ini = {
type:'fx',
radius: 16,
angle:0,
frames:[]
};
var fx = drawnEntity(mergeObject(settings,ini));
fx.animation.speed = 24;
fx.animation.loop = false;
fx.animation.play();
var superUpdate = fx.update;
fx.update = function(dt) {
if(this.animation.end) {
log('fx destroy');
this.destroy();
}
superUpdate.call(this,dt);
};
fx.draw = function(ctx) {
var self = this;
drawAt(ctx,this.position,angle,function(ctx) {
self.animation.draw(ctx,
-self.size.x/2,-self.size.y/2,self.size.x,self.size.y);
});
};
return fx;
};
var smallExplosion = function(settings) {
var ini = {
type:'smallExplosion',
radius: 16,
frames:ressources.smallExplosion,
size:new Point(256,256)
};
var smallExplosion = fx(mergeObject(settings,ini));
engine.camera.shake();
return smallExplosion;
};
var bigExplosion = function(settings) {
var ini = {
type:'bigExplosion',
radius: 64,
frames:ressources.bigExplosion,
size:new Point(256,256)
};
engine.camera.shake(20,50,1.0);
var bigExplosion = fx(mergeObject(settings,ini));
return bigExplosion;
};