-
Notifications
You must be signed in to change notification settings - Fork 437
/
Copy pathbulletBill.js
executable file
·112 lines (96 loc) · 2.97 KB
/
bulletBill.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/**
Represents a bullet bill enemy.
Code by Rob Kleffner, 2011
*/
Mario.BulletBill = function(world, x, y, dir) {
this.Image = Enjine.Resources.Images["enemies"];
this.World = world;
this.X = x;
this.Y = y;
this.Facing = dir;
this.XPicO = 8;
this.YPicO = 31;
this.Height = 12;
this.Width = 4;
this.PicWidth = 16;
this.YPic = 5;
this.XPic = 0;
this.Ya = -5;
this.DeadTime = 0;
this.Dead = false;
this.Anim = 0;
};
Mario.BulletBill.prototype = new Mario.NotchSprite();
Mario.BulletBill.prototype.CollideCheck = function() {
if (this.Dead) {
return;
}
var xMarioD = Mario.MarioCharacter.X - this.X, yMarioD = Mario.MarioCharacter.Y - this.Y;
if (xMarioD > -16 && xMarioD < 16) {
if (yMarioD > -this.Height && yMarioD < this.World.Mario.Height) {
if (Mario.MarioCharacter.Y > 0 && yMarioD <= 0 && (!Mario.MarioCharacter.OnGround || !Mario.MarioCharacter.WasOnGround)) {
Mario.MarioCharacter.Stomp(this);
this.Dead = true;
this.Xa = 0;
this.Ya = 1;
this.DeadTime = 100;
} else {
Mario.MarioCharacter.GetHurt();
}
}
}
};
Mario.BulletBill.prototype.Move = function() {
var i = 0, sideWaysSpeed = 4;
if (this.DeadTime > 0) {
this.DeadTime--;
if (this.DeadTime === 0) {
this.DeadTime = 1;
for (i = 0; i < 8; i++) {
this.World.AddSprite(new Mario.Sparkle(((this.X + Math.random() * 16 - 8) | 0) + 4, ((this.Y + Math.random() * 8) | 0) + 4, Math.random() * 2 - 1, Math.random() * -1, 0, 1, 5));
}
this.World.RemoveSprite(this);
}
this.X += this.Xa;
this.Y += this.Ya;
this.Ya *= 0.95;
this.Ya += 1;
return;
}
this.Xa = this.Facing * sideWaysSpeed;
this.XFlip = this.Facing === -1;
this.Move(this.Xa, 0);
};
Mario.BulletBill.prototype.SubMove = function(xa, ya) {
this.X += xa;
return true;
};
Mario.BulletBill.prototype.FireballCollideCheck = function(fireball) {
if (this.DeadTime !== 0) {
return false;
}
var xD = fireball.X - this.X, yD = fireball.Y - this.Y;
if (xD > -16 && xD < 16) {
if (yD > -this.Height && yD < fireball.Height) {
return true;
}
}
return false;
};
Mario.BulletBill.prototype.ShellCollideCheck = function(shell) {
if (this.DeadTime !== 0) {
return false;
}
var xD = shell.X - this.X, yD = shell.Y - this.Y;
if (xD > -16 && xD < 16) {
if (yD > -this.Height && yD < shell.Height) {
Enjine.Resources.PlaySound("kick");
this.Dead = true;
this.Xa = 0;
this.Ya = 1;
this.DeadTime = 100;
return true;
}
}
return false;
};