Hi everyone, I just thought I'd share something I've been working on. Aside from game developers I doubt many will have much of a use for it.
So for one of my upcomming games I needed to be able to handle collisions between two circular sprites, which was umm... harder than I hoped. In the end though I was able to get it going and I have a working sample channel if anyone is interested.
https://github.com/Romans-I-XVI/Roku-El ... on-PhysicsIf you just want to see what the channel does without installing you can see here...
https://www.youtube.com/watch?v=httCGL_XwLASo in this sample we are essentially spawning 20 balls with random sizes that also correlate to their mass, tell them to start moving at a random speed, and then let the ManageBounce() function do its magic
😛If you look at my commit history on github you might see I've been banging my head on the desk trying to make the code *perfect*. Because, although everything works great, there are special circumstances where occassionally a ball will pass through another ball. I know what the cause is, but I don't know the solution. Once two balls have collided I have to mark that the collision has happened because if I don't, and the collision is still occuring in the next frame even though speeds have already been altered, the collision will be processed again and the balls get stuck together. The problem that creates though is that if say another ball comes and hits the ball, while it is still registering that previous collision, it won't register it another time (again because it doesn't want to get stuck together) and will pass right through the ball it originally had a collision with. I've tried getting really crazy with it from about every angle I can think of, handling multiple collisions at a time, disabling the first collision if a second collision occurs ( this just leads back to the problem of balls getting stuck together sometimes ), manually altering speeds. In the end I reverted to the code I had originally that seemed to work just as good ( it's hard to tell for sure since it's so random ) and is a lot less complicated.
So if anyone has any thoughts on getting this to work 100% with balls never passing through each other, even if there were say 40+ on the screen, let me know. Otherwise enjoy the code. Hopefully somebody can use this in a game or something.