4 Way Collision | Sololearn: Learn to code for FREE!

+4

# 4 Way Collision

How can I test to see whether the player is touching the bottom, top, left or right of the platform? Each side will have a different reaction. https://code.sololearn.com/WSC3JL587LQ2/?ref=app

6/25/2019 2:45:42 PM

Clueless Coder

+5

I really canβt help, but maybe this code of mine is helpful? It also handles collisions on 4 sides of a block... https://code.sololearn.com/WM2x10n1vy1A/?ref=app

+5

β__JavaScripter__π i hope so too, good luck πΉπΉ

+5

marjel101 Does the variable "x0" and "yO" reference the square on your code?

+4

β__JavaScripter__π yes, these are used in the collision detection between blocks and circles. I found the function in the p5.collide2D library.

+3

marjel101 Interesting, I tried p5.collide2D with InvBoy's Node.js library but I couldn't find anything like that on GitHub. I wonder if there is an alternative for collideRectRect() which checks sides and widths of the object?

+3

β__JavaScripter__π did you have a look at https://github.com/bmoren/p5.collide2D/blob/master/p5.collide2d.js ?

+2

marjel101 Thanks for the reply. I don't understand collision in the code at all, but thanks anyway. I have asked Coder to see if he can help.

+2

Concept: have the platforms break up into 4 lines and detect collisions with the point edges of the box Implementing this takes a bit of time (for me to test) Source: http://www.jeffreythompson.org/collision-detection/line-point.php

+2

Coder It's probably an easy solve Again. But I can't get the top collision to respond again https://code.sololearn.com/WjuHV2FIB48r/?ref=app

+2

Coder The character can't jump when it hits the top of the platform. Also, when I did debugging using the console, I found out that top and bottom are reversed.