+ 1
Help!!! What's wrong in this code?
Hi, everyone I don't know ... đ„đ„đ„ ... why does the player fall through the floor, I actually wanted him only fit through small holes (when he is exactly on the hole). But he always falls through the floor when he is right on any block Can anybody help me ... i would be very happy. Hoping i will get some answers, S.A. https://code.sololearn.com/Wa2A10a20a24/?ref=app
8 Respostas
+ 1
If you want to check for an collision on all side of the player you need both x and y coordinates. X is for the left and right side of the player and y is used to check the top and bottom of the player.
I've change playerXPos to playerYPos at line 103 and 108, I also logged the variable tor to help with this point. I suggest you console.log tor on your original code to see the difference
Take a look and see if this the result you were expecting.
https://code.sololearn.com/W86a2403a3a1
btw - You have to tap on the game board to bring it in focus so you can you use the keyboard to move the player around.
+ 1
ODLNT THANK YOU!!!!!!!!!! IT WORKS NOW! THANK YOU VERY MUCH!!!!!!!!
0
You get out of the matrix
Working with try/catch could do it.
0
Frogged no, no exception is throwed. The problem is that the player can fall throu the floor. I'm goint to fix the other error later.
0
Try/catch is the idea how to fixđ
0
At line 108 are you checking for playerXPos or playerYPos?
0
ODLNT playerXPos, because I need to check: if the player is exactly at an block (an not on onother), I should only check the block below the player.
0
You are very welcome. Keep up the good.