Computer Science Canada Moving the ball in Brick Breaker. |
Author: | miller6 [ Tue Jan 19, 2010 11:20 am ] | ||
Post subject: | Moving the ball in Brick Breaker. | ||
What is it you are trying to achieve? I am trying to move the ball (in this case a snowflake) just like the ball in breakbreaker. Where it bounces off the side of the wall when it hits it. What is the problem you are having? Moving the ball all around the screen and showing the movement of it. Describe what you have tried to solve this problem Alot. I have tried different ways of moving it, but still have problems. Post any relevant code (You may choose to attach the file instead of posting the code if it is too long) This is the main part of moving the ball. Not entire program posted.
Please specify what version of Turing you are using 4.1.1 |
Author: | miller6 [ Tue Jan 19, 2010 11:20 am ] |
Post subject: | RE:Moving the ball in Brick Breaker. |
sorry for the double attachment. |
Author: | Turing_Gamer [ Tue Jan 19, 2010 5:34 pm ] | ||
Post subject: | Re: Moving the ball in Brick Breaker. | ||
Have 2 separate variables: speed and direction. Then do the following...
Puting how fast and what direction is easy. Use either boolean or if statements. |
Author: | TheGuardian001 [ Tue Jan 19, 2010 6:22 pm ] | ||||
Post subject: | Re: Moving the ball in Brick Breaker. | ||||
Turing_Gamer @ Tue Jan 19, 2010 5:34 pm wrote: Have 2 separate variables: speed and direction. Then do the following...
Puting how fast and what direction is easy. Use either boolean or if statements. I think you probably meant
since multiplying by 1 won't do anything... |
Author: | andrew. [ Tue Jan 19, 2010 8:53 pm ] | ||
Post subject: | RE:Moving the ball in Brick Breaker. | ||
Or you can multiply by -1 (which was probably his intention).
|
Author: | miller6 [ Wed Jan 20, 2010 11:17 am ] | ||
Post subject: | Re: Moving the ball in Brick Breaker. | ||
okay, so it is still doing the same thing, its just popping up in random places. It is not travelling from each position to each position. This is the changed code:
|
Author: | miller6 [ Wed Jan 20, 2010 12:13 pm ] | ||
Post subject: | Re: Moving the ball in Brick Breaker. | ||
Okay, so now i changed it for it to bounce off the side at a different angle each time but still am having trouble getting it to move in one continious motion. Here is the new coding:
|
Author: | miller6 [ Wed Jan 20, 2010 12:16 pm ] | ||
Post subject: | Re: Moving the ball in Brick Breaker. | ||
sorry, i missed part of it.
|
Author: | Insectoid [ Wed Jan 20, 2010 1:33 pm ] | ||
Post subject: | RE:Moving the ball in Brick Breaker. | ||
This part should not be in the loop. You are selecting a random direction every time the loop iterates, which makes your ball fuffle around aimlessly. |