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
if(xCollision(player,platform)&&yCollision(player,platform)){//stoping player going up if hitting platforms
122
-
playerVelY=0;
123
-
if(checkSideRight){
124
-
if(playerVelX<0){
125
-
playerVelX=0
126
-
};
127
-
};
128
-
if(checkSideLeft){
129
-
if(playerVelX>0){
130
-
playerVelX=0
131
-
};
132
-
};
133
-
};
120
+
134
121
};
135
122
136
123
//player x movement
@@ -146,30 +133,10 @@ function update() {
146
133
147
134
};
148
135
149
-
functionxCollision(a,b){// checks is the left or right sides are touching
150
-
returna.x<=b.x+b.width&&//a's left side is to the left of b's right side
151
-
a.x+a.width>=b.x;//a's right side is to the right b's left side
152
-
};
153
-
functionyCollision(a,b){
154
-
returna.y<=b.y+b.height&&//a's top side is above b's bottom side
155
-
a.y+a.height>=b.y;//a's bottom side is under b's top side
156
-
};
157
136
functioncreatePlatforms(){
158
137
platform.height=25;
159
138
platform.width=150;
160
139
platform.x=50;
161
140
platform.y=200;
162
141
platformArray.push(platform);
163
142
};
164
-
functioncheckSideLeft(a,b){
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
-
if(a.x+a.width-b.x<=10&&a.x+a.width-b.x>=0)
167
-
returntrue;
168
-
};
169
-
};
170
-
functioncheckSideRight(a,b){
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