-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgame.js
29 lines (28 loc) · 857 Bytes
/
game.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
class Sprite {
constructor(width, height, x, y, color, speed) {
this.speed = speed;
for (let i = 0; i < 2; i++) {
let elem = $('<div class="sprite"></div>');
elem.css('width', width);
elem.css('height', height);
elem.css('position', 'absolute');
elem.css('left', x + i * 20);
elem.css('top', y);
elem.css('background', color);
$('.game').append(elem);
}
this.move = function() {
}
}
}
class Enemy extends Sprite {
constructor(visibility, lives) {
super('10px', '10px', '50%', '0%', '#000', 50);
$('.sprite').addClass('enemy');
this.lives = lives;
this.visibility = visibility;
if (this.visibility === 0) {
$('.enemy').css('opacity', 0.1);
}
}
}