forked from robertkleffner/mariohtml5
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloseState.js
More file actions
executable file
·60 lines (50 loc) · 1.73 KB
/
Copy pathloseState.js
File metadata and controls
executable file
·60 lines (50 loc) · 1.73 KB
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
/**
State shown when the player loses!
Code by Rob Kleffner, 2011
*/
Mario.LoseState = function() {
this.drawManager = null;
this.camera = null;
this.gameOver = null;
this.font = null;
this.wasKeyDown = false;
};
Mario.LoseState.prototype = new Enjine.GameState();
Mario.LoseState.prototype.Enter = function() {
this.drawManager = new Enjine.DrawableManager();
this.camera = new Enjine.Camera();
this.gameOver = new Enjine.AnimatedSprite();
this.gameOver.Image = Enjine.Resources.Images["gameOverGhost"];
this.gameOver.SetColumnCount(9);
this.gameOver.SetRowCount(1);
this.gameOver.AddNewSequence("turnLoop", 0, 0, 0, 8);
this.gameOver.PlaySequence("turnLoop", true);
this.gameOver.FramesPerSecond = 1/15;
this.gameOver.X = 112;
this.gameOver.Y = 68;
this.font = Mario.SpriteCuts.CreateBlackFont();
this.font.Strings[0] = { String: "Game over!", X: 116, Y: 160 };
this.drawManager.Add(this.font);
this.drawManager.Add(this.gameOver);
};
Mario.LoseState.prototype.Exit = function() {
this.drawManager.Clear();
delete this.drawManager;
delete this.camera;
delete this.gameOver;
delete this.font;
};
Mario.LoseState.prototype.Update = function(delta) {
this.drawManager.Update(delta);
if (Enjine.KeyboardInput.IsKeyDown(Enjine.Keys.S)) {
this.wasKeyDown = true;
}
};
Mario.LoseState.prototype.Draw = function(context) {
this.drawManager.Draw(context, this.camera);
};
Mario.LoseState.prototype.CheckForChange = function(context) {
if (this.wasKeyDown && !Enjine.KeyboardInput.IsKeyDown(Enjine.Keys.S)) {
context.ChangeState(new Mario.TitleState());
}
};