Skip to content
This repository was archived by the owner on Jul 18, 2020. It is now read-only.

Commit 2b1c9a5

Browse files
committed
Added new version of ARC PLAT fixes #6
1 parent 6787673 commit 2b1c9a5

File tree

6 files changed

+515
-3
lines changed

6 files changed

+515
-3
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,287 @@
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+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
var CanvasWidth = 1200
2+
var CanvasHight = 600
3+
4+
//platforms
5+
var platforms = []
6+
var amoutOfPlatforms = 30
7+
8+
//Controls
9+
var jumpGap = false
10+
var jumpSpaced = false
11+
var jumpKeyDown = false
12+
13+
var upGap = false
14+
var upSpaced = false
15+
var upKeyDown = false
16+
17+
var downGap = false
18+
var downSpaced = false
19+
var downKeyDown = false
20+
21+
var rightGap = false
22+
var rightSpaced = false
23+
var rightKeyDown = false
24+
25+
var leftGap = false
26+
var leftSpaced = false
27+
var leftKeyDown = false
28+
29+
var optionGap = false
30+
var optionSpaced = false
31+
var optionKeyDown = false
32+
//jumping
33+
var gravity = 8
34+
var momentumCutoff = -1
35+
var LateralMovemetSpeed = 5
36+
var aerialSpeedchangeD = 0.1
37+
var aerialSpeedchange = aerialSpeedchangeD
38+
var jumpPower = 12
39+
// double Jumping
40+
var doubleJumpsTotal = 3
41+
var doubleJumpsPower = 5
42+
var doubleJumpsCount = 3
43+
44+
// level stats
45+
var level = 0
46+
var timerSeconds
47+
var levelPlatNumber = amoutOfPlatforms
48+
var MaxPlatSize
49+
var MinPlatSize
50+
51+
//timer
52+
var timerLastUpdate = 0
53+
var CurrentTimer
54+
55+
//game
56+
var state = "menu"
57+
var highScore = 0
58+
//gui
59+
var developerHudActive = false
60+
var developerHudSize = 20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.6.1/p5.js">
5+
</script>
6+
<body>
7+
<script src="https://firebasestorage.googleapis.com/v0/b/claytondoesthingsxyz.appspot.com/o/games%2FArc-Plat%2FWeb%2Fv1.1.1%2Fglobals.js?alt=media&token=3f2d6055-67f2-4e6c-b9ef-14c48764e7f3"></script>
8+
<script src="https://firebasestorage.googleapis.com/v0/b/claytondoesthingsxyz.appspot.com/o/games%2FArc-Plat%2FWeb%2Fv1.1.1%2Fclasses.js?alt=media&token=83ea178b-9674-4cf9-b6af-8984a1f0717c"></script>
9+
<script src="https://firebasestorage.googleapis.com/v0/b/claytondoesthingsxyz.appspot.com/o/games%2FArc-Plat%2FWeb%2Fv1.1.1%2Findex.js?alt=media&token=7fa366de-dd96-4963-b384-bc09661240a2"></script>
10+
<script src="https://firebasestorage.googleapis.com/v0/b/claytondoesthingsxyz.appspot.com/o/games%2FArc-Plat%2FWeb%2Fv1.1.1%2Fobjects.js?alt=media&token=e6f6ff85-b09a-4df3-943d-a10722ea85d7"></script>
11+
</body>
12+
</html>
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
function setup() {
2+
createCanvas(CanvasWidth, CanvasHight);
3+
fill(0)
4+
5+
player = new playerObject()
6+
7+
for (var i = 0; i < amoutOfPlatforms; i++) {
8+
platforms.push(new platformObject())
9+
}
10+
}
11+
12+
function draw() {
13+
background(230)
14+
15+
input()
16+
17+
if(state == "menu"){
18+
menu()
19+
}
20+
else if(state == "game"){
21+
game()
22+
}
23+
}

0 commit comments

Comments
 (0)