1
+ function menu ( ) {
2
+ textAlign ( CENTER )
3
+ textSize ( 100 )
4
+ text ( "ARC PLAT" , CanvasWidth / 2 , CanvasHight / 2 - 100 )
5
+ textSize ( 30 )
6
+ text ( "HAYDEN SHUKER" , CanvasWidth / 2 , CanvasHight / 2 - 50 )
7
+ textSize ( 25 )
8
+ text ( "HIGH SCORE:" , CanvasWidth / 2 , CanvasHight / 2 + 50 )
9
+ textSize ( 80 )
10
+ text ( highScore , CanvasWidth / 2 , CanvasHight / 2 + 130 )
11
+ textSize ( 15 )
12
+ text ( "START WITH J, QUICKSTART WITH S" , CanvasWidth / 2 , CanvasHight / 2 + 230 )
13
+ textSize ( 15 )
14
+ text ( "v1.1.1" , CanvasWidth - 30 , 20 )
15
+
16
+ if ( jumpSpaced ) {
17
+ level = 0
18
+ doubleJumpsCount = doubleJumpsTotal
19
+ state = "game"
20
+ generateLevel ( )
21
+ }
22
+ if ( downSpaced ) {
23
+ level = 10
24
+ doubleJumpsCount = doubleJumpsTotal
25
+ state = "game"
26
+ generateLevel ( )
27
+ }
28
+ }
29
+
30
+ function game ( ) {
31
+
32
+ CurrentTimer = timerSeconds * 1000 - ( millis ( ) - timerLastUpdate )
33
+
34
+ levelText ( )
35
+
36
+ player . move ( )
37
+ player . updatePull ( )
38
+ player . display ( )
39
+ hud ( )
40
+ testSuccsess ( )
41
+ testFailure ( )
42
+
43
+ if ( optionSpaced ) {
44
+ developerHudActive = ! developerHudActive
45
+ }
46
+
47
+ for ( var i = 0 ; i < amoutOfPlatforms ; i ++ ) {
48
+ platforms [ i ] . draw ( )
49
+ }
50
+
51
+ if ( level > highScore ) {
52
+ highScore = level
53
+ }
54
+
55
+ function testSuccsess ( ) {
56
+ if ( player . x >= CanvasWidth ) {
57
+ level = level + 1
58
+ if ( doubleJumpsCount < doubleJumpsTotal ) {
59
+ doubleJumpsCount ++
60
+ }
61
+ generateLevel ( )
62
+ }
63
+ }
64
+
65
+ function testFailure ( ) {
66
+ if ( CurrentTimer < 0 || player . y > CanvasHight ) {
67
+ state = "menu"
68
+ }
69
+ }
70
+ }
71
+
72
+ function levelText ( ) {
73
+ fill ( 200 )
74
+ textAlign ( CENTER )
75
+ if ( level == 0 ) {
76
+ textSize ( 100 )
77
+ text ( "W,A,S,D AND J" , CanvasWidth / 2 , CanvasHight / 2 )
78
+ }
79
+ if ( level == 1 ) {
80
+ textSize ( 70 )
81
+ text ( "JUMP IN AIR TO DOUBLE JUMP" , CanvasWidth / 2 , CanvasHight / 2 )
82
+ }
83
+ if ( level == 2 ) {
84
+ textSize ( 60 )
85
+ text ( "DOUBLE JUMPS ARE REPLENISHED" , CanvasWidth / 2 , CanvasHight / 2 - 50 )
86
+ text ( "AFTER EVERY LEVEL" , CanvasWidth / 2 , CanvasHight / 2 + 50 )
87
+ }
88
+ if ( level == 3 ) {
89
+ textSize ( 100 )
90
+ text ( "S TO FAST FALL" , CanvasWidth / 2 , CanvasHight / 2 )
91
+ }
92
+ fill ( 0 )
93
+ }
94
+
95
+ function levelDifficultySet ( ) {
96
+ /*if (level >= 10) {
97
+ levelPlatNumber = 10
98
+ MaxPlatSize = 75
99
+ MinPlatSize = 25
100
+ timerSeconds = 10
101
+ }
102
+ else if (level >= 5) {
103
+ levelPlatNumber = 15
104
+ MaxPlatSize = 150
105
+ MinPlatSize = 50
106
+ timerSeconds = 15
107
+ }
108
+ else if (level >= 1) {
109
+ levelPlatNumber = 20
110
+ MaxPlatSize = 150
111
+ MinPlatSize = 100
112
+ timerSeconds = 30
113
+ }
114
+ else {
115
+ levelPlatNumber = 25
116
+ MaxPlatSize = 150
117
+ MinPlatSize = 100
118
+ timerSeconds = 600
119
+ }*/
120
+ levelPlatNumber = Math . floor (
121
+ 15 + ( 15 / ( level / 2 + 1 ) )
122
+ )
123
+ MaxPlatSize = Math . floor (
124
+ 100 + ( 200 / ( level / 2 + 1 ) )
125
+ )
126
+ MinPlatSize = Math . floor (
127
+ 25 + ( 100 / ( level / 2 + 1 ) )
128
+ )
129
+ timerSeconds = Math . floor (
130
+ 8 + ( 508 / ( ( level * 8 ) + 1 ) )
131
+ )
132
+ }
133
+
134
+ function generateLevel ( ) {
135
+ for ( C = 0 ; C < amoutOfPlatforms ; C ++ ) {
136
+ platforms [ C ] . active = false
137
+ platforms [ C ] . x = floor ( random ( 100 , CanvasWidth ) )
138
+ platforms [ C ] . y = floor ( random ( 250 , CanvasHight - 10 ) )
139
+ }
140
+
141
+ levelDifficultySet ( )
142
+
143
+ for ( C = 0 ; C < amoutOfPlatforms ; C ++ ) {
144
+ platforms [ C ] . width = random ( MinPlatSize , MaxPlatSize )
145
+ }
146
+ //toggle plats
147
+ for ( C = 1 ; C < levelPlatNumber ; C ++ ) {
148
+ platforms [ C ] . active = true
149
+ }
150
+
151
+ timerLastUpdate = millis ( )
152
+
153
+ platforms [ 0 ] . x = - 150
154
+ platforms [ 0 ] . y = CanvasHight - 30
155
+ platforms [ 0 ] . width = 400
156
+ platforms [ 0 ] . active = true
157
+ player . x = 80
158
+ player . y = CanvasHight - 40
159
+ }
160
+
161
+ function input ( ) {
162
+
163
+ //left
164
+ if ( keyIsDown ( 65 ) ) {
165
+ leftKeyDown = true
166
+ }
167
+ else {
168
+ leftKeyDown = false
169
+ leftGap = true
170
+ }
171
+
172
+ if ( leftGap && leftKeyDown ) {
173
+ leftSpaced = true
174
+ leftGap = false
175
+ }
176
+ else {
177
+ leftSpaced = false
178
+ }
179
+
180
+ //right
181
+ if ( keyIsDown ( 68 ) ) {
182
+ rightKeyDown = true
183
+ }
184
+ else {
185
+ rightKeyDown = false
186
+ rightGap = true
187
+ }
188
+
189
+ if ( rightGap && rightKeyDown ) {
190
+ rightSpaced = true
191
+ rightGap = false
192
+ }
193
+ else {
194
+ rightSpaced = false
195
+ }
196
+
197
+ //down
198
+ if ( keyIsDown ( 83 ) ) {
199
+ downKeyDown = true
200
+ }
201
+ else {
202
+ downKeyDown = false
203
+ downGap = true
204
+ }
205
+
206
+ if ( downGap && downKeyDown ) {
207
+ downSpaced = true
208
+ downGap = false
209
+ }
210
+ else {
211
+ downSpaced = false
212
+ }
213
+
214
+ //jump
215
+ if ( keyIsDown ( 74 ) || keyIsDown ( 87 ) ) {
216
+ jumpKeyDown = true
217
+ }
218
+ else {
219
+ jumpKeyDown = false
220
+ jumpGap = true
221
+ }
222
+
223
+ if ( jumpGap && jumpKeyDown ) {
224
+ jumpSpaced = true
225
+ jumpGap = false
226
+ }
227
+ else {
228
+ jumpSpaced = false
229
+ }
230
+
231
+ //option
232
+ if ( keyIsDown ( 49 ) ) {
233
+ optionKeyDown = true
234
+ }
235
+ else {
236
+ optionKeyDown = false
237
+ optionGap = true
238
+ }
239
+
240
+ if ( optionGap && optionKeyDown ) {
241
+ optionSpaced = true
242
+ optionGap = false
243
+ }
244
+ else {
245
+ optionSpaced = false
246
+ }
247
+ }
248
+
249
+ function hud ( ) {
250
+
251
+ standardHud ( )
252
+ developerHud ( )
253
+
254
+ function standardHud ( ) {
255
+ textAlign ( LEFT )
256
+ textSize ( 40 )
257
+ text ( level , 50 , 80 )
258
+ textSize ( 20 )
259
+ text ( Math . round ( ( CurrentTimer / 1000 ) * 100 ) / 100 , 50 , 130 )
260
+ if ( doubleJumpsCount == 1 ) {
261
+ text ( "■ □ □" , 50 , 170 )
262
+ }
263
+ else if ( doubleJumpsCount == 2 ) {
264
+ text ( "■ ■ □" , 50 , 170 )
265
+ }
266
+ else if ( doubleJumpsCount == 3 ) {
267
+ text ( "■ ■ ■" , 50 , 170 )
268
+ }
269
+ else {
270
+ text ( "□ □ □" , 50 , 170 )
271
+ }
272
+ textSize ( 15 )
273
+ text ( highScore , 120 , 80 )
274
+ }
275
+ function developerHud ( ) {
276
+ if ( developerHudActive ) {
277
+ textSize ( 15 )
278
+ textAlign ( LEFT )
279
+ text ( "X pull: " + player . Xpull , 200 , 40 )
280
+ text ( "Y pull: " + player . Ypull , 200 , 60 )
281
+ text ( "grounded: " + player . grounded , 200 , 80 )
282
+ text ( "Max Platform Size: " + MaxPlatSize , 200 , 100 )
283
+ text ( "Min Platform Size: " + MinPlatSize , 200 , 120 )
284
+ text ( "# of Platforms: " + levelPlatNumber , 200 , 140 )
285
+ }
286
+ }
287
+ }
0 commit comments