-
Notifications
You must be signed in to change notification settings - Fork 0
/
effects.js
163 lines (145 loc) · 5.11 KB
/
effects.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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
function increaseDifficulty() {
let xAxisObstacles = obstacles.speed.xAxis
for (let xSpeed in xAxisObstacles){
xAxisObstacles[xSpeed] *= difficultyFactor;
}
let xAxisBackground = background
for (let xSpeed in xAxisBackground){
xAxisBackground[xSpeed] *= difficultyFactor;
}
let xAxisClouds = clouds.speed
for (let xSpeed in xAxisClouds){
xAxisClouds[xSpeed] *= difficultyFactor;
}
let obstacleFrequencies = obstacles.frequency
for (let frequency in obstacleFrequencies){
obstacleFrequencies[frequency] /= difficultyFactor;
}
}
function slowTime() {
isSlowTime = true;
let xAxisObstacles = obstacles.speed.xAxis
for (let xSpeed in xAxisObstacles){
xAxisObstacles[xSpeed] *= collectibles.factor.slowTimeFactor;
}
let yAxisObstacles = obstacles.speed.yAxis
for (let ySpeed in yAxisObstacles){
yAxisObstacles[ySpeed] *= collectibles.factor.slowTimeFactor;
}
let xAxisBackground = background
for (let xSpeed in xAxisBackground){
xAxisBackground[xSpeed] *= collectibles.factor.slowTimeFactor;
}
let xAxisClouds = clouds.speed
for (let xSpeed in xAxisClouds){
xAxisClouds[xSpeed] *= collectibles.factor.slowTimeFactor;
}
const intervalId = setInterval(function() {
for (let xSpeed in xAxisObstacles){
xAxisObstacles[xSpeed] /= collectibles.factor.slowTimeFactor;
};
for (let ySpeed in yAxisObstacles){
yAxisObstacles[ySpeed] /= collectibles.factor.slowTimeFactor;
};
let xAxisBackground = background
for (let xSpeed in xAxisBackground){
xAxisBackground[xSpeed] *= collectibles.factor.slowTimeFactor;
}
let xAxisClouds = clouds.speed
for (let xSpeed in xAxisClouds){
xAxisClouds[xSpeed] *= collectibles.factor.slowTimeFactor;
}
isSlowTime = false;
clearInterval(intervalId);
}, collectibles.duration.slowTimeDuration);
}
function timerDisplay(interval, input) {
effect = input;
displayText = interval / 1000;
const intervalId = setInterval(function() {
displayText -= 1;
if (displayText == 0) {
clearInterval(intervalId);
}
console.log(displayText);
}, 1000);
}
function makePlayerSmall() {
isPlayerSmall = true;
let playerSize = player;
for (let size in playerSize){
playerSize[size] *= collectibles.factor.makeSmallFactor;
}
const intervalId = setInterval(function() {
for (let size in playerSize){
playerSize[size] /= collectibles.factor.slowTimeFactor;
};
isPlayerSmall = false;
clearInterval(intervalId);
}, collectibles.duration.makeSmallDuration);
}
function increasePlayerSpeed () {
isPlayerSpeedIncreased = true;
//add display function here
let verticalFactor = 1.5;
let mitigateSlownessFactor = 1;
if (isPlayerSmall) {
mitigateSlownessFactor = 0.7;
}
verticalSpeed *= collectibles.factor.speedBonusFactor * mitigateSlownessFactor * verticalFactor;
horizontalSpeed *= collectibles.factor.speedBonusFactor * mitigateSlownessFactor;
const intervalId = setInterval(function() {
verticalSpeed /= collectibles.factor.speedBonusFactor * mitigateSlownessFactor* verticalFactor;
horizontalSpeed *= collectibles.factor.speedBonusFactor * mitigateSlownessFactor;
isPlayerSpeedIncreased = false;
clearInterval(intervalId);
}, collectibles.duration.speedBonusDuration);
}
function removeAllObstacles() {
isObstaclesRemoved = true;
const intervalId = setInterval(function() {
verticalSpeed /= collectibles.factor.speedBonusFactor;
horizontalSpeed *= collectibles.factor.speedBonusFactor;
isObstaclesRemoved = false;
clearInterval(intervalId);
}, 1500);
game.ufos = [];
game.rockets = [];
game.anvils = [];
}
function isTeckel() {
isTeckelchen = true;
const intervalId = setInterval(function() {
isTeckelchen = false;
clearInterval(intervalId);
}, 1500);
}
function increaseObstacleSize() {
isObstaclesSupersized = true;
/* this version increases the size of all obstacles
let obstacleWidth = obstacles.size.width;
for (let width in obstacleWidth){
console.log("downsizing");
obstacleWidth[width] *= collectibles.factor.supersizeObstaclesFactor;
}
let obstacleHeight = obstacles.size.height;
for (let height in obstacleHeight){
console.log("downsizing");
obstacleHeight[height] *= collectibles.factor.supersizeObstaclesFactor;
}
*/
obstacles.size.width.rocketWidth *= collectibles.factor.supersizeObstaclesFactor;
obstacles.size.height.rocketHeight *= collectibles.factor.supersizeObstaclesFactor;
const intervalId = setInterval(function() {
/*for (let width in obstacleWidth){
obstacleWidth[width] /= collectibles.factor.supersizeObstaclesFactor;
};
for (let height in obstacleHeight){
obstacleHeight[height] /= collectibles.factor.supersizeObstaclesFactor;
};*/
obstacles.size.width.rocketWidth /= collectibles.factor.supersizeObstaclesFactor;
obstacles.size.height.rocketHeight /= collectibles.factor.supersizeObstaclesFactor;
isObstaclesSupersized = false;
clearInterval(intervalId);
}, collectibles.duration.supersizeObstaclesDuration);
}