Given above is the link of my project. Someone please help me by reviewing my code and telling me that how can I confirm the collision of the player with the moving rectangles.
Please provide me the code of only the lines which specifies the collision of the player and the moving blocks.
I tried so many ways but I can’t figure it out.
Please please help me.
Yeah it’s correct link. But I am sorry that the moving rectangles have white colour.
And ofcourse there cannot be any line of code of collision because that’s what I am asking
I see. So you want to check if two rectangles or objects have collided? It called collision detection. I don’t know how accurate you want to be, but possibly easiest way is to check distance of the objects and when it’s small enough collision has happened. Distance depends on size, shape and accuracy you’re looking for.
You get distance with dist()-function. I would use center points of the objects to get distances. Naturally you need to take that to account when you draw those objects, so that you set them in place with the same center point.
Ya you are right but I already have tried it. And unfortunately it doesn’t work there .
Can, you please try this in my code and if you get that right, please send me the link of that code
No, I won’t. Idea of processing is to learn. What would you learn if I wrote the code for you? I’m happy to help you find the solution. This is a free time activity for me so it shouldn’t feel like work.
I am not telling this to you because of my laziness but I am telling this to you because I have already tried it, even then it shows an eroor- dist() was expecting 4 arguments but received only 0 arguments.
I think I am not writing the dist() function at a correct place and with correctly passed parameters. That’s why I am humbly requesting to please write that function in the proper place and with correctly passed parameters/arguments.
Please please please tell Sir,please…please… Sir… please
Sir, please try to understand. I am telling the same to you also. I am not telling this to you because of my laziness but I am telling this to you because I have already tried it, even then it shows an eroor- dist() was expecting 4 arguments but received on 0 arguments.
I think I am not writing the dist() function at a correct place and with correctly passed parameters. That’s why I am humbly requesting to please write that function in the proper place and with correctly passed parameters/arguments.
Please please please tell Sir,please…please… Sir… please
It isn’t a free time service for me. I have been challenged and also I have a bet to develop a game in p5.js. And also, if I would be able to do so, I will get selected in my school’s CodingTeam.
Did you give it four parameters? it should be something like dist(x1,y1,x2,y2) where x1 and y1 are coordinates of the first point and x2 and y2 are coordinates of the second point