Skip to content

Commit 54b4fa3

Browse files
committed
trying to fix crash
1 parent 346c36c commit 54b4fa3

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

platformer.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,12 @@ function update() {
120120

121121
if (xCollision(player, platform)&& yCollision(player, platform) ) { //stoping player going up if hitting platforms
122122
playerVelY = 0;
123-
if (checkSide(player,platform) == right){
123+
if (checkSideRight){
124124
if(playerVelX < 0){
125125
playerVelX = 0
126126
};
127127
};
128-
if (checkSide(player,platform) == left){
128+
if (checkSideLeft){
129129
if(playerVelX > 0){
130130
playerVelX = 0
131131
};
@@ -161,13 +161,15 @@ function createPlatforms() {
161161
platform.y = 200;
162162
platformArray.push(platform);
163163
};
164-
function checkSide(a, b) {
164+
function checkSideLeft(a, b) {
165165
if(a.x <= b.x && a.x + a.width >= b.x){ //if a left side to the left of b left side and a right side to the right of b left side, its the right side of a touching b
166166
if (a.x + a.width - b.x <= 10 && a.x + a.width - b.x >= 0)
167-
return left;
167+
return true;
168168
};
169+
};
170+
function checkSideRight(a, b) {
169171
if(a.x <= b.x + b.width && a.x + a.width >= b.x + b.width){ //if a left side to the left of b left side and a right side to the right of b left side, its the right side of a touching b
170172
if (a.x + a.width - b.x - b.width <= 10 && a.x + a.width - b.x - b.width >= 0)
171-
return right;
173+
return true ;
172174
};
173175
};

0 commit comments

Comments
 (0)