-
Notifications
You must be signed in to change notification settings - Fork 0
/
CreditsPlayer.as
127 lines (123 loc) · 3.36 KB
/
CreditsPlayer.as
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
package {
import flash.display.DisplayObjectContainer;
/**
* Shitty Fucking Art Game
* @author Sean Finch
* @version 27APR2011
*/
/* Copyright © 2011 - 2015 Sean Finch
This file is part of Shitty Fucking Art Game.
bang is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
bang is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with bang. If not, see <http://www.gnu.org/licenses>. */
public class CreditsPlayer extends CreditsEntity {
private var stepCount:int;
public var arrested:Boolean;
public var arrestTimer:int;
public var appliedForce:Number;
private var grabPower:int;
private var prevkeys:uint;
public function CreditsPlayer(layer:DisplayObjectContainer, collideLayer:DisplayObjectContainer, dx:int, dy:int) {
super(layer, collideLayer);
icon = new protagonist();
icon.x = dx;
icon.y = dy;
jumptimer = 0;
arrestTimer = 0;
arrested = false;
_parent.addChild(icon);
stepCount = 0;
appliedForce = 0;
grabPower = 2000;
prevkeys = 0;
}
public function getKeys(keys:uint):void {
icon.rotation = 0;
if (!collide.hitTestPoint(icon.x, icon.y + icon.height / 2 + 2, true)) {
jumping = true;
}
if (arrestTimer == 0 && !arrested) {
prevkeys = 0;
appliedForce = 0;
if (!thud) {
if (keys & 2) {
icon.gotoAndStop(2);
icon.scaleX = -1;
icon.x -= 5;
stepCount += 1;
} else if (keys & 4) {
icon.gotoAndStop(2);
icon.scaleX = 1;
icon.x += 5;
stepCount += 1;
} else {
icon.gotoAndStop(1);
}
if (keys & 1) {
if (!jumping && jumptimer == 0) {
jumptimer = 12;
if (!SelectionMemory.soundOff) {
SelectionMemory.sHandler.jump.play();
}
}
jumping = true;
if (jumptimer > 0) {
jumptimer -= 1;
icon.y -= jumptimer;
fallVelocity = 0;
}
}
/*if ((keys & 8) && !jumping) {
icon.y += icon.height / 1.5;
jumping = true;
}*/
if (stepCount > 6 && !jumping) {
stepCount = 0;
if (!SelectionMemory.soundOff) {
SelectionMemory.sHandler.step.play();
}
}
} else {
icon.gotoAndStop(6);
}
} else {
if (keys > 0 && (keys != prevkeys) && !arrested) {
appliedForce += 1 + (grabPower / 1000) * Math.random();
icon.rotation = 360 * Math.random();
if (!SelectionMemory.soundOff) {
SelectionMemory.sHandler.jump.play();
}
icon.x += -3 + 6 * Math.random();
prevkeys = keys;
}
icon.gotoAndStop(4);
if (arrestTimer >= 3) {
arrested = true;
icon.gotoAndStop(7);
}
arrestTimer = 0;
}
if (arrested) {
icon.gotoAndStop(7);
icon.x += icon.scaleX * 3;
} else if (jumping) {
if (fallVelocity > 9) {
fallVelocity = 9;
if (!thud) { icon.gotoAndStop(5); }
} else {
if (!thud) { icon.gotoAndStop(3); }
}
icon.y += fallVelocity;
fallVelocity += 0.25;
}
update();
}
}
}