-
Notifications
You must be signed in to change notification settings - Fork 0
/
enemy_2.js
64 lines (56 loc) · 1.73 KB
/
enemy_2.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
63
64
const enemy_2_create = function() {
enemy_2 = Game.add.sprite(800, 2300,'Hound')
enemy_2.health = 70
enemy_2.scale.setTo(1.7)
}
const enemy_2_phys = function() {
Game.physics.arcade.enable(enemy_2)
enemy_2.body.gravity.y = 500
enemy_2.body.collideWorldBounds = true
enemy_2.body.setSize(48, 28, 10, 4)
enemy_2.body.velocity.x = -300
}
const enemy_2_movement = function() {
if (enemy_2.x === plat_hound.x){
enemy_2.body.velocity.x = 300
enemy_2.animations.add('right',[5,6,7,8,9],10,true).play()
}else if (enemy_2.x + enemy_2.width - 3.9 === plat_hound.x + plat_hound.width){
enemy_2.body.velocity.x = -300
enemy_2.animations.add('left',[0,1,2,3,4],10,true).play()
}
}
const enemy_2_dying = function() {
if (enemy_2.health < 0){
enemy_2.kill()
}
}
const enemy_2_damage = function() {
if (pl.visible && enemy_2.visible){
if (Phaser.Rectangle.intersects(pl.body, enemy_2.body)){
pl.health -= 1
}}
}
const enemy_2_hit = function() {
if (pl.visible && enemy_2.visible){
if (Phaser.Rectangle.intersects(attacker.body, enemy_2.body)){
enemy_2.health -= 5
pl.health += 7
}
if (Phaser.Rectangle.intersects(attacker1.body, enemy_2.body)){
enemy_2.health -= 5
pl.health += 7
}
}
}
const enemy_2_collision = function() {
Game.physics.arcade.collide(enemy_2, platform5)
Game.physics.arcade.collide(enemy_2, plat_hound)
Game.physics.arcade.collide(enemy_2, plat_hound2)
Game.physics.arcade.collide(enemy_2, plat_hound3)
}
const enemy_2_revive = function() {
enemy_2.revive()
enemy_2.x = 1100
enemy_2.y = 2900
enemy_2.health = 50
}