Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Help with Physics when ball hit the paddle (Arkanoid type of game)

Author
Message
MobileCreator
13
Years of Service
User Offline
Joined: 1st Jun 2011
Location: Ottawa - Canada
Posted: 10th Oct 2011 00:49
I'm build an Arkanoid type of game, and what I've done is when the ball hit the paddle, I change the speed depends on the point of contact. I'm not using physic commands whatsoever, and here is the code snipet:



INITIAL_VELOCITY_BALL_X and INITIAL_VELOCITY_BALL_Y are set to 5.

It is working, but I don't think it has the right behavior, because the diff variable changes the ball X speed to actually change its angle. Sometimes when I want to increase the global speed (velocity_increase), the angle also changes.

Another problem is that, when the ball hits the paddle close to the center, I'm setting its speed to the default value without the diff factor, which makes hard to get an angle close to 90 degrees as the speed gets higher.

What I 'd like to do is be able to:

- make the angle and the speed independent
- make the angle close to 90 degrees when hit the center
- (opcional) make the angle and speed vary depends on the speed that the paddle were moving while hitting the ball.


I know I'm ask a lot and this is math/physics not really AppGameKit, but I have no idea where to start. I tried few experiments with Box2D, but I couldn't get anywere.

Any help will be appreciated.

Thanks

----------
Paulo
http://www.mobilecreators.com
MobileCreator
13
Years of Service
User Offline
Joined: 1st Jun 2011
Location: Ottawa - Canada
Posted: 10th Oct 2011 21:30
Ok,

after burning the midnight oil, I think I've came up with the right solution. Here is the code, if you are curious:



I'm not considering the paddle speed at all, but I like the way it is working now.

Cheers

----------
Paulo
http://www.mobilecreators.com
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 11th Oct 2011 12:41
nice

Login to post a reply

Server time is: 2024-11-22 03:43:52
Your offset time is: 2024-11-22 03:43:52