Accelerometer moving a grc
Posted: Wed May 23, 2012 9:42 pm
I've been working on a stack that moves a round grc around the screen based on the accelerometer. I have code that keeps it within the bounds of the screen, code that makes it "bounce" a little based on velocity, as well as a little friction so that its actually possible to stop the ball in place.
All of the above is working well.
My problem is that I want to turn this into a marble maze game and i'm having difficulty dealing with the walls. I've got it to where the walls are maneagable in 2 directions (for example, top and bottom, check for intersect, check direction of movement and then set the ball to the proper location (a y value) and adjust the velocity(for the bounce affect, reverse direction and multiply the velocity by a factor to slow it way down)
The thing I can't seem to wrap my head around is a way to roll the ball around a corner. Obviously this will require a full rethink. Currently as it tries to pass the corner an intersect occurs and it pops to the top or the bottom which is not the desired affect.
Can anyone point me to a better algorithm? Give any pointers at all?
Thanks in advance for any and all help!
All of the above is working well.
My problem is that I want to turn this into a marble maze game and i'm having difficulty dealing with the walls. I've got it to where the walls are maneagable in 2 directions (for example, top and bottom, check for intersect, check direction of movement and then set the ball to the proper location (a y value) and adjust the velocity(for the bounce affect, reverse direction and multiply the velocity by a factor to slow it way down)
The thing I can't seem to wrap my head around is a way to roll the ball around a corner. Obviously this will require a full rethink. Currently as it tries to pass the corner an intersect occurs and it pops to the top or the bottom which is not the desired affect.
Can anyone point me to a better algorithm? Give any pointers at all?
Thanks in advance for any and all help!