Hello everyone, I have a little question about basic gravity and platforms.
In my programs, there's two squares : player and enemy. There is also a bunch of platforms, "solid" structures that no object is supposed to pass by.
Here are my problems :
- I just don't know how to come up with a basic gravity feature. I guess there is a force that pulls down the objets and jumping, for example, is just "going against" that force?
- I managed to "detect" if one square is over a platform, but I don't know how to make the platform "solid" as in : the animated objets cannot go into that part of the screen.
Here's my code, I hope you guys can help me.
Also, any comment on my code or problems with it will be more than welcome.
Thanks!
The code is divided in two parts. Main and Classes.
I started learning Processing two days ago and I'm experimenting quite a bit. So far, I'm loving it. I've been trying to make a little program where the user can control a square (SquareA) and when he collides with SquareB, the screen goes all red.
I managed to program a very primitive form of collision, but it only takes in account SquareB's corner (I'm comparing the coordinates of both squares to generate a big, red rect() that would cover the whole screen.
I think the logic is kind of there, but I would need to find a way to take in account all the points in both squares and compare them. I don't know how to do this yet and there's where I would need some help. My idea, for the moment, is to find a way to calculate the squares areas to know which coordinates they're occupying and then comparing them. But this seems kind of complicated, I'm sure there's another way that I don't know yet.
Any pointers for syntax and those kind of things will be appreciated too.