-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbullet.js
59 lines (43 loc) · 1.22 KB
/
bullet.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
'use strict';
function Bullet(ctx, width, height, playerX, bulletY, rockArray) {
var self = this;
self.ctx = ctx;
self.width = width;
self.height = height;
self.x = playerX;
self.y = bulletY;
self.bulletHeight = 0;
self.bulletWidth = 10;
self.dy = 10;
self.rockArray = rockArray;
self.startTime = new Date();
self.timeLapse;
self.totalTime;
self.hit = new Audio('./sounds/dragon_ball_z_scream_9-RA_The_Sun_God-952538986.mp3');
};
Bullet.prototype.update = function () {
var self = this;
self.timeLapse = new Date();
self.bulletHeight -= self.dy;
if (self.bulletHeight < -490 ){
self.bulletHeight = -490;
}
self.totalTime = self.timeLapse - self.startTime;
};
Bullet.prototype.draw = function () {
var self = this;
self.ctx.fillStyle = 'red';
self.ctx.fillRect(self.x+ 70, self.height -30, self.bulletWidth, self.bulletHeight);
};
// Bullet.prototype.hitting = function () {
// var self = this;
// // function play() {
// // self.hit;
// // if (audio.paused) {
// // audio.play();
// // } else {
// // audio.currentTime = 0
// // }
// // }
// self.hit.play();
// }