Ball isn't bouncing off all sides of the obstacle

342 views
Skip to first unread message
Assigned to scottfr...@gmail.com by taifu...@gmail.com

epo...@gmail.com

unread,
Jun 26, 2014, 11:13:33 PM6/26/14
to mitappinv...@googlegroups.com
I'm doing a game simlar to the mini golf one. I just can't get the ball to bounce of the vertical sides of my obstacles without having to use the orientation sensor.


Does anyone know a good way to do this withuot using the command OrientationSensor1.Roll?

app.png

Abraham Getzler

unread,
Jun 27, 2014, 9:41:32 AM6/27/14
to mitappinv...@googlegroups.com
Here's a link  to my notes on bounce angles in AI2 ...
https://docs.google.com/document/d/1g71sI_rR7PqHGB83tAYZfNi7HvzIkWZ-xsvhFUxpplo/edit?usp=sharing

Further debugging of your problem may require more info on your
sprites' shapes, sizes, and orientations, along with discussions
as to what happens when two sprites collide - which sprite's events fire?

ABG


Scott Ferguson

unread,
Jun 28, 2014, 12:13:20 AM6/28/14
to mitappinv...@googlegroups.com
After looking over Abraham's formula and his suggestion about testing the pixel color of the paddle, I made a test project and it works pretty well for bouncing off of one side of an ImageSprite.
I don't have a good solution for bouncing off all sides of a rotated ImageSprite.
As I recall, > this solution < for bouncing a ball off of a rectangular ImageSprite worked OK but I haven't tested that for rotation.
> This < project which bounced a ball off a drawing on the Canvas and Abraham's formula are the basis for this current solution here which reads the pixel color and uses two clocks -- one to emulate CollidedWith and one to emulate NoLongerCollidingWith.
---


Note that the paddle is 245x20 pixels and is colored by one gray pixel.
App Inventor can propagate a single colored pixel to fill an ImageSprite in that way.





BouncePaddle.aia
Reply all
Reply to author
Forward
0 new messages