You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: platformer.js
+7-5Lines changed: 7 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -120,12 +120,12 @@ function update() {
120
120
121
121
if(xCollision(player,platform)&&yCollision(player,platform)){//stoping player going up if hitting platforms
122
122
playerVelY=0;
123
-
if(checkSide(player,platform)==right){
123
+
if(checkSideRight){
124
124
if(playerVelX<0){
125
125
playerVelX=0
126
126
};
127
127
};
128
-
if(checkSide(player,platform)==left){
128
+
if(checkSideLeft){
129
129
if(playerVelX>0){
130
130
playerVelX=0
131
131
};
@@ -161,13 +161,15 @@ function createPlatforms() {
161
161
platform.y=200;
162
162
platformArray.push(platform);
163
163
};
164
-
functioncheckSide(a,b){
164
+
functioncheckSideLeft(a,b){
165
165
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
166
166
if(a.x+a.width-b.x<=10&&a.x+a.width-b.x>=0)
167
-
returnleft;
167
+
returntrue;
168
168
};
169
+
};
170
+
functioncheckSideRight(a,b){
169
171
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
0 commit comments